Beruflich Dokumente
Kultur Dokumente
What is digital design ? Slide 1 Analog v. Digital Digital Devices Digital Abstraction Slide 3 Analog devices process signal that can assume any value across a continuous range and produce results that are also in continuous form. Examples of continuous signal include voltage, current, force, etc.. Digital devices process signals that take on only two discrete values such as 0 and 1 and produces output that can be represented by 0 and 1.
Gates (contd)
AND gate
Performs the AND logic operation on its inputs and outputs its result.
Input output
OR gate
Performs the OR logic operation on its inputs and outputs its result.
Input output
NOT gate
Also referred to as inverter, produces an output value that is the opposite of the input value. Slide 12
Input output
Slide 10
Logic 1
High 3,5 V
Slide 14
Integrated Circuits
Slide 17 A collection of one or more gates fabricated on a single silicon chip to achieve a specic function is called an integrated circuit or IC for short. Slide 19
Slide 18
Slide 20
Slide 21
Introduction
Slide 2 Digital design deals with binary digits. In practice, very few numbers, events, conditions, and operations are in binary. This chapter shows how to represent non-binary numeric quantities and how to perform numeric operations in binary.
Slide 4
Binary Number
Slide 7 A N bit binary number can represent up to 2N distinctive binary codes. The 2N distinctive codes can be formed by successively adding 1 to the previous code until all N bits are 1s. For example, for 2 bit binary number, it has 4 codes: 00 01 10 11.
Slide 5
D=
i=P
di bi
where di is the ith digit and b is the base of the numbering system.
Binary Number
Slide 6 Binary numbers consist of a string of digits of values 0 or 1 such as 0101. The leftmost digit is called the most signicant bit (MSB) while the rightmost one the least signicant bit (LSB). Slide 8
Decimal to unsigned binary The binary equivalent of a decimal number is obtained by successively dividing the decimal number by 2 until the quotient is 1. The binary number is formed by the reminder (modulus) of each successive division and the nal quotient, with the nal quotient as the MSB and the rst reminder as the LSB. For example, 17910 = 101100112
HEXADECIMAL Number
HEXADECIMAL number has a base of 16, consisting of 16 digits ranging from 0 to 9 and A to F. For example, F1A3. Each hex digit corresponds to 4 binary digits. The decimal value of a hex digit ranges from 0 to 15. Hex numbers are often used to describe computer memory location. They are only used for human consumption.
F 1A316 = 1111000110100011 Binary to HEX: starting from right, replace each four binary digits with the corresponding HEX digit as shown in Table 2-1. Add leading 0s if there are fewer than 4 bits.
Slide 9
Slide 11
HEX to DECIMAL
HEX to Decimal
F 1A316 = 15 163 + 1 162 + 10 161 + 3 160 = 6185910 Decimal to HEX For example,
Slide 10
The HEX equivalent of a decimal number may be obtained by successively dividing the decimal number by 16 until the quotient is less than 16. The HEX number is formed by the reminder of each successive division and the nal quotient, with the nal quotient as the most signicant digit (the left most) and the rst reminder as the least signicant (the right most) digit. For example, 341710 = D 5916
Slide 12
011000110011102 = 18CE16
Slide 13
Slide 15
OCTAL Numbers
Slide 14 The OCTAL numbering system has a base of 8, using digits 0-7. Each OCTAL digit can be uniquely represented by 3 binary bits as shown in Table 2-1. Slide 16
Slide 23
Slide 25
D=
i=0
di 2i
Slide 27
Other Issues
Slide 34 Binary Code for Decimal (BCD) Gray code Character Codes Slide 36
Gray Code
Gray codes are binary numbers that have only one bit change between successive code words. They may be used to represent successive states or positions. On the other hand, the binary codes of successive numbers may have more than one bit change between successive codes. See 3-bit gray code in table 2-10.
Character Codes
Slide 38 Character codes are binary numbers used to represent characters. The most commonly used character code is ASCII codes, which represent characters with 7 bit, representing a total of 128 characters. see table 2-11.
Chapter 2 Summary
dierent positional number systems: decimal, binary, hex, and octal. conversion between dierent numbering systems. Binary addition and subtraction Slide 39 Representation of signed decimal number using twos complement binary system twos complement binary number range decimal and twos complement conversion overow twos complement addition and subtraction twos complement representation using dierent bits Gray code
Logic Signals
Slide 2 Digital logic ignores the analog by mapping real value of innite precision for a physical quantity into discrete values consisting of 0s and 1s. A digit bit can represent only two discrete states. N bits can represent 2N dierent values. See table 1 for physical quantities that can be represented by a bit. Slide 4
Truth table shows the relationship between the input and output of a logic circuit. It lists all combinations of inputs and the output produced by each input combination.
Slide 5 A logic circuit whose outputs depend only on its current inputs is called combinational circuit. A logic circuit whose outputs depend not only on its current inputs but also on past inputs, is called sequential circuit. The three gates AND, OR, and NOT can build any combinational circuits.
Slide 7
NOR Gate
Input output
output
NAND Gate
Input output
Combinational Circuit
A combinational circuit consists of an arbitrary number of gates connected in series or in parallel but not feedback loop. Slide 12
X Y F
Slide 10
Input
output
Timing Diagram
Timing diagram is the dynamic representation of the truth table. It represents input and output relationship as a function of the time.
Z= X AND Y
Logic Families
Slide 15 A logic family is a collection of dierent integrated circuit chips that have similar input, output, and internal circuit characteristics, but perform dierent logic functions. Chips from dierent families may not be compatible. Each family is dierent in the technologies used to produce the transistor.
Slide 13
X Y Z
Note signals do not change between 0 and 1 instantaneously and there is a transition period.
Transistor
Slide 16
Two most common logic families are Transistor-Transistor Logic (TTL) and Complementary Metal-Oxide Semiconductor eld eect transistor (CMOS). They dier in materials, fabrication methods, and electrical behaviors.
CMOS Logic
Slide 17 Section 3.3.2 - 3.3.4 introduce MOS transistors and the construction of gates with MOS transistors.
Slide 19
Noise Margin
voltage outputs logic 1 Noise Margin Inputs
Fan-in
Slide 22 The number of inputs that a gate can practically have. Too many inputs for a gate may lead to signicant delay. The inputs to most CMOS gates are limited to 4 to 6. Gates with a large number of inputs can be made faster and ecient by cascading gates with fewer inputs.
Slide 20
11111111111 00000000000 00000000000 logic 1 11111111111 00000000000 11111111111 00000000000 11111111111 00000000 11111111 00000000 11111111 invalid 00000000 11111111 00000000 11111111 000000000 111111111 000000000 111111111 000000000 logic 0 111111111 logic 0 111111111111111111111111 000000000000000000000000
Fan-out
Slide 23 If too many fan-out are connected to an output, the DC noise margin may not be adequate. Fanout may also aect speed.
Data Sheets
The data sheet of a chip or a digital device species the devices logical and electrical characteristics as well as operating conditions. See table 3-3 for CMOS family and table 3-11 for TTL family. To ensure the device work properly, the operating conditions must be satised.
Slide 25
Propagation Delay
Slide 24 There is a lag between an input change and the corresponding output change. Propagation delay refers to the amount of time needed for a change in the input signal to produce a change in the output signal.
Switching Algebra
It is the mathematical foundation for logic design.
+ stands for logic OR operation, e.g., x + y = x OR y stands for logic AND operation, e.g, x y = x AND Y stands for logic NOT operation or complement, e.g., x = NOT x If a logic operation involves all the three operations, the precedence order is: , , and +, e.g. , X + Y Z .
F (X, Y, Z ) = X Y + Z Y F (X, Y, Z ) = (X + Y ) (Z + Y ) see more examples on page 192 Like theorem 8, DeMorgans law may be used to convert between sum of products and product of sums.
n Variable Theorems
The two or three variables theorems can be extended to an arbitrary number of variables, n as shown in table 4-3. T12) X + X + ... + X = X T12) X X ... X =X The DeMorgans theorem (T13, T13) Slide 10 T13) (X1 X2 ...Xn ) = X1 + X2 + ... + Xn T13) (X1 + X2 + ... + Xn ) = (X1 X2 ...Xn ) see gure 4-3, 4-4 for the use DeMorgans theorem The Generalized DeMorgans Law T14) F (X1 , X2 , .., Xn , +, ) = F (X1 , X2 , ....Xn , , +) The generalized DeMorgans theorem (T14) states that given any n-variable logic expression, its complement can be obtained by Slide 12
Duality
Principle of Duality: Any theorem or logic equation remains true if 0 and 1 are swapped and and + are swapped throughout. It doubles the usefulness of everything. In general, the dual of a logical expression F can be represented as F D (X1 , X2 , . . . , Xn , +, , , 0, 1) = F (X1 , X2 , . . . , Xn , , +, , 1, 0) where F D is the dual of F . See previous theorems for example.
X4
type 2
X5
type 1
type 1
Slide 14
type 1
type 2
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Xn
X1 X2 X3
Slide 16
type 1
type 2
truth-table rows for which the function produces a 0 output. Note for a n variable logic function, each maxterm must consist of n variables and within each maxterm, each variable is represented by its complement if the variable value is 1.
type 2
X4 X5
type 2
type 1
type 1
type 1
Xn
type 1
type 2
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Algebraic representations
For the example in table 4-5 and 4-6, we have Algebraic Sum of Minterms
An Example
Given truth table, you should derive its canonical sum and canonical product, and simplify the canonical expression. Given a logical expression, you should be able to Slide 19 derive its truth table canonical sum canonical product For example, given F=X+YZ, derive its truth table, canonical sum and canonical product.
F Slide 17
=
X,Y,Z
(0, 3, 4, 6, 7) = X Y Z + X Y Z + X Y Z +X Y Z +X Y Z
(1, 2, 5) = (X + Y + Z ) (X + Y + Z ) (X + Y + Z )
(0, 1, 2, 3) =
A,B,C
(4, 5, 6, 7)
Note 1) both canonical sum and product are not minimal;2) sum of products and product of sums may be minimal and each term may not contain n variables.
Algebraic Expression
For example, gure 4-11,
X Y Z F
Slide 21
Slide 23
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
X Y Z X Y
X + Y (X + Y ) Z F = ((X + Y) Z) + (X Y Z) X Y Z
we can obtain its algebraic expression as F = ((X + Y ) Z ) + (X Y Z ) The diagram consists of multiple levels, may cause propagation delay. Algebraic expression Slide 22 We can build an algebraic expression of a circuit by propagating expressions from inputs through gates towards the output. Boolean algebra may be used to simplify the expression to obtain a dierent circuit of the same logic function. Slide 24 Using Boolean algebra (Theorems T8 and T8), we can convert the expression to standard form: sum of products and product of sums. Sum of Products: F = X Z +Y Z +X Y Z
X Y Y Z X X Y Z
XZ
F = X Z + Y Z + X Y Z
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
W X X
W + X ((W + X) Y)
Product of Sums: F = (X + Y + Z ) (X + Z ) (Y + Z )
Y W (W + X + Y) Y (W + Z) Z F = ((W + X) Y) (W + X + Y) (W + Z)
X Y Z X + Y + Z
Slide 25
X Y Z
X + Z
F = (X + Y + Z) (X + Z) (Y + Z)
Slide 27
Given the same above expression, the circuit can be further simplied by removing redundant NOT gates, leading to a dierent physical circuit as shown in Figure 4-16.
W X Y X W + X (W + X) Y W W + X + Y Y W+Z Z F = ((W + X) Y) (W + X + Y) (W + Z)
Y+Z
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
They correspond to dierent physical circuits (gures 4-12 and 4-13), each has only two levels.
Slide 26
Simply applying DeMorgans law yields an equivalent algebraic expression. F = ((W + X ) Y )) (W + X + Y ) (W + Z ) whose circuit is shown in Figure 4-16.
Y Z
YZ
(c)
W X
(W X) Y
WXY
Y Z
YZ
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Example
Problem Statement: Design a four-bit prime number detector. They, though logically equivalent, may have dierent electrical properties, costs, and sizes. Inputs: Four bits representing decimal numbers from 0 to 15 Slide 31 Output: 1 if input is a prime number or 0. Truth Table Algebraic Sum or Product Expression Logic diagram see gure 4-18
Slide 29
N3
N3 N3 N2 N1 N0 N3 N3 N2 N1 N0
N2
N2 N3 N2 N1 N0 N2 N3 N2 N1 N0 F
N1
N1 N3 N2 N1 N0 N1 N3 N2 N1 N0
Slide 30
Slide 32
N0
N0 N3 N2 N1 N0 N0
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
After simplication
N3 N3 N2 N2 N1 N1 N0 N0 N3 N2 N3 N0 N3 N2 N1 N0 F N3 N2 N1 N0 N3 N2 N1 N0 N0
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Another Example
Slide 35 Design a two-bit odd number detector, which outputs one if the input number is an odd number and 0 otherwise.
Slide 33
N1
SECURE
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 38
ALARM = PANIC + ENABLE EXITING WINDOW + ENABLE EXITING DOOR + ENABLE EXITING GARAGE
(b)
(a)
Slide 40
(c)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(c)
(a)
(b)
Slide 42
The same kind of manipulation can be applied to arbitrary logic circuits as shown in Figure 4-24.
label each cell in K-map that corresponds to 1 circle the adjacent 1-cells (minterms) and combine them write the sum of new products Note 1) more than 2 1-cells may be combined 2) the number of cells in a circled region must be power of 2. 3) the circled region must be rectangular 4) account for all adjacent relationships 5) consider wrap-around when circling cells in the boundary
Minimal Sum
6) start with the region that includes the most number of 1-cells Slide 49 see gure 4-27 for example. Slide 51 A minimum sum of products of a logic function is the one that has the fewest possible number of product terms and that has fewer or equal number of logic variables than any sum of products expression of the same number of products.
Rule of Combination
Given a K-map with circled regions, the following rules specify how to determine the form of the combined product graphically. If the circled area covers only regions where the variable is 0, then the complement of the variable appears in the combined form. If the circled area covers only regions where the variable is 1, then the variable appears in the combined form. If the circled area covers both regions where the variable is 0 and 1, then the variable does not appear in the combined form. see examples in gure 4-30, 4-31, and 4-32.
Denitions
a prime implicant in a K-map is a circled set of 1-cells that satises combining rules and that will cover one or more 0s if we make it larger a distinguished 1-cell is a 1-cell in a K-map that is covered by only one prime implicant. an essential prime implicant is a prime implicant that covers one or more distinguished cells. Given two prime implicants P and Q in a reduced K-map, P is said to eclipse Q if P covers at least all the 1-cells covered by Q.
Slide 50
Slide 52
In this case, trial and error may be used. For example, gure 4-37.
Programs (e.g. Espresso) are available that implement certain algorithms to automatically nd the minimal sum. See more examples in problem 4-14. Also note the minimal sum may not be unique.
Slide 54
Slide 56
Slide 57
Slide 59
(0, 1, 3, 4, 5)
Slide 58
This can be done 1) using F = W,X,Y = (2, 6, 7) but the result is minimal expression in SOP; or 2) direct minimization with the maxterms (corresponding to 0-cells); 3) get F, minimizing F as SOP, and complement the minimal F to get the minimal F. Note 2) and 3) should obtain the same result.
where d(.) represents the dont care inputs. In K-map, the dont cares cells may be marked as d or x.
Slide 63
N3
(a) N1 N0
N3 N2 00 00 01 11 N1 10
0 1
N3 (b) 01
4 5
N3 N2 N1 N0 N3 N0 00 01 1 1 1 N2 1 1 00 01 11 d d d d
11
12
10
8 9 11
10
N2 N0
d
13
1
3 7
1 1
6
d
15
N0 N1 N2 N1
1
2
d
14
d
10
11 10
d d
N0
1 N2
F = N3,N2,N1,N0(1,2,3,5,7) + d(10,11,12,13,14,15)
F = N3 N0 + N2 N1
Slide 62
Slide 65
Chapter 6 Combinational Logic Design Practices This chapter is concerned with examples of basic combinational circuits including PLA, decoders, encoders, comparators, xor gate and parity circuits, multiplexers, adders, and FPGA. Those basic building circuits frequently appear, as building blocks, in the combinational circuits.
Block Diagrams
Slide 3 Block diagram shows the inputs , outputs, functional modules, internal data paths, and important control signals of a system. See Figure 6.1 for example.
Slide 1
Documentation Standards
Documentation is necessary for correct design and ecient debug and maintenance of digital systems. A documentation should consist of the following items: a specication describes the functionality (e.g., what it does ) of a circuit and its inputs and outputs. Slide 2 a block diagram is an informal pictorial description of the circuits major functional modules and interconnections. a schematic diagram is a formal specication of the electrical components of the system, their interconnections, and details about each IC chips. a timing diagram shows the various logic signals as a function of time. Slide 4
SHIFT-AND-ADD MULTIPLIER
RESET LOAD RUN DISPLAY R/W 4 CONTROL ADDR BYTE EN IN 16-word x 32-bit RAM OUT
MULTIPLEXER 4 to 1 32
A REGISTER 32
B REGISTER 32
OUTBUS
Page 1
Page 2
Page 3
Page 4
Slide 5
Note a bus is a collection of two or more signal lines. It represents interconnection and data ow between two functional modules.
Slide 7
Page 5 Page 6
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
A timing diagram illustrates the logical behaviors of signals in a digital circuit as a function of time. The most important information provided by a timing diagram is a specication of delay. See Fig. 6-19. Note a delay is subject to many factors and is often specied by a range between maximum and minimum delay or by a typical delay value. Slide 8
(b) GO READY
Slide 6
Page 4 Page 5 Page 6
tRDY DAT tDAT (a) GO ENB READY READY DAT tRDYmin tRDYmax DAT tDATmin
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
tRDY
tDAT
(c) GO
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
tDATmax
Gate Symbols
Dierent gate symbols will appear in schematic diagram of a circuit. Standard gate symbols have been introduced. Figures 6-3 and 6-4 show standard shapes for commonly used gates. Slide 9 Note a buer is a circuit that converts weak logic signals to strong ones.
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Active Levels
Slide 11 Each signal has an active level associated with it. A signal is active high if it performs the named action when it is high. A signal is active low if it performs the named action when it is low. A signal is said to be asserted if it is at its active level. A signal is said to be negated if it is not activated.
AND
NAND
OR
NOR
INVERTER
Slide 10
AND
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 12
NAND
Dierent naming conventions may be used to represent active levels. See table 6-1. Figure 6-5 shows how to represent the active levels of the input and output a logic circuit (as represented by a rectangular box). An inversion bubble to indicate active low while the absence of a bubble to indicate an active high. Alternatively, a logic symbol for a digital circuit may have its pins explicitly labeled as active high or active low.
Active Low
READY ERROR.L ADDR15(L) RESET* ENABLE~ ~GO /RECEIVE TRANSMIT_L
Active High
READY+ ERROR.H ADDR15(H) RESET ENABLE GO RECEIVE TRANSMIT
Slide 13
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
I1 I2 I3 I4
READY REQUEST (a) GO READY REQUEST (b) GO_L
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 14
GO
GO_L
Slide 16
P1
P2
P3
P4
P5
P6 O1 O2 O3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
I1 I2 I3 I4
Decoders
P1 P2 P3 P4 P5 P6 O1 O2 O3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 17
Slide 19
A decoder is a multiple input and multiple output logic circuit that decodes the coded input. It maps an input code into an output code. The number of inputs is usually fewer than that of output. A decoder usually contains a special input called enable. It must be asserted before the decoder can perform its normal function. It is not counted as an input. See gure 6-31.
See Fig. 6-23 for programmed PLA. Note both the AND and OR gates are programmable. Another programmable logic device is
ma p
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Inputs
EN I1 I0 Y3
Outputs
Y2 Y1 Y0
x 0 0 1 1
x 0 1 0 1
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
Binary Decoders
The most common decoder is the binary decoder where the number of output is the power of 2 of the number of input. For example, we have n to 2n binary decoder, where n is the number of input and 2n is the number of output. A binary decoder is used when you need to activate exactly one of 2n outputs based on n inputs. Note the dont care notation in the truth table.
1 1 1 1
Slide 21
Slide 23
Note the truth table will be dierent if the active levels for input/ouput are changed. What are the truth table if the outputs are all active low ? The input and output codes are not limited to consecutive decimal numbers but may represent any consecutive physical entities. For example, see table 6-5.
Disk Position
I2
I1
I0
Slide 22
2-to-4 decoder I0 I1 EN Y0 Y1 Y2 Y3 I1
Y0
Slide 24
Y1
0 0 0 0 1 1 1 1
0 0 1 1 1 1 0 0
0 1 1 0 0 1 1 0
Y2
Y3 EN (a) (b)
3-to-8 decoder Y0 Y1 SHAFTI0 SHAFTI1 SHAFTI2 ENABLE I0 I1 I2 EN Y2 Y3 Y4 Y5 Y6 Y7 DEG0 DEG45 DEG135 DEG90 DEG315 DEG270 DEG180 DEG225
Slide 25
Slide 27
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(a)
(b)
Also not all outputs of a decoder may be used, e.g., for BCD
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Outputs
Y2_L Y1_L Y0_L
Slide 29
Slide 31
1 0 0 0 0
x 0 0 1 1
x 0 1 0 1
1 1 1 1 0
1 1 1 0 1
1 1 0 1 1
1 0 1 1 1
1Y0_L
1
74x139 1G
2
1G_L
4 5 6 7
1Y1_L
1A 3 1B
15
1Y2_L
2G 2A 2B
12 11 10 9
It has three enable inputs and its outputs are active low. All the three enable inputs must be asserted before the decoder can perform its function. Its logic diagram and logic symbol are shown in Figure 6-35.
(a)
(15)
1A 1B
14
(3)
1Y3_L
13
Y0_L
(b)
6
Slide 30
(a)
(12) (15) (11)
(b) 2Y0_L
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 32
G1 G2A_L G2B_L
(6) (4) (5)
(14)
Y1_L
(13)
2G_L
Y2_L
2 3
2Y1_L
1/2 74x139 G Y0 Y1 Y2 Y3
(12)
Y3_L
2Y2_L
2A 2B
A B
(11)
Y4_L
(10)
(13)
2Y3_L
(c)
(1)
Y5_L
(9)
(2)
Y6_L
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(3)
(7)
Y7_L
+5V R
6 4 5
Truth table is shown in Table 6-6. An output is asserted if only the decoder is enabled and the output is selected (e.g., Y 5L ).
T a b l e 5 - 7 Truth table for a 74x138 3-to-8 decoder.
Inputs
G1 G2A_L G2B_L C B A Y7_L Y6_L Y5_L
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 U1
15 14 13 12 11 10 9 7
Outputs
Y4_L Y3_L Y2_L Y1_L Y0_L
N0 N1 N2 N3 EN_L
A 2 B
3
0 x
x 1 x 0 0 0 0 0 0 0 0
x x 1 0 0 0 0 0 0 0 0
x x x 0 0 0 0 1 1 1 1
x x x 0 0 1 1 0 0 1 1
x x x 0 1 0 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 0 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1 1
Slide 33
x 1 1 1 1 1 1 1 1
Slide 35
74x138
6 4 5
G1 G2A G2B
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 U2
15 14 13 12 11 10 9 7
A 2 B
3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Multiplexers (contd)
The input of a multiplexer consist of
Multiplexers
A multiplexer is a digital switch that determines which of its n input data should be routed to output. It is a useful device in any application where data must be switched from multiple sources to a destination source. For example , the multiplexer between the processors registers and its arithmetic logic unit (ALU). The data from one of the registers must be routed to ALU for execution.
n input data, each of which is b bit wide. n is usually 2,4,8,16. and b is 1,2, 3.. Slide 39 s selections inputs to determine which of the n sources to select. s = log2 n. an enable input, which must be asserted for the multiplexer to function. Output: one of the n input data see gure 6-59.
Slide 37
(b)
(a) enable s
Slide 38
select
SEL
EN
EN_L
(7)
D0
(4)
See logic symbols and truth tables for 74 157 (2 inputs and 4 bit )
(a) G_L S
(15) (1)
D1
(3)
(b)
15 1 2
74x157 G S 1A 3 1B
5 4
D2
(2)
1Y 2Y 3Y 4Y
D3
Y Y_L
1A
(2)
6 11 (4)
D4
(15)
2A 2B 3A 3B 4A 4B
1B
(3)
1Y
10 14 13
12
Slide 41
D5
(14)
Slide 43
74x151
2A
(5)
D6
(13)
D7
(12)
4 3 2
D0 D1 D2 D3 D4 D5 D6 D7
Y Y
5 6
3A
(11)
(11)
1 15 14
(9)
3B
(10)
3Y
(10)
13 12
4A
(14)
(12)
(9)
(a)
(b)
4B
(13)
4Y
Outputs
Y Y_L
Inputs
G_L S 1Y
Outputs
2Y 3Y 4Y
1 0 0 0 0 0 0 0 0
x 0 0 0 0 1 1 1 1
x 0 0 1 1 0 0 1 1
x 0 1 0 1 0 1 0 1
0
D0 D1 D2 D3 D4 D5 D6 D7
1
D0 D1 D2 D3 D4 D5 D6 D7
x 0 1
0
1A 1B
0
2A 2B
0
3A 3B
0
4A 4B
Slide 42
Slide 44
0 0
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
EN 11 A 10 B 9 C
(7)
2B
(6)
2Y
74x151
(a) A
(14)
7 11 10 9 4 3 2 1 15 14 13
EN A B C D0 D1 D2 D3 D4 D5 Y Y
5 6
(2)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
XO0_L
1G_L
(1)
D6 12 D7
U2
1G
2 3
74x151 EN A
1C0
(6)
XA3 XA4
1A 1B
11 10
B 9 C
4 3 2 1
1C1
(5) (7)
X8 X9
D0 D1 D2 D3 D4 D5 D6 D7
Y Y
5 6 XO1_L
1Y
15 14 13 12
1C2
(4)
1/2 74x20
6
Slide 45
1C3
(3)
Slide 47
7 11
U3
2 4
XOUT
74x151 EN A B C D0 D1 D2 D3 D4 D5 D6 D7 Y Y
5 6 XO2_L
U6
2G_L
(15)
(b)
14 2
74x153 A
X16 X17 X18 X19 X20 X21
10 9 4 3 2 1 15 14 13 12
2C0
(10)
1 6
2C1
(11) (9)
1Y
X22 X23
U4
2Y
15 10 11 12
2C2
(12)
74x151
7 11 10 9
EN A B C D0 D1 D2 D3 D4 Y Y
5 6 XO3_L
2Y
2C3
(13)
13
4 3 2 1 15 14 13
D5 D6 12 D7
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
U5
Expanding Multiplexers
Slide 46 Smaller multiplexers can be combined to form a larger multiplexer. See Fig. 6-62. Slide 48
Opposite the operation of a decoder, a binary encoder assumes only one of its inputs is activated at a time and the output corresponds to the asserted input. See the truth table below.
Encoders
Multiple-input/multiple-output device. Slide 49 Performs the inverse function of a Decoder. Outputs ( m ) are less than inputs ( n ). Converts input code words into output code words. It may be applied to handling multiple devices requests But, no simultaneous requests, i.e., only one input can be activated at a time. Slide 51
Binary Encoders
The simplest encoder is the binary encoder, whose number of input is 2n and the number of output is n, such 8-to-3 binary encoder below.
Priority Encoders
To handle multiple requests, i.e., to allow multiple inputs to be asserted at the same time, priority encoder may be used.
Slide 50
Slide 52
It is clear that the output only corresponds to the input with the highest priority. The low priority inputs are ignored, independent of their states (dont care). Output enable is asserted only when all inputs are not activated. The GS output is asserted if any of of the
Slide 54
Slide 56
input is asserted.
Slide 60
74x126
(4) (5) (6) (10) (9) (8)
Comparator
A circuit that compares two binary inputs and indicates if they are equal are called comparator. By denition, an XOR gate is a one-bit comparator. Multiple XOR gates can be used to perform multiple bit comparator. For example, 4 XOR gates for a 4-bit comparator is shown in Figure 6-74. Slide 63
(b) A0 B0 A1 B1 (a) A2 B2 1/4 74x86 A0 B0
1 2 3 1 2 4 5
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
74x86
3
DIFF0 74x02
2
U1
6
DIFF1
DF01_L 74x00
1 2 3
U1
9 10 8
U2 DIFF2 74x02
5 6 4
DIFF
DF23_L
U3
U1 DIFF A3 B3
12 13 11
U2 DIFF3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
U1
U1
Refer to gure below for logic diagrams and symbols for XOR and XNOR gates.
(a)
(b)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Adder
9 10 8
Slide 62
Slide 64
An adder performs arithmetic addition of two operands using the addition table. An adder whose two operands are 1-bit is called half-adder. An adder whose two operands are more than 1 bit are called full adder.
4 5
12 13
11
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
S COU T
= =
S CO
= X Y = X Y
(a) COUT X COUT (c) S Y CIN
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Full Adder
A full adder handles more than one bit of binary addition (with carry). While performing bitwise addition, each bitwise addition has the following inputs and outputs: Inputs: Slide 66 input operands X and Y carry in (CIN) Outputs:
s3 s2 s1 s0
Ripple Adder
A ripple adder is a cascade of n full-adders, each of which handles one bit. See Figure 6-84 for 4-bit ripple adder. It can perform 4-bit addition. Slide 68
c4 x3 X COUT S y3 Y CIN c3 x2 X COUT S y2 Y CIN c2 x1 X COUT S y1 Y CIN c1 x0 X COUT S y0 Y CIN c0
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
We can similarly build a n bit ripple subtractor by cascading n full subtractors as shown in gure 6-85.
(a)
1 2
(c)
1 2
X
3
Y
5
BOUT BIN D
(d)
Slide 71
xn1
yn1
1
xn2
yn2
3
x0
y0
13
74x04
2 1 2 1 4 2
74x04
74x04
12 1 2
b_Ln1 5
b_Ln2
b_L1 5
b_L0 1
dn1
dn2
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
d0
Note a full subtractor can be implemented with a full adder circuit plus inverters.
Slide 70
D BOU T
Clock Signal Most sequential circuits undergo a state change by a clock signal. For clock signal, it may be active high or active low. Its state my include high, low, rising edge, and falling edge. Its parameters include period, frequency, and duty cycle. See gure 7-1.
(a) CLK state changes occur here
Chapter 7 Sequential Logic Design Principles A sequential circuit is one whose output depends not only on its current input but also on its previous inputs. This implies that sequential circuit has memory that can remember previous inputs. Examples of sequential circuits: TV channel controller, elevator controller, etc.. This chapter introduces two types of sequential circuits: feedback sequential circuit and clock synchronous state machine.
Slide 1
Slide 3
tH tper
tL
(b) CLK_L
tL tper
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
State In addition to input, another important attribute of a sequential circuit is its state. The state of a circuit determines the internal condition of the circuit. For a sequential circuit, its output is determined not only by the input but also determined by its state. A state can be stable or metastable. Slide 2
Bistable Circuit The simplest sequential circuit is bistable circuit consisting of two inverters. It has no inputs and two outputs as shown in gure 7-2. Its state is characterized by the values of its two outputs. It has only two states (1 ,0) or (0,1). Its output only depends on its previous input through a feedback loop.
metastable
Slide 4
stable
stable
S-R Latch
Vin1
Vout1
S 0 0 1 1 (b)
R 0 1 0 1
QN
last Q last QN 0 1 0 1 0 0
(a)
QN
Slide 5
Vin2
Vout2
Slide 7
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Q_L
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
The circuit has two external inputs, two feedback loops, and two outputs. The circuit remembers its previous state if its two external inputs are 0 (negated). Q=R (LQ +S) QN= S (LQN +R )
S-R Latch (contd) One input (S) sets the output (Q) and the other (R) input clears the output (Q). If both inputs are asserted, both outputs are 0 (metastable state may occur). See truth table in gure 7-5(b) and timing (operation) diagram in gure 7-6.
S
Latches and Flip-Flops Latches and ip-ops are the basic building blocks for most sequential circuits. They each represents a feedback loop made up of logic gates. A latch diers from a ip-op in that the former continuously samples its input , independent of a clock signal while the later samples its input only at times determined by a clock. Flip-ops are also called latches with dynamic clocks.
Slide 6
Slide 8
(a)
R Q QN (b)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Figure 7-7 gives the logic symbol of the S-R latch. A S-R latch may be used as a switch. Note the circuit diagram, S corresponds to QN and R corresponds to Q.
Timing Parameters for S-R Latch propagation delay-the time it takes for a transition from input to produce a transition on an output signal. The output transition can be low to high or high to low. Minimum pulse width-it is the minimum time for an input signal to go from one state to another and then return to its original state. If the time is too short, this may cause metastable state. See g. 7-8.
S (1) R (2) Q
S R
Q QN
S R
Q Q
S R
Q QN
Slide 9
(a) (b) (c)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 11
tpLH(SQ)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
tpHL(RQ)
tpw(min)
-R Latch S Avoiding Unstable Behaviors Two undesirable behaviors with a latch are: oscillation and metastable. The former may be induced by changing R and S from 1 to 0 at the same time (see gure 7-6(b)). The latter may be caused if the input signal is changed back and forth too fast (see gure 7-8). The former can be avoided by not allowing R and S to both be 1 at the same time. The latter may be avoided by ensuring the input signals satisfy the minimum-pulse-width (ppw(min) ). -R latch diers from S-R latch in that the two external The S inputs and the two feedback loops are both active low. It consists of two NAND gates. See gure 7-9.
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(a)
S_L or S Q
(b)
S_L R_L 0 0 1 1 0 1 0 1
Q 1
QN 1
(c)
S R Q Q
Slide 10
Slide 12
R_L or R
QN
0 1 1 0 last Q last QN
+ LQ R Q=S +S LQN QN = R It is preferred over S-R latch due to the use of NAND gates.
-R Latch (contd) S
S
Ignored since C is 0.
Ignored until C is 1.
Slide 13
Inputs are active low. The output remains the same as S-R latch. corresponds to Q and R corresponds to In the circuit diagram, S NQ. When S and R are both asserted (equal to 0), then the two outputs are 1 instead of 0 as for S-R latch. When both inputs are -R latch, S negated, the latch remembers its previous state. For S clears Q. sets Q and R
R C
Slide 15
Q QN
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
S-R Latch with Enable (gated SR latch) An enable input is added to the S-R latch, yielding a 3-input S-R latch. The S-R latch behaves like a S-R latch if the enable input is asserted. It, however, assumes its previous state if the enable input is negated. See its truth table in gure 7-10 and timing diagram in gure 7-11. Note the dierence in circuit diagrams between an S-R latch and S-R with enable.
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
D Latch A D-latch is a special S-R latch with enable. It is useful when you need a device to store (remember) a bit of data. Its R input is generated by inverting its S input, leading to one external input D. see gure 7-12.
D Q C D 1 1 QN (a) (b) 0 0 1 x Q 0 1 QN 1 0
D C Q Q
Slide 14
Slide 16
(a)
S Q C QN R
(b)
S R C 0 0 1 0 1 1 1 0 1 1 1 1 x x 0
QN
(c)
S C R Q Q
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
If both S and R are 1 when the enable changes from 1 to 0, this circuit output may oscillate (see gure 7-11).
This eliminates the case where both inputs are asserted simultaneously (avoid oscillation). Its output follows its input if the enable input is asserted. If the enable input is negated, its output retains its previous state. See gure 7-13.
Slide 17
Slide 19
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
For a latch without enable, the output continuously samples input. For a latch with enable, the output continuously samples input when the enable is asserted. For a ip-op, the output samples input only at a specic time determined by an external clock signal.
Positive Edge-Triggered D Flip-Flop D Latch (contd) D-latch, however, can not eliminate the metastable problem with S-R latch. The latch may enter a metastable state if the input signal D changes back and forth too fast or it changes during the setup- and hold-time of the enable signal C as shown in gure 7-14.
D
Slide 18
Slide 20
It consists of two D-latches connected in series and a clock signal. The rst one is called master while the second one is called slave latch. The salve always follows the master. While the clock is low, the master latch is enabled and its output follows its D input. When the clock makes a low-to-high change, the master latch is disabled and the last value it saw is stored and transfered to the slave latch. Refer to gure 7-15 (a).
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
tpHL(DQ) tpLH(CQ)
thold tsetup
(a) D
D C Q
(b) QM
D C Q Q
(c) D 0 1 x x 0 1 CLK Q 0 1 QN 1 0
D CLK Q Q
Q QN
CLK
Positive Edge-Triggered D Flip-Flop(contd) The slave is enabled while the clock is high, its output follows its input. However, its output only changes at the time the clock goes high since its input is connected to the master and the master can not change when the clock is high. This produces the edge-triggered eect. The output follows input only when the clock is at its rising edge. See gure 7-16 and Fig. 7-15 (b). Slide 21
D CLK QM Q QN
Edge-Triggered D Flip-Flop with Enable An enable input is added to the edge-triggered D ip-op to allow it to assume its previous value even at the rising edge of the clock signal. The enable signal does not matter if the clock signal is not at its rising edge. see gure 7-21.
(a) D EN
D CLK Q Q
Slide 23
(b) D EN CLK 0 Q QN 1 x x x 1 1 0 x x 0 1 Q 0 1 QN 1 0
(c)
D EN CLK Q Q
CLK
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
See Fig. 7-15(c) for the logic symbol of D-FF. Note the dierence from the that of D latch. Metastable state still occurs if the input
Edge-triggered J-K Flip-Flop signal changes during the setup and hold time of the clock signal. See Fig. 7-17.
D
CLK
Slide 22
tpLH(CQ) tpHL(CQ)
thold tsetup
Slide 24
In summary, the positive edge-triggered D ip-op samples its input only when the clock signal at its rising edge. Its output follows its input only when the clock signal is at its rising edge. Its output assumes its previous state if the clock input is asserted or negated.
It contains an edge-triggered D ip-op. Here the J-K ip-op is triggered by the rising edge of the control signal. The ip op assumes its previous state if the control signal is asserted or negated. At the rising edge of the clock (control) signal, the Q output follows J input while the QN outputs follows K input. While both J and K are asserted at the same time and the clock is at its rising edge, Q assumes previous QN and QN assumes previous Q. See gures 7-28 and 7-29
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(a)
(b) J J
D Q Q
(c) K CLK x x 0 1 0 1 0 1 Q QN
J CLK K Q Q
x Q QN x 0 0
K CLK
CLK
1 1
last QN last Q
EN T
J K CLK
D CLK
Q Q
Q QN (b)
EN T
J CLK K
Q Q
Q QN
(a)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 25
Slide 27
(a)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(b) EN
EN T Q Q
T Q
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(b) Q T T
CLK
Q QN
QN
Slide 26
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 28
Its output follows the clock signal at half the frequency of the input.
Q T Q
State machine is a generic name given to a sequential circuit. clocked refers to the ip-ops of the sequential circuit are controlled by a clock signal. Synchronous all ip-ops use the same clock signal,which causes the op-ips to change states at each tick (rising/falling edge) of the clock.
T Q (b)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(a)
State Machine Structure A state machine consists of three components: state memory, next-state logic, and output logic as shown in gure 7-35.
inputs inputs Next-state Logic F excitation State Memory clock input current state Output Logic G
Next-state Logic F
excitation
State Memory
current state
Output Logic G
outputs
outputs
clock input
Slide 29
clock signal
Slide 31
clock signal
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
state memory is a set of ip-ops that store current state. Given n ip-ops, it can store 2n states. Its inputs include an excitation signal and a clock signal (which connects to all ip-ops). Its output is current state.
An Example of a State Machine State Machine Structure (contd) The next-state logic determines the next state of the state machine. It is a function of input and current state. The output logic determines the output of the state machine. It is a function of input and current state. Both the next-state logic and output logic are combinational circuits. Sequential circuit whose output depends on both its input and current state is called Mealy machine. Sequential circuit whose output depends only on current state is called Moore machine (see gure 7-36).
input EN EN EN D0
D CLK Q Q
Next-state Logic F
State Memory
excitation Q0
MAX
Slide 30
Slide 32
Q0 Q0 D1
D CLK Q Q
Q1
Q1 Q1
current state
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Characteristic Equations The characteristic equation of a latch or ip-op species the ip-ops next state as a function of its current state and inputs when the the enable is asserted (for latch) or when the clock is at its rising edge (for FFs). See table 7-1.
Device Type Characteristic Equation
Q = S + R Q Q = D Q = D Q = EN D + EN Q Q = S + R Q Q = J Q + K Q
Slide 33
Analysis of State Machine Slide 35 The goal of analysis of state machine is to characterize the behavior of sequential circuit in terms of relationship between its input, current state, next state, and output (note how this diers from combinational circuit analysis).
Edge-triggered D flip-flop
D flip-flop with enable
Analysis of State Machine Three steps in state machine analysis: the control inputs when output samples input, e.g., during a clock tick for FF and when the enable is asserted for latch. 1. Determine the next state function F and output function G Slide 36 2. Use F and G to construct state/output table that completely species the next state and the output of the circuit for every possible combination of current state and input. 3. Draw a state diagram
Slide 34
Analysis of State Machine: Example determine excitation equation identify the FF, the state variables, and give the characteristic equation construct transition equations Slide 37 build transition table build state table Derive the output equation build state/output table draw state diagram Analysis of an example state machine Slide 39
(a)
Q1 Q0 0
EN 1
(b)
S
A B C D
EN 0
A B C D S
(c)
1
B C D A
EN S
A B C D
0
A, 0 B, 0 C, 0 D, 0
1
B, 0 C, 0 D, 0 A, 1
00 01 10 11
00 01 10 11
01 10 11 00
Table 7-2 Transition, state, and state/output tables for the state machine in Figure 7-38.
Q1 Q0
S, MAX
Next-state Logic F
State Memory
EN = 0
(MAX = 0)
EN = 0 A EN = 1
(MAX = 0) (MAX = 0)
input EN EN EN D0
excitation Q0
MAX
D CLK
Q Q
EN = 1
(MAX = 1)
EN = 1
(MAX = 0)
Q0 Q0 D1
D CLK Q Q
Q1
Slide 38
Q1 Q1
Slide 40
EN = 0
(MAX = 0)
EN = 1
(MAX = 0)
C EN = 0
(MAX = 0)
current state
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
See g. 7-41 for a redrawn state machine Transition, state, and state/output table (Table 7-2) see the analysis of the state machine shown in g. 7-43
EN = 0 A
MAXS=0
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
EN = 0 EN = 1 B
MAXS=0
MAX
EN = 1
D0
EN = 1
Slide 41
EN CLK
D CLK
Q Q
Q0
D1
D CLK
Q Q
Q1
Slide 43
D
MAXS=1
EN = 1
C
MAXS=0
EN = 0
EN = 0
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Analysis of Moore Machine Unlike Mealy state machine, the output of a Moore machine depends only on its current states . This dierence leads to dierent (simpler) state/output table and state diagram. For the state machine in Fig. 7-38, if the EN input to the output logic is removed, it becomes a moore machine. See table 7-3 and gure 7-40 for the state/output table and the state diagram. Slide 42
Table 7-3 State/output table for a Moore machine.
EN S
A B C D
D0
D CLK
Q Q
Q0
D1
D CLK
Q Q
Q1
Slide 44
1
B C D A
Z2
Q2 Q0 Q0 X CLK Q
D2
Q2 Z1
0
A B C D S
MAXS
0 0 0 1
CLK
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Table 7-5 Transition/output and state/output tables for the state machine in Figure 7-45.
(a)
Q1 Q0 00 01
XY 10 11
(b)
S
A B C D
XY 00
A, 0 B, 0 C, 0 D, 0 S
01
C, 1 D, 0 A, 0 C, 0
10
B, 0 C, 0 D, 0 A, 1
11
C, 1 D, 0 A, 0 C, 1
00 01 10 11
Q1 Q0, Z
, Z
State Diagram
X Y A
Z = 0 unless otherwise indicated
X Y B
X Y
X Y Y Y
(Z = 1)
Y X Y X Y
(Z = 1)
C X Y
X Y X Y
(Z = 1)
D X Y
J0 K0
J CLK K
Q Q
Q0
X Q0 Y X
X
Y
J1 K1
Q0 J CLK K Q Q
Q1
Q1 Q0 Q1 Y
Q0 X Y Q0
State Machine Design and Synthesis Slide 48 Like combinational design, design of state machine involves formalization of the problem description and the development of a sequential circuit to solve for the stated problem. It represents the reverse of state machine analysis.
Slide 46
CLK
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
State Machine Design Steps 1. Formalize the problem description with a state/output table or with a state diagram identify inputs, outputs, and possible states represent the identied inputs, outputs,and states with mnemonic names Slide 49 construct the state/output template instantiate the template based on the problem description using the named inputs, output,and states. 2. Assign binary combinations to the named states 3. Substitute the state-variable combinations into the state/output table to create a transition/output table. 4. Determine the number of FFs and identify a ip-op (D or J-K) 5. Derive an excitation table that shows the output of the next Slide 51
State Machine Design Example Problem Description Design a clocked synchronous (Moore) state machine with two inputs A and B, a single output Z that is 1 if : A had the same value at each of the two previous clock ticks, or B has been 1 since the last time that the rst condition was true Otherwise, the output should be 0. Since we are dealing with Moore machine, the second condition can be alternatively interpreted as the state of the machine stays the same if B has been 1 since last time condition 1 is true. See g. 7-45 for the timing diagram. Note a clock tick represents the rising edge of the clock signal. Between two neighboring clock ticks,
logic circuit as a function of inputs and current states. 6. Derive the excitation equations from the excitation table Slide 50 Minimize the excitation equation using K-map 7. Derive the output equation from the transition/output table. 8. Draw the logic diagram Slide 52
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Build state/output table Identify inputs,outputs,and possible states and name them Inputs: A,B Output: Z Slide 53 States: A1, A0, OK0 (A00), OK1(A11), INIT Construct the state/output template Instantiate the template based on the problem description using the named inputs, output,and states. See gures 7-46 and 7-47. Slide 55 State/output table
Ta bl e 7 - 6 State and output table for example problem.
AB S
INIT A0 A1 OK0 OK1
00
A0 OK0 A0 OK0 A0
01
A0 OK0 A0 OK0 OK0
11
A1 A1 OK1 OK1 OK1 S
10
A1 A1 OK1 A1 OK1
0 0 0 1 1
(a) Meaning
Initial state
AB
(b) 11 10
Z
AB
S
INIT ... ... ...
00
01
Meaning
Initial state Got a 0 on A Got a 1 on A
S
INIT A0 A1
00
A0
01
A0
11
A1
10
A1
0 0 0
(c) Meaning
Initial state Got a 0 on A Got a 1 on A Got two equal A inputs
AB
(d) 11
A1 A1
AB
S
INIT A0 A1 OK
00
A0 OK
01
A0 OK
10
A1 A1
Meaning
Initial state Got a 0 on A Got a 1 on A Got two equal A inputs
S
INIT A0 A1 OK
00
A0 OK A0
01
A0 OK A0
11
A1 A1 OK
10
A1 A1 OK
0 0 0 1
0 0 0 1
State Assignment Slide 56 Determine the number of binary variables needed to represent the named states and assign a specic binary combination to each state. For ve states, we need 3 binary state variables Q1 , Q2 , and Q3 . This means we need 3 ip-ops.
S
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Slide 54
(a)
AB
Meaning
Initial state Got a 0 on A Got a 1 on A Got two equal A inputs
S
INIT A0 A1 OK
00
A0 OK A0 ?
01
A0 OK A0 OK
11
A1 A1 OK OK
10
A1 A1 OK ?
(b)
AB
Meaning
Initial state Got a 0 on A Got a 1 on A Two equal, A=0 last Two equal, A=1 last
S
INIT A0 A1 OK0 OK1
00
A0 OK0 A0
01
A0 OK0 A0
11
A1 A1 OK1
10
A1 A1 OK1
0 0 0 1
0 0 0 1 1
(c)
AB
Meaning
Initial state Got a 0 on A Got a 1 on A Two equal, A=0 last Two equal, A=1 last
S
INIT A0 A1 OK0 OK1
00
A0 OK0 A0 OK0
01
A0 OK0 A0 OK0
11
A1 A1 OK1 OK1
10
A1 A1 OK1 A1
(d)
AB
Meaning
Initial state Got a 0 on A Got a 1 on A Two equal, A=0 last Two equal, A=1 last
S
INIT A0 A1 OK0 OK1
00
A0 OK0 A0 OK0 A0
01
A0 OK0 A0 OK0 OK0
11
A1 A1 OK1 OK1 OK1
10
A1 A1 OK1 A1 OK1
0 0 0 1 1
0 0 0 1 1
S
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
State Assignment (contd) State assignment aects the complexity, eciency, and cost of the circuit. It may also aect the choice of the storage elements. State assignment needs experience. But some rules may apply. For example, select the initial state that the circuit can easily be set to and minimize the number of state variable changes at each transition. Slide 57 See table 7-6 for possible state assignment. Pay attention to the decomposed scheme, where Q1 indicates if it is INIT or not, Q2 indicates the value of output, and Q3 indicate the value of A.
Assignment State Name
INIT A0 A1 OK0 OK1
Excitation Table Assuming we use D ip-op, the transition table is the same as excitation table as shown in table 7-8 except that Q1,Q2, and Q3 are replaced by D1, D2, and D3 respectively. Slide 59
Ta bl e 7 - 9 Excitation and output table for Table 7-8 using D flip-flops.
AB Q1 Q2 Q3 00 01 11 10 Z
0 0 0 1 1
Simplest Q1Q3
Decomposed Q1Q3
One-hot Q1Q5
Table 7-7 Possible state assignments for the state machine in Table 7-6.
D1 D2 D3
Excitation Equation Transition Table Substituting the assigned binary states to the state table to obtain the transition table as shown in table 7-7.
AB
Slide 58
Q1 Q2 Q3
00
01
11
10
0 0 0 1 1
Derive the excitation equations and minimize them using K-map assuming the output for the unused states are either 0 or dont care. see gure 7-50. Note how to create a 5-variable K-map from 2 4-variable K-maps. For the 2 4-variable K-maps, cells in the same position are considered adjacent. Ignore Dont cares Slide 60
D1 Q2 Q3 00 01 11 Q2 10 Q1=0 0 0 B Q2 Q3 A D2 Q2 Q3 00 01 11 Q2 10 Q1=0 0 0 B 0 0 AB 00 0 0 0 01 0 0 0 11 0 0 0 A 10 0 0 Q3 0 Q2 10 Q1=1 1 1 B 1 0 11 0 1 1 1 Q1 Q3 A Q1 Q2 B Q1=0 B Q1=1 B Q2 10 0 0 0 0 Q2 Q3 00 01 AB 00 1 0 01 1 0 11 0 1 A 10 0 1 Q3 11 0 0 0 0 Q2 10 0 0 1 1 Q1 Q3 A D3 Q2 Q3 00 01 AB 00 0 0 01 0 0 11 1 0 A 10 1 0 Q3 11 0 0 1 1 Q2 Q3 00 01 0 0 AB 00 1 0 0 01 1 0 0 11 1 0 0 A 10 1 0 Q3 0 Q2 10 Q1=1 1 1 B 1 1 Q1 11 1 1 1 1 Q2 Q3 Q2 Q3 00 01 AB 00 1 1 01 1 1 11 1 1 A 10 1 1 Q3
Q1 A AB 00 0 0 01 0 0 11 1 1 A 10 1 1 Q3
Q1 Q2 Q3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Output Equation D1=Q1+ Q2Q3 Slide 61 D2=Q1Q3A+Q1Q3A+Q1Q2B D3=Q1A + Q2Q3A Slide 63 Derive the output equation from the excitation and output table. If do not consider dont cares, Z= Q1Q2 If include dont cares, Z=Q2
Logic Diagram draw the logic diagram based on the minimal excitation equation, the output equation, and the D ip-ops. See the logic diagram below (note here the unused states are assumed to be dont-cares).
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
D1
Q1
CLK Q CLR Q1
A
D2
AB 00 00 01 11 0 d d d 01 0 d d d B 11 0 d d d
A 10 0 d Q3 d Q2 d Q2 Q3
AB 00 01 00 01 11 10 Q1=1 1 0 0 1 1 0 1 1 B 11 0 1 1 1
A 10 0 1 Q3 1 0 Q3 A Q2 B Q1 Q3 A
D3 Q2 Q3
AB 00 00 01 11 0 d d d 01 0 d d d B 11 1 d d d
A 10 1 d Q3 d Q2 d A Q2 Q3
AB 00 00 01 11 10 Q1=1 0 0 0 0 01 0 0 0 0 B 11 1 1 1 1
Slide 62
Q2 Q3
10 1 1 Q3 1 1
Slide 64
A B
Q3 A Q3 A Q2 B
D2
Q2
CLK Q CLR
Q2 10 Q1=0
Q2 10 Q1=0
D3
D
Q3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
CLK Q CLR
RESET_L
CLK
Can we design a Mealy machine to achieve the same ? or the same Moore machine with a dierent FF such as with a T FF or with a
Excitation table for J-K FFs Take the J-K FFs for example, from its characteristic equation, we can derive its characteristic table as follows. Then from the above characteristic table we can derive its excitation table as follows.
Slide 65
JK FF ?
Slide 67
Excitation table for T FFs with Enable State Machine Design with T and J-K FFs For D FF, the excitation table for D FF can be easily derived from the transition table. But for T and J-K FF, the excitation table is not that straightforward. Slide 66 From the characteristic of a FF, we can derive its excitation table. The excitation table species the inputs of a FF as a function of its current and next states. Specically, given we know the current state as well as what we desire about the next state of the FF, we want to decide what inputs we should provide to the FF in order to achieve the transition from current state to the desired next state. Slide 68 Similarly, for T FFs, its excitation table can be derived similarly from its characteristic function as follows
Slide 69
Slide 71
Given the excitation table, show how to construct a T FF (or T FF with enable from a D FF or JK FF)?
Excitation Table with J-K FF Change the transition table (table 7-8) to the following format Sequential Circuit Design Example Problem: Design a Moore state machine that accepts an input binary sequence such as 001010011101 .... Its output is zero except when the number of 1s that have been input is a multiple of three. Implement the machine using as few as ip-ops as possible. Steps: state/output table, transition table, excitation table, minimized excitation equations, minimized output equations, and diagram.
Slide 70
Slide 72
Complete the excitation table using the transition table by transferring the numbers in table 7-8 to and the J-K excitation table. We can then easily derive the excitation equations from the table.
Input, output, States Input: X Output: Z States: Slide 73 INIT-inital state S0-the number of 1s is multiple of 3 S1-the number of 1s is 1 in excess of multiple of 3 S2-the number of 1s is 2 in excess of multiple of 3 Implement this state machine using D, T, and J-K FFs respectively. Slide 75 Word Problem 1 Design a circuit that detects an input sequence of 101 and that allows overlaps. The circuit can be a Moore or a Mealy machine. Steps: state diagram, state/output table, transition table, excitation table, minimized excitation equations, minimized output equations, and diagram. Implement it using one D FF and one JK FF.
Word Problem 2 State Machine Design using State Diagrams Slide 74 State machine design with state diagram presents a graphical design approach. It is more intuitively appealing. Caution, however, must be exercised while using state diagrams since the constructed state diagram may be ambiguous. Slide 76 Design a sequential circuit that has one input (X) and one output (Z). The circuit examines groups of three consecutive inputs and produces an output. The output is Z=1 if the input sequence 1011 occurs. Draw the state diagram Give the state/output table design it as a Moore and Mealy machine ? what is the dierence ?
Counter Design (section 8.4-8.4.4) A counter increments at each clock tick. Input is a clock tick and output is the current state. Its state diagram is a single circle. A counter with m states is called a modulo-m counter or divide-by-m counter. A counter can be constructed with dierent types of FFs. But the most convenient FF for counter is T FF. Asynchronous Ripple Counter Slide 79 The simplest counter is a ripple counter constructed by cascading T FFs. See Fig. 8-24 below.
Slide 77
Q0
CLK
T Q
Q T
Q1
Counter Design Slide 78 Design a 3-bit up counter, that counts from 0 to 7 at each clock pulse and wraps around to 0 after it reaches 7. Do the design using 2 D FF and one T FF. Slide 80
T
Q Q
Q2
Q T Q
Q3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
CNTEN CLK
EN T
Q0
EN
Q1
Slide 81
It is slow because of CLK propagation from the least signicant output (Q0) to the most signicant output (Q3).
Slide 83
EN T Q
Q2
EN T
Q3
All FFs share the same clock and they hence change state at the same time. But this requires using TTs with Enable. The output
Synchronous Counters Slide 82 Two examples of synchronous (unlike series ripple counter) counter are shown in Figures 8-25 and 8-26 below. Slide 84
toggles when the master enable CNTEN is asserted. Since the master enable still needs to propagate through FFs, it remains slow and it is called synchronous serial counter.
Q0
EN T
Q1
Slide 85
EN T
Q2
Slide 87
It is a 4-bit up counter, with clear (CLR) and load (LD) inputs, two enable inputs (ENP,ENT), and ripper carry-output (RCO).
EN T
Q3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
All FF share the same CLK and Enable. There are no delay. It is the fastest binary counter.
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
x 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
x x 0 x 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
x x x 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
x x x x 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
x x x x 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
x x x x 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
x x x x 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0
D QD QD
0
C QC QC
0
B QB QB
0
A QA QA
0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0
0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0
0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
Slide 86
10 3 4
Slide 88
QB 12 QC QD RCO
11 15
A B 5 C
6
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
MSI Counter Chip (contd) Slide 89 The output is 0 if CLR is asserted. The output is A,B,C,D if LD is asserted. If either ENP os ENT is asserted, the output stays the same as the last state. RCO is asserted if all four outputs are 1. Slide 91 values A,B,C,and D (they are 1100) are loaded into the output.
Module-11 Counter 74x163 can be used to build dierent counters (see Fig. 8-29). The following is an module-11 decimal counter (i.e., count up to 11 and wrap around) built with 74x163
74x163 CLOCK
1 2
CLK
Slide 90
+5 V R RPU
A B 5 C 6 D
Q0 Q1 Q2 Q3 74x00
3
Design a state machine with two inputs X and Y, and output Z. The output is 1 if the number of 1 inputs on X and Y since reset is a multiple of 4. See section 7.4.6 for details.
S11XX_L
U2
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
State Design: Another Example Design a controller for T-bird tail lights.
Slide 93
CALIFORNIA
Slide 95
on when the Left (Right) input is on and six lights all ash when the HAZ is on. Assume the clock frequency matches the light ash rate.
ZOTTFFS
LC
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
LB
LA
RA
RB
RC
Problem statement: three lights on each side, and for turn, they operate in sequence to show the turning direction
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
(a)
LC
LB
LA
(b)
RA
RB
RC
Slide 94
Slide 96
output: six lights: 3 for left (LA, LB, LC) and 3 for right (RA, RB, RC) States: IDLE, L1, L2, L3, R1, R2, R3, LR3 see progressive improvement in state diagrams from Fig. 7.56, 7.57, and 7.58.
It has three inputs: Left, Right, and Haz. The left (right) lights are
L2 HAZ HAZ
HAZ
S
IDLE IDLE
Q2
Q1
Q0
Transition Expression
(LEFT + RIGHT + HAZ) LEFT HAZ RIGHT HAZ + LEFT RIGHT RIGHT HAZ LEFT HAZ HAZ HAZ HAZ
S
IDLE L1 LR3 R1 L2 LR3 L3 LR3 IDLE R2 LR3 R3 LR3 IDLE IDLE
Q2
Q1
Q0
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
0 0 0 0 0 0 1 1 1 0 0 1 1 1 0
0 0 0 0 1 1 1 1 0 1 1 1 1 0 0
0 0 1 1 0 1 0 1 0 1 1 1 1 0 0
0 0 0 0 1 0 1 0 0 1 0 1 0 0 0
0 1 0 1 1 0 0 0 0 1 0 0 0 0 0
L1
IDLE IDLE
HAZ
L1
L1 L2
Slide 97
1 R3
Slide 99
L2 L3 R1 R1
1
HAZ HAZ HAZ HAZ
R2 R2 R3
1 1
HAZ
HAZ
HAZ
LR3
R2
Transition List From the constructed state diagram, we can build a transition list table as shown in Table 7-14. Transition equations can be directly derived from the transition list. The transition equation for a next state is the sum of transition expression for which the next state variable has a value of 1. Transition equation can then be simplied algebraically or using K-map. Excitation equations can be derived from transition equations.
Slide 98
1D
(2) (3)
1Q 1Q_L (a)
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
2D
(7) (6)
CLK CLR 1Q 1Q 2Q 2Q 3Q 3Q 4Q 4Q
2 3 7 6 10 11 15 14
Chapter 8 Sequential Logic Design Practices Slide 1 Registers (section 8.2.5) Shift Registers (section 8.5.1-8.5.2) Counters (section 8.4) Slide 3
3D
(10) (11)
3Q 3Q_L
4
1D 2D 3D 4D
12
4D CLK CLR_L
(15) (14)
4Q 4Q_L
13
The data inputs (1D-4D) are transferred to the D FFs (transferring to Q1-Q4) at each clock tick. It includes a synchronous clear input, which clears the FFs (i.e., set the Qs to zero) if asserted. 74x374 is a 8-bit register. See Figure 8-10.
Shift Registers Registers Slide 2 A register is a storage device, consisting of a collection of D FFs with a common clock input. Each D FF can store 1 bit of data. 74x175 is a 4-bit register. Slide 4 A shift register shifts its stored data by one bit position at each clock tick. There are four types of shift registers: serial-in, serial out; serial-in, parallel-out; parallel-in, serial-out, and and parallel-in, parallel-out. Go to Wikipedia at http://en.wikipedia.org/wiki/Shift register for a demo of each register.
Serial-in Serial-Out Shift Registers Slide 5 The input data SERIN is applied sequentially to the D input of the rst FF. During each clock pulse, one bit is transmitted from current FF to next FF. The output is read one bit at a time from the last FF. Slide 7
Serial-in Parallel-Out Shift Registers The input data SERIN is applied sequentially to the D input of the rst FF. During each clock pulse, one bit is transmitted from current FF to next FF. The output is read simultaneously from all FFs.
SERIN
SERIN CLOCK
D CK Q
D CK
1Q
CLOCK
D
D CK Q
Q CK
2Q
Slide 6
Slide 8
D CK
SEROUT
D CK
NQ
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Parallel-in Serial-Out Shift Registers At each clock tick, depending on the control input LOAD/SHIFT, it could load new data (1D-ND) to the FFs or shift the existing content of the FFs right one bit at a time. The output is read one bit at a time from the last FF.
CLOCK LOAD/SHIFT SERIN
D Q CK
1Q
1D
Q CK
2Q
2D
Slide 9
1D
Slide 11
D Q CK
NQ
Q CK
2D
ND
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Q CK
SEROUT
ND
This is the most general shift register and can replace other types of registers.
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
MSI Shift Registers 74x164 8-bit serial-in, parallel-out shift register, consisting two serial inputs (SERA and SERB). Internally, they are ANDed. Both must be 1 for 1 to be shifted into the register. it also includes an synchronous clear input. 74x166 8-bit parallel-in, serial-out shift register. The device shifts when SH/LD is 1. Otherwise, it loads new data from its input (A-H) into the register. it also includes an synchronous clear input. 74x194 parallel-in, parallel-out shift register, its output depend on the two control inputs S1 and S0. Note these MSI parts are seldom used nowadays, because any desired, customized shift-register function can be provided in a PLD or FPGA.
Parallel-in Parallel-Out Shift Registers At each clock tick, depending on the control input LOAD/SHIFT, it could loads new data (1D-ND) to the FFs or shift the existing content of the FFs right one bit at a time. The output is read simultaneously from all FFs. Parallel-in Parallel-Out Shift registers are called universal shift registers.
Slide 10
Slide 12
Slide 13
Slide 14
Table 8-18 Function table for the 74x194 4-bit universal shift register.
Inputs Function S1 S0 QA
Next state QB QC QD
0 0 1 1
0 1 0 1
QA RIN QB A
QB QA QC B
QC QB QD C
QD QC LIN D
Chapter 9 Memory Slide 1 Read-Only Memory (section 9.1-9.1.1) Static RAM (section 9.3-9.3.2, 9.3.4) Slide 3
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
The data is hard-wired in the ROM. ROM memory is usually non-volatile, i.e., its content does not disappear when power is o.
Inputs A2 A1 A0 D3
Outputs D2 D1 D0
Read Only Memory (ROM) Slide 2 A ROM is a combinational circuit with n address inputs and b data outputs. It stores a truth table of the size 2n x b, where n is the number of input and b is the number of output. Slide 4
0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1
1 1 1 0 0 0 0 1
1 1 0 1 0 0 1 0
1 0 1 1 0 1 0 0
0 1 1 1 1 0 0 0
Static Random Access Memory (RAM) Slide 5 A static RAM is a sequential circuit with n address inputs and b data outputs. A RAM also has b data inputs and a set of control inputs. One of the control input is Write-Enable (WE). When WE is asserted, the data inputs are written into the memory. Slide 7
READthe data stored in the location specied by address input are transfered to the output. For this to happen, the eanbles CS and OE (output enable) need be asserted. WRITE-the data in the data input (DIN0-DINb-1) are written to the memory location specied by the address inputs. For this to happen, CS and WE need be enabled.
HM628512 (512k x 8)
DOUT0 DOUT1 data outputs
Slide 6
Slide 8
control inputs
DINb1 CS OE WE
DOUTb1
Copyright 2000 by Prentice Hall, Inc. Digital Design Principles and Practices, 3/e
Advanced Topics
Register
Buses
A shared collection of wires for exchanging data, with some defined rules
Data Lines (two-way) N M Address Lines (one-way)
Fundamentals in Computer
Data In (N bits) N N Register Load Output Enable (we have Tri-state outputs) Data Out (N bits)
Only one of these OEs can be true at once Rule 1: Only one device can write to a bus at any time Rule 2: Multiple devices can read the bus at any time Rule 3: There is usually a bus protocol that is followed strictly by all devices sharing the bus
OE1
OE2
OE3
Register 1
Register 2
Register 3
LOAD2
LOAD3
M A R
Data Out
Read/Write Wait
Operation
ALU N
Keep in mind: The ALU is a combinational circuit. Flags Result (carry out, overflow, etc.)
OE1
OE2
OE3
Register 1
Register 2
Register 3
Slow RAMs usually ask Processor to wait LOAD1 LOAD2 LOAD3 Only one can write to the data line, but more than one 3 4 registers can receive inputs at the same time 7
M B R
Address Bus
Result Bus
M A R
P C
I R
A C
Register transfer operations: PC BUS IR BUS AC BUS MBR BUS ALU Result BUS BUS PC BUS IR BUS AC BUS MBR BUS ALU B BUS MAR They all share one bus. AC ALU A (hardwired)
M B R
Memory Bus
Note: This is not the only way to build a computer, but is the most common one.
9
Single bus replaced by three busses: Note, the BUS is treated just like a register 13
14
Structure of a Computer
Address
Add Memory
RBUS
Add Control
BUS
AC
Memory Data Bus
Memory System
Control
Data Inputs
Datapath
In its simplest form, a computer consists of a processor (CPU) and a memory system.
RBUS MBUS
MBUS
AC
ALU
ALU
S
MAR ABUS IR PC
The Datapath Unit, also called the execution unit, consisting of Registers for temporary data storage and functional unit to perform operation on the data. Main parts: Registers, Shifter, ALU, Buses. The Control Unit, also called the instruction unit. It provides instruction as to what operation to perform Main parts: Finite-State Machine update PC (since inputs
11
The BUS is like a highway for transferring data from one point to any other point Program Counter (Holds address of NEXT instruction)
MBUS
Every bit of the Instruction Register (IR), every other registers OE and LOAD signals, every control input and flag output of the ALU, and every memory control signal is either an input or an output of the control unit. (Shown in red) Accumulator Involved in most instructions Instruction Register (Holds the fetched instruction) Note that this one has two outputs 12
FSM
ALU
Memory Address
MAR
Opcode
ABUS
IR
PC
MBUS
We simplified our datapath further by assuming that MBR is inside the memory system itself and MBUS has two branches. Every device in this diagram has control signals that must be operated. 15
Reality Note #1:The control unit FSM is huge compared to the FSM examples that weve seen thus far!!
Reality Note #2: The diagram above is extremely simplified compared to a real processor
16
Micro-Operations
Instruction Fetch
Instruction fetch: PC ABUS; ABUS MAR; 1 Read/Write*; MBR MBUS; MBUS IR; Instruction Decode: IF IR<OpCode> = LOAD_FROM_MEMORY THEN Operand fetch: IR-> ABUS ABUS->MAR 1 Read/Write*; Instruction Execution: MBR MBUS; MBUS ALU B; ALU PASS B; ALU Result RBUS; RBUS AC; 18 Housekeeping: PC+1 PC; 21
Micro-operations
1. Instruction Fetch: Move PC to MAR Initiate a memory read sequence Move data from memory to IR
Memory N bits wide 2M words
Opcode
IR
2. Instruction Decode: Opcode bits of IR are input to control FSM Rest of IR bits encode the operand address (see Fig 11.4) OPCODE 3. Operand Fetch: Move operand address from IR to MAR Initiate a memory read sequence Instruction Format Instruction Format 17 OPERAND SPECIFIER OPCODE 5. Housekeeping: Update PC to point at next instruction OPERAND SPECIFIER
4. Instruction Execute: Data available on load path Move data to ALU input Configure ALU to perform ADD operation Move result S to AC
22
Example Task
Read the output of the 4-bit data source every time the push button is pressed, and display the result.
Instruction Decode: IF IR<op code> = ADD_FROM_MEMORY THEN Operand fetch: IR<addr> MAR; Memory Read; Instruction Execution: Memory ALU B; AC ALU A; ALU ADD; ALU S AC; Assert Control Signal Housekeeping: PC+1 PC; Repeat the five steps ! -- move operand addr to MAR -- assert Memory READ signal -- gate Memory to ALU B -- gate AC to ALU A -- instruct ALU to perform ADD -- gate ALU result to AC -- increment PC
Interrupts, Resets
Display
Push Button
20
23
24
One Method...
4-bit Data Source Computer (HC11 chip) Display
Is Polling Bad?
Eats up a lot of CPU cycles doing nothing! Were repeatedly checking the button Each time the button is pressed, we delay by 1 ms by going around in a loop, wasting time This is also called busy wait We could do better if only we could somehow grab the CPUs attention momentarily whenever the button is pressed! We could do even better if the 1 ms delay could be achieved without a delay loop!
25 26
Interrupt Method
Suppose that the computer is doing something... useful or otherwise....
START
Interrupt Method
START
Push Button
NO
START
INITIALIZE
Key Pressed
READ THE 4-BIT INPUT UPDATE THE DISPLAY DO SOMETHING USEFUL Key Pressed
4-bit Data Source
This style of computer input/output is called Polled I/O because were constantly polling the pushbutton
BUTTON PRESSED? YES READ 4-BIT INPUT UPDATE DISPLAY NO
Display
DO SOMETHING USEFUL
Push Button
30
Introducing Interrupts
A mechanism to interrupt the CPU, i.e., steal it for a little while to service the interrupting device (a button in our example)
An interrupt is an unusual event that requires the CPU to stop normal program and perform some service related to the unusual event. It can be external or internal. External interrupts can be generated by asserting an interrupt signal to CPU. Internal interrupts can be hardware components in CPU such as timer, I/O interface function. Interrupts can also be caused by software errors (overflow, abnormal operations, ..) 27
Interrupt Sources
Hardware Sources External Pushbuttons Internal Timers I/O interface Serial Communication Systems ...
28
31
32
Interrupt priority: - The order in which the CPU will service interrupts when all of them occur (pending) at the same time.
Interrupt Maskability: - Interrupts that can be ignored by the CPU are called maskable interrupts. A maskable interrupt must be enabled before it can interrupt the CPU. Masking can change priority. An interrupt is enabled by setting an enable flag. Interrupts that cant be ignored by the CPU are called non-maskable interrupts.
Managing Interrupts
The 68HC11 timer produces an interrupt once every 216 CPU cycles.
At 9600 bits/sec, the RS-232 port on your PC produces an interrupt about once every 2000 CPU cycles.
For example, sources requiring a more timely response get higher priority.
Interrupt Priority
VHDL was designed with structured programming in mind Borrowed concepts from Pascal and ADA Slide 3 Actually VHDL is almost object-oriented Has separate interface and implementation parts! But, doesnt have classes with which to instantiate new objects with. Needs an update!
33
Functions of Interrupts: - Coordinating I/O activities and preventing CPU from being tied up - Providing a graceful way to exit from errors - Reminding the CPU to perform routine tasks
34
A special event that requires the CPU to stop normal program execution and perform some service related to the event. E.g.: I/O completion, timer time-out, illegal opcodes, arithmetic overflow, divide-by-0 etc.
What is an interrupt?
Interrupts: Recap
Slide 1
VHDL: Features
Designs can be decomposed hierarchically Each design element has: A well-dened interface for connecting with other elements Slide 2 Precise functional description (for simulation) Functional description may be Behavioral algorithm (direct functional description) Hardware structural description (such as in term of gates and their interconnections) Slide 4
Slide 5
architecture definition
Slide 7
Keywords-entity, is, port, begin, end, etc.. Note they are case insensitive. Entity name and signal name-a string of characters (containing no spaces and hyphens). The key words cannot be used as variable names.
Slide 6
Slide 8
The name of all VHDL programs should end with an extension .vhd such as mydesign.vhd .
Often, we use std logic and std logic vector for bit and bit vector if the IEEE standard library (IEEE.std logic 1164.all) is used
architecture architecture-name of entity-name is type declarations signal declarations constant declarations function definitions procedure definitions component declarations begin concurrent-statement ... concurrent-statement end architecture-name;
Slide 10
Slide 12
Note:
1)use two hyphens to indicate the start of comments. Slide 13 2)reserved words such as entity, port, is, in, out, bit are not case sensitive. Slide 15 2)<= can also be used as the assignment operator.
VHDL operators
Table 4-30 Predefined operators for VHDL's integer and boolean types.
Operators integer Operators boolean
Slide 14
addition subtraction multiplication division modulo division modulo remainder absolute value exponentiation
complementation
In addition, there are also relational operators: =, / =, <, <=, >, and >=. Note: 1) results of Boolean and Relational operations are all Boolean data type.
VHDL IF statement
if boolean-expression then sequential-statement end if; if boolean-expression then sequential-statement else sequential-statement end if;
WITH Statement
Table 4-57 Syntax of a VHDL if statement.
Table 4-52 Syntax of VHDL selected signalassignment statement.
with expression select signal-name <= signal-value when choices, signal-value when choices, ... signal-value when choices;
Slide 17
if boolean-expression then sequential-statement elsif boolean-expression then sequential-statement ... elsif boolean-expression then sequential-statement end if; if boolean-expression then sequential-statement elsif boolean-expression then sequential-statement ... elsif boolean-expression then sequential-statement else sequential-statement end if;
Slide 19
An example
Table 4-53 Prime-number detector architecture using selected signal assignment.
architecture prime4_arch of prime is begin with N select F <= '1' when "0001", '1' when "0010", '1' when "0011" | "0101" | "0111", '1' when "1011" | "1101", '0' when others; end prime4_arch;
CASE Statement
Syntax: CASE expression IS An example
Table 4-58 architecture prime7_arch of prime is Prime-numberbegin detector architecture process(N) using an if statement. variable NI: INTEGER; begin NI := CONV_INTEGER(N); if NI=1 or NI=2 then F <= '1'; elsif NI=3 or NI=5 or NI=7 or NI=11 or NI=13 then F <= '1'; else F <= '0'; end if; end process; end prime7_arch;
WHEN choices => statements; WHEN choices => statements; WHEN OTHERS => statements; Slide 20 END CASE; Example: CASE state IS WHEN S1 => Z <= 1; WHEN S2 => Z <= 2; WHEN OTHERS => Z <= 0; END CASE;
Slide 18
VHDL Loop
for identifier in range loop sequential-statement ... sequential-statement end loop;
Slide 21
An example
Slide 22
Note: always include ieee.std logic 1164.all in the beginning of a VHDL program.
Slide 24
architecture V74x138_a of V74x138 is signal Y_L_i: STD_LOGIC_VECTOR (0 to 7); begin with A select Y_L_i <= "01111111" when "000", "10111111" when "001", "11011111" when "010", "11101111" when "011", "11110111" when "100", "11111011" when "101", "11111101" when "110", "11111110" when "111", "11111111" when others; Y_L <= Y_L_i when (G1 and not G2A_L and not G2B_L)='1' else "11111111"; end V74x138_a;
Multiplexers in VHDL
Ta bl e 5 - 4 2 Dataflow VHDL program for a 4-input, 8-bit multiplexer.
library IEEE; use IEEE.std_logic_1164.all; entity mux4in8b is port ( S: in STD_LOGIC_VECTOR (1 downto 0); -- Select inputs, 0-3 ==> A-D A, B, C, D: in STD_LOGIC_VECTOR (1 to 8); -- Data bus input Y: out STD_LOGIC_VECTOR (1 to 8) -- Data bus output Slide ); end mux4in8b; architecture mux4in8b of mux4in8b is begin with S select Y <= A when "00", B when "01", C when "10", D when "11", (others => 'U') when others; -- this creates an 8-bit vector of 'U' end mux4in8b;
SUBTYPE Statement
Syntax: SUBTYPE subtype-name IS type-name (start to end); CONSTANT constant-name: subtype-name : = value Example: SUBTYPE state IS STD LOGIC VECTOR (1 to 3); 27 CONSTANT S0: state :=000; CONSTANT S1: state :=001; CONSTANT S2: state :=011; CONSTANT S3: state :=010; CONSTANT S4: state :=110; These statements can be used to relate the statess mnemonic names to their binary assignment.
Slide 25
VHDL Functions
Like functions for high level programming language (e.g. C++), a VHDL function has its input arguments and returns a result of certain type. Syntax for VHDL functions
architecture Inhibit_archf of Inhibit is
Slide 26
Slide 28
-- 8-bit vector of 'U'
function ButNot (A, B: bit) return bit is begin if B = '0' then return A; else return '0'; end if; end ButNot; begin Z <= ButNot(X,Y); end Inhibit_archf;
PROCESS Statement
Syntax: process is a collection of statements dened in an enclosing architecture. A process statement is introduced by the keyword process. Statements in a process are executed sequentially instead of concurrently. Multiple processes can be dened in an architecture and they are processed simultaneously. PROCESS (signal-name, signal-name, signal-name) Slide 29 type declarations; variable declarations; constant declarations; BEGIN statements; statements; ... END PROCESS; Slide 31
library IEEE; use IEEE.std_logic_1164.all; entity Vsrlatch is port (S, R: in STD_LOGIC; Q, QN: buffer STD_LOGIC ); end Vsrlatch; architecture Vsrlatch_arch of Vsrlatch is begin QN <= S nor Q; Q <= R nor QN; end Vsrlatch_arch;
Slide 30
Slide 32
END CASE; END IF; Slide 35 END PROCESS; END vending arch;
Slide 33
architecture VposDff_arch of VposDff is begin process (CLK, CLR) begin if CLR=?1? then Q <= ?0?; QN <= ?1?; elsif CLK?event and CLK=?1? then Q <= D; QN <= not D; end if; end process; end VposDff_arch;
Slide 37
Slide 38
Exam Rules:
This is a 3 hours exam. It includes all materials covered during this semester. This is an Open Book and Notes exam. You are not allowed to consult with other students. You may not use a calculator, laptop, palmtop, PDA, or such computer. If you need more space, continue on the back sides of pages, but make sure to indicate the continuation.
1. Mark each of the following statement TRUE or FALSE 10 points, 1 point each a The largest number a BCD can represent is 9. b Over ow applies only to arithmetic operations on signed numbers. c The canonical sum and canonical product representation of a digital circuit are logically the same. d The state of a Moore machine will change only at the rising edge of the clock signal. e The number of outputs a gate can have is arbitrary. f For a NOR gate in positive logic, it would become a NAND gate if the negative logic were applied instead. g The 7-bit binary representation for 8 as a unsigned number, signed number, or a ASCII character are all the same. h The data bus is bidirectional. i The control unit in a computer controls the operations of every register, the ALU, and the memory. j MBR and MAR use di erent types of bus.
1 2 3 4 5 6 7 8 9 10 Total 10 points 10 points 10 points 10 points 10 points 10 points 10 points 10 points 10 points 10 points
2. Complete the following table by lling in all the blanks 10 points use 6-bit binary representations if there are multiple answers for a particular blank, then give all of them if there are no answers for a blank, then mark it with X" in that space
4. Do the following Draw the gate-level implementation of a 2:1 multiplexer. Clearly label all control, input, and output signals 5 points
Show how you can construct a 4:1 mux using 2:1 multiplexers only. Clearly label all control, input, and output signals. Clearly show all the connections between multiplexers. Using the 2:1 mux logic symbol below 5 points. 3. Perform the following calculation using 2's complement and indicate if an over ow occurs. First convert the decimal number to 6-bit long 2's complement numbers and then do the addition. Show the result of the conversion and addition. z = -20 + -13 10 pts
5. Give the state diagram for the logic diagram below, where FA=full adder. Identify the inputs, outputs, and states explicitly 10 points.
6. A combinational logic circuit accepts a 4-bit unsigned number A3A2A1A0 and generates a binary output Pn Pn 1 P2P1P0 equal to the eight times the input. Find the simpli ed sum of products for P3 and P2 only 10 points
7. An AB-type" ip- op has two inputs A and B. If A=1, then Q*=B if A=0, then Q*=B' 10 points . Using a D ip- op, design an AB ip- op. Show how you derived the schematic and draw the schematic.
8. Given the following timing chart for a negatively edge-triggered sequential network, where X1 and X2 are inputs, Q1 and Q2 are state variables, and Z1 and Z2 represent two outputs. Is this a Moore or Mealy or Moore machine and why ? Construct as much of the state diagram as possible 10 points.
Using an AB ip- op, design a T ip- op. Explain how you derived the schematic.
9. Design a sequence detector with one input X and one output Z. Every time the input sequence "101" is detected the output Z=1. However, the output detector needs to be rst activated with a key, i.e. it has to receive at least three consecutive 0's before it will start detecting the desired sequence "101". Once the key has been received, the sequence detector keeps looking for the desired sequence. Identify the possible states and give the state diagram 10 points .
10. Do the following 10 points Complete the state diagram below for a Mealy machine that implements a full adder. The state machine has two inputs X and Y, representing the two addends respectively, an output S representing the sum, and a state variable C representing the carry 5 points
Based on the above state diagram, complete the following VHDL implementation of the full adder Mealy machine by replacing the questions marks with the correct entries 5 points.
10
1. Do the following Complete the following table by lling in all of the blanks [5 points] Use 6-bit binary representation If there is no answer for a particular blank, then write an x in the space.
decimal
unsigned binary
signed 2s complement
Exam Rules:
This is an Open Book and Notes exam. You are not allowed to consult with other students. You may not use a calculator, laptop, palmtop, PDA, or such computer. If you need more space, continue on the back sides of pages, but make sure to indicate the continuation.
Perform the following [10 points] (a) Given A=10101 B=11001 A and B are positive numbers. Represent A and B in 8-bit 2s complement. Let C=-B, perform the operations A+B, and A+C, where all the numbers are in 2s complement representation. Give your answers in decimal. Does overow occur in each case ?
2. Given the logic expression below, do the following (15 points). F= (ab+ (a + (bc))) + (a + (b +ac)) Use Boolean theorems to minimize F (5 pts).
X,Y,Z,W (1, 3, 4, 6, 9)
Implement the function F using a 74 138 decoder and label the decoder pins appropriately [5 pts]
74 x 138
G1 G2A G2B y0 y1 y2 y3
A B C
y4 y5 y6 y7
4. The following logic circuit consists of a 2-4 decoder and a 4-1 multiplexer. Its inputs are X, Y, S0, and S1 (where S1 is MSB and and S0 is LSB), and its output is F (15 points).
D0 4-1 2-4 Y X decoder D1 mux D2 D3
5. Consider a 2-bit binary subtracter dened as follows. The inputs A, B and C, D form the two 2-bit numbers N1 and N2 . The circuit will compute the dierence N1 N2 on the output bits F (most signicant) and G(least signicant). Assume the circuit never sees an input combination in which N1 is less than N2 , The output bits are dont care in these cases (15 points). (a) Fill in the 4-variable truth table for F and G (5 pts).
A B C D F G
S1
S0
(b) Derive the minimum SOP for F and G using K-map (5 pts).
F AB CD CD G AB
Find the minimal sum of products expression for the diagram using K-map (8 pts).
XY S1S0
(c) Implement the sum of products expression from (b) using two 8:1 mux for both F and G. Draw the schematics and clearly label the inputs and outputs of each pin of the mux (5 pts).
8:1 MUX En 8:1 MUX En
I0 I1 I2 I3 I4 I5 I6 I7 s2 s1 s0 Y
I0 I1 I2 I3 I4 I5 I6 I7 s2 s1 s0 Y