Академический Документы
Профессиональный Документы
Культура Документы
Introduction
Chpts 2 & 3: Introduced increasingly complex digital building blocks
Gates, multiplexors, decoders, basic registers, and controllers
4.1
Appropriate building blocks: Tires, seat, pedals Not: Rubber, glue, metal 2
Registers
N-bit register: Stores N bits, N is the width
Common widths: 8, 16, 32 Storing data into register: Loading Opposite of storing: Reading (does not alter contents)
b
4.2
x Combinational n1 logic n0 s1 s0
State register
load
clk
I3
I2
I1
I0
4-bit register
D Q
D Q
D Q
D Q
I3 I2 I1 I0 reg(4)
Q3 Q2 Q1 Q0
Q3 Q2 Q1 Q0
Basic register loads on every clock cycle How extend to only load on certain cycles?
Digital Design 2e Copyright 2010 Frank Vahid
block symbol
load=0
load=1
I3 10 D Q Q3
I2 10 D Q Q2
I1 10 D Q Q1
I0 10 D Q Q0
I3 10 D Q Q3
I2 10 D Q Q2
I1 10 D Q Q1
I0 10 D Q Q0
0010 1
Save 3 pounds 2 Present weight b clk
load
I3 I2 I1 I0 Q3 Q2 Q1 Q0
0011
Buses
N-bit bus: N wires to carry N-bit data item
Circuit drawings can become cluttered
Scale Weight Sampler
b clk
load
I3 I2 I1 I0 Q3 Q2 Q1 Q0
Saved weight
ld
8
a Digital Design 2e Copyright 2010 Frank Vahid
0001010
C 8 d0 2x4
Ch2 ex: Four simultaneous values from cars computer To reduce wires: Computer writes only 1 value at a time, loads into one of four registers
Was: 8+8+8+8 = 32 wires Now: 8 +2+1 = 11 wires
load
a0
0
1
d1 i0
0001010
A
8
8-bit 41
i1
d2 load reg2 I i2 8 d 8 D
a1
i1
d3
load reg3
M
8 i3 s1 s0 x y 7
0
0 0 1 0 R7 R6 R5 R4 R3 R2 R1 R0 Q I R0 10100010
load
d7
8 D e
d6
d5
d4 d3 i2 i1 i0
d2 d1 d0 3x8 decoder
from microprocessor
microprocessor
(a)
R7
R6
R5
R4
R3
R2
R1
R0
D i2,i1,i0 e clk
Shift Register
Shift right
Move each bit one position right Rightmost bit is dropped Assume 0 shifted into leftmost bit
1 1 0 1 0 0 1 1 0 Register contents before shift right
a
10
Shift Register
To allow register to either shift or retain, use 2x1 muxes
shr: 0 means retain, 1 shift shr_in: value to shift in
May be 0, or 1
shr_in shr 1 0 2x1 D Q Q3 1 0 shr=1
1 0
1 0
1 0
1 0 D Q Q2 (b)
1 0 D Q Q1
1 0 D Q Q0
2x1
D Q
D Q Q2 (a )
D Q Q1
D Q Q0
Q3
shr_in shr Q3 Q2 (c ) Q1 Q0
11
Rotate Register
1 1 0 1
Rotate right: Like shift right, but leftmost bit comes from rightmost bit
Register contents before shift right Register contents after shift right
1 1 1 0
12
Earlier example: 8+2+1 = 11wires from cars computer to above-mirror displays four registers
Better than 32 wires, but 11 still a lot want fewer for smaller wire bundles
8 d0 2 4
a0 d1 load
load
reg0
i0 8 reg1 A
8 8-bit 4 1
i0 i1 d2 load
reg2
i1 I i2
8
a1
e load
d3
load
reg3
M 8 i3 s1 s0 x y
Note: this line is 1 wire, rather than 8 like before x y c shr_in shr reg0 d0 T s1 s0 i0 2x4 8 shr_in 41 shr reg1 d1 A a0 i0 i1 8 i1 a1 shr_in d shr reg2 d2 8 I i2 e d3
8 M i3 8
shift
13
Multifunction Registers
Many registers have multiple functions
Load, shift, clear (load all 0s) And retain present value, of course
Functions:
s1 0 0 1 1 s0 0 1 0 1 Operation Maintain present value Parallel load Shift right (unused - let's load 0s)
I2 0 3210
I1 0 3210
I0 0 3210 shr_in s1 s0 I3 I2 I1 I0
D Q Q2 (a)
D Q Q1
D Q Q0
Q3 Q2 Q1 Q0 (b)
14
Multifunction Registers
s1 0 0 1 1 s0 0 1 0 1 Operation Maintain present value Parallel load Shift right Shift left
I3 shr_in
I2
I1
I0 shl_in
3210
3210
3210
3210
shl_in shr_in s1 s0
I3
I2
I1
I0
D Q Q3
Digital Design 2e Copyright 2010 Frank Vahid
D Q Q2
D Q Q1
D Q Q0
Q3 Q2 Q1 Q0
(a)
(b)
15
I3 shr_in s1 s0 I3
I2 I2
I1 I1
I0 I0 shl_in
shl_in Q3 Q2 Q1 Q0 Q3 Q2 Q1 Q0
16
Put highest priority control input on left to make reduced table simple
Inputs shr shl ld 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 Outputs s1 s0 0 1 1 1 0 0 0 0 0 1 0 0 1 1 1 1 Not e Operation Maintain value Shift left Shift right Shift right Parallel load Parallel load Parallel load Parallel load
ld
0 0 0 1
shr
0 0 1 X
shl
0 1 X X
Operation
Maintain value Shi ft left Shift right Parallel load
17
18
5 operations: above, plus maintain present value (dont forget this one!) Use 8x1 mux
1 0
s2 s1 s0
In from Qn-1
7 6 5 4 3 2 1 0
D
Q Qn
clr 0
0 0
Inputs set ld 0 0
0 0 0 1
shl 0
1 X
Outputs s2 s1 s0 0 0 0
0 0 1 0 0 1
0 1
a
1 X
X X
X X
1 0
0 1
0 1
19
shl_in Q3 Q2 Q1 Q0 Q3 Q2 Q1 Q0
clr 0
0 0
Inputs set ld 0 0
0 0 0 1
shl 0
1 X
Outputs s2 s1 s0 0 0 0
0 0 1 0 0 1
0 1
1 X
X X
X X
1 0
0 1
0 1
20
Adders
Adds two N-bit binary numbers
2-bit adder: adds two 2-bit numbers, outputs 3-bit result e.g., 01 + 11 = 100 (1 + 3 = 4)
a1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Inputs a0 b1 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 b0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 c 0 0 0 0 0 0 0 1 0 0 1 1 0 1 1 1
4.3
Can design using combinational design process of Ch 2, but doesnt work well for typical N
Why not?
Outputs s1 s0 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0
21
4.3
Inputs a0 b1
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
b0
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
c
0 0 0 0 0 0 0 1 0 0 1 1 0 1 1 1
Outputs s1 s0
0 0 1 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0
8-bit adder: 2(8+8) = 65,536 rows 16-bit adder: 2(16+16) = ~4 billion rows 32-bit adder: ...
10000 8000
A: 1000 transistors for N=5, doubles for each increase of N. So transistors = 1000*2(N-5). Thus, for N=16, transistors = 1000*2(16-5) = 1000*2048 = 2,048,000. Way too many!
Digital Design 2e Copyright 2010 Frank Vahid a
Size comes from implementing with two levels of gates. Following approach uses more levels to achieve smaller size.
22
A: B: +
1 1 1 1 0 1 1 0
0 1
1 0 1
1 0 1 0 1
23
A: B:
1 1 1 1 + 0 1 1 0
1 0 1 0 1 1 1 0
A: 1
1 0 b a ci 1 b a ci co s 0 1
1 1 b a ci co s 0
1 0 b a co s 1 SUM
B:
co s 1
Full-adders
Half-adder
24
Half-Adder
Half-adder: Adds 2 bits, generates sum and carry Design using combinational design process from Ch 2
1 1 1 1 b a ci co s 1 0 1 1 b a ci co s 0 1 0 b a co s 1 SUM
A: 1
B: 0 b a ci co s
Inputs a b 0 0 0 1 1 0 1 1
Outputs co s 0 0 0 1 0 1 1 0
b a b
Half-adder (HA)
co s
co (a)
s (b)
25
Full-Adder
Full-adder: Adds 3 bits, generates sum and carry Design using combinational design process from Ch 2
1 1 1 1 b a ci co s 1 0 1 1 b a ci co s 0 1 0 b a co s 1 SUM
A: 1
B: 0 b a ci co s
Step 1: Capture the function Step 2A: Create equations Inputs Outputs
a 0 0 0 0 1 1 1 1 b 0 0 1 1 0 0 1 1 ci 0 1 0 1 0 1 0 1 co 0 0 0 1 0 1 1 1 s 0 1 1 0 1 0 0 1
co = abc + abc + abc + abc co = abc +abc +abc +abc +abc +abc co = (a+a)bc + (b+b)ac + (c+c)ab co = bc + ac + ab
s = abc + abc + abc + abc s = a(bc + bc) + a(bc + bc) s = a(b xor c) + a(b xor c) s = a xor b xor c
26
Carry-Ripple Adder
Using half-adder and full-adders, we can build adder that adds like we would by hand Called a carry-ripple adder
4-bit adder shown: Adds two 4-bit numbers, generates 5-bit output
5-bit output can be considered 4-bit sum plus 1-bit carry out
a b ci F A co s
a b ci F A co s
a b ci F A co s
a b HA co s
a3 a2 a1 a0
b3 b2 b1 b0
4-bit adder co s3 s2 s1 s0
co
s3
s2 (a)
s1
s0 (b)
27
Carry-Ripple Adder
Using full-adder instead of half-adder for first bit, we can include a carry in bit in the addition
Useful later when we connect smaller adders to form bigger adders
a3 b3 a2 b2 a1 b1 a0 b0 ci
a b ci F A co s
a b ci F A co s
a b ci F A co s
a b ci F A co s
a3 a2 a1 a0
b3 b2 b1 b0 ci
4-bit adder co s3 s2 s1 s0
co
s3
s2 (a)
s1
s0 (b)
28
a b ci F A s 0 1 1
000 a b ci F A co s
0111+0001
(answer should be 01000)
a b ci F A co s 0 1 co0
0
Digital Design 2e Copyright 2010 Frank Vahid
Wrong answeris there a problem? Nojust need more time for carry to ripple through the chain of full adders.
29
0111+0001
(answer should be 01000)
a b ci F A co 1 s 0
(b) 000
a b ci F A co s
101 0
a b ci F A co s 1 co2 0 10 1
101
a b ci F A co 1 (c) s 0 101
1 1
a b ci F A co 1 s
a
0 1 1 0
0 00 1
a b ci F A
co s
a b ci F A
co 1 s 0
a b ci F A
co 1 (d) s 0
a b ci F A
co 1 s 0 Output after 8ns (4 FA delays)
0
Digital Design 2e Copyright 2010 Frank Vahid
30
Cascading Adders
a7 a6 a5 a4 a3 a2 a1 a0
b7 b6 b5 b4 b3 b2 b1 b0 ci
a3 a2 a1 a0 a3 a2 a1 a0
b3 b2 b1 b0 b3 b2 b1 b0 ci co a7.. a0 b7.. b0 ci
4-bit adder co co s3 s2 s1 s0 s7 s6 s5 s4
+
C
(b)
(c)
Block symbol
31
a7..a0
b7..b0 ci 0
a
CALC LEDs
Digital Design 2e Copyright 2010 Frank Vahid
32
b7..b0 ci 0
s7..s0
ld
LEDs
33
01000010
a7..a0
ci
1 clk
ld
Weight Adjuster
to display
34
Incrementer
Adds 1 to input A
Inputs a3 a2 a1 a0 c0 Outputs s3 s2 s1 s0
carries: unused +
011 0011 1
00100
a
0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
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
Incrementer (+1)
a3 a b
a2 a b
a1 a b
a0 a
1 b
a3 a2 a1 a0 +1 co s3 s2 s1 s0
HA co s co s3
HA co s s2 (a)
HA co s s1
HA co s s0
(b)
Could design using combinational design process, but smaller design uses carry-ripple, only need half-adders
Digital Design 2e Copyright 2010 Frank Vahid
35
Comparators
N-bit equality comparator: Outputs 1 if two N-bit numbers are equal
4-bit equality comparator with inputs A and B
a3 must equal b3, a2 = b2, a1 = b1, a0 = b0
Two bits are equal if both 1, or both 0 eq = (a3b3 + a3b3) * (a2b2 + a2b2) * (a1b1 + a1b1) * (a0b0 + a0b0)
4.4
0110 = 0111 ?
0 0
1 1
1 1
0 1
a3 a2 a1 a0 b3 b2 b1 b0
0
Digital Design 2e Copyright 2010 Frank Vahid
eq
36
Magnitude Comparator
N-bit magnitude comparator: Two N-bit inputs A and B, outputs whether A>B, A=B, or A<B, for
How design? Consider comparing by hand. First compare a3 and b3. If equal, compare a2 and b2. And so on. Stop if comparison not equal (the two bits are 0 and 1, or 1 and 0)whichever of A or B has the 1 is thus greater. If never see unequal bit pair, then A=B.
Digital Design 2e Copyright 2010 Frank Vahid
A=1011 B=1001
So A > B
37
Magnitude Comparator
By-hand example leads to idea for design
Start at left, compare each bit pair, pass results to the right Each bit pair called a stage Each stage has 3 inputs taking results of higher stage, outputs new results to lower stage
a3 b3 a Igt Ieq Ilt b a2 b2 a b a1 b1 a b a0 b0 a b AgtB AeqB AltB
0 1 0
a3a2a1a0
b3b2b1b0
>=<
38
Magnitude Comparator
a3 b3 a Igt Ieq Ilt b a2 b2 a b a1 b1 a b a0 b0 a b
Each stage:
out_gt = in_gt + (in_eq * a * b)
A>B if already determined in higher stage, or if higher stages equal but in this stage a=1 and b=0
A<B if already determined in higher stage, or if higher stages equal but in this stage a=0 and b=1
Simple circuit inside each stage, just a few gates (not shown)
Digital Design 2e Copyright 2010 Frank Vahid
39
Magnitude Comparator
How does it work?
1011 = 1001 ?
1 = 1 a3 b3 0 0 a2 b2 1 0 a1 b1 a b 1 1 a0 b0 a b AgtB AeqB AltB
a b a b 0 0 Igt in_gt out_gt in_gt out_gt 1 1 Ieq in_eq out_eq in_eq out_eq 0 0 in_lt out_lt in_lt out_lt Ilt S tage3 S tage2 (a) 0 = 0 a2 b2
1 1 a3 b3
1 0 a1 b1
a b a b a b 0 0 0 Igt in_gt out_gt in_gt out_gt in_gt out_gt 1 1 1 Ieq in_eq out_eq in_eq out_eq in_eq out_eq 0 0 in_lt out_lt 0 in_lt out_lt in_lt out_lt Ilt
S tage3
Digital Design 2e Copyright 2010 Frank Vahid
S tage2
(b)
S tage1
S tage0
40
Magnitude Comparator
1011 = 1001 ?
1 1 0 0 1 > 0 a1 b1 1 a0 1 b0 a3 b3 a2 b2
b out_gt out_lt
a in_gt
in_eq out_eq
1 out_gt 0 in_gt out_gt in_gt out_gt 0 1 in_eq out_eq in_eq out_eq in_eq out_eq 0 in_lt out_lt 0 in_lt out_lt in_lt out_lt S tage2 (c) S tage1 S tage0
S tage3
1 a0
1 b0
a3 b3
a2 b2
a1 b1
a Igt 0
b out_gt out_lt
a in_gt in_lt
b out_gt out_lt
a in_gt
1 Ieq 0 Ilt
in_gt in_lt
in_eq out_eq
in_eq out_eq
1 out_gt 1 in_gt out_gt AgtB 0 0 in_eq out_eq in_eq out_eq AeqB 0 0 in_lt out_lt in_lt out_lt AltB S tage1 (d) S tage0
Final answer appears on the right Takes time for answer to ripple from left to right Thus called carry-ripple style after the carry-ripple adder Even though theres no carry involved
S tage3
Digital Design 2e Copyright 2010 Frank Vahid
S tage2
41
01111111
B 8 8 B 8 8 I0 A Min C 8 8 B
0 1 0
I1
8
(b)
(a)
01111111
Digital Design 2e Copyright 2010 Frank Vahid
42
4.5
43
44
b1
pp2
pp1
0
0 + (5-bit)
b2
pp3
00 A B
b3
+ (6-bit)
pp4
0 00
+ (7-bit)
Block symbol
p7..p0
45
4.6
- 0 0
1 0
1 1
1 1
a3 b3
a b wi FS wo s wo s3
Digital Design 2e Copyright 2010 Frank Vahid
a2 b2
a b wi FS wo s s2
a1 b1
a b wi FS wo s s1
a0 b0 wi
a b wi FS wo s s0 a3 a2 a1 a0 b3 b2 b1 b0 4-bit subtractor wo s3 s2 s1 s0 wi
a
(b)
(c)
46
B ci 8-bit adder
co S 8
A B wi 8-bit subtractor
wo 8 S
2x1 8
8-bit register
CALC
8
LEDs
Digital Design 2e Copyright 2010 Frank Vahid
47
Subtractor Example:
Color Space Converter RGB to CMYK
Color
Often represented as weights of three colors: red, green, and blue (RGB)
Perhaps 8 bits each (0-255), so specific color is 24 bits
White: R=11111111 (255), G=11111111, B=11111111 Black: R=00000000, G=00000000, B=00000000 Other colors: values in between, e.g., R=00111111, G=00000000, B=00001111 would be a reddish purple
Good for computer monitors, which mix red, green, and blue lights to form colors
Digital Design 2e Copyright 2010 Frank Vahid
Subtractor Example:
Color Space Converter RGB to CMYK
Printers must quickly convert RGB to CMY
C=255-R, M=255-G, Y=255-B Use subtractors as shown
C
R 255 8 8 G 255 8 8 B 255 8 8
8 M
8 Y
49
Subtractor Example:
Color Space Converter RGB to CMYK
Try to save colored inks
Expensive Imperfect mixing C, M, Y doesnt yield good-looking black
Solution: Factor out the black or gray from the color, print that part using black ink
e.g., CMY of (250,200,200)= (200,200,200) + (50,0,0).
(200,200,200) is a dark gray use black ink
Digital Design 2e Copyright 2010 Frank Vahid
50
Subtractor Example:
Color Space Converter RGB to CMYK
Call black part K
(200,200,200): K=200
(Letter B already used for blue)
C2 8
M2 8
Y2 8 K 8 51
Signed-magnitude
Use leftmost bit for sign bit
So -5 would be:
1101 using four bits 10000101 using eight bits
52
Tens Complement
1 9 8 7 6 5 4 3 2 1
2 3 4 5 6 7 8 9
53
Tens Complement
Nice feature of tens complement
Instead of subtracting a number, adding its complement results in answer exactly 10 too much So just drop the 1 results in subtracting using addition only
complements 1 2 3 4 5 6 7 8 9 0
Digital Design 2e Copyright 2010 Frank Vahid
9 8 7 6 5 4 3 2 1 10 74=3 0 4 7
10 6
10 +6
20 13 13 3
a
7+6=13
Adding the complement results in an answer that is exactly 10 too much dropping the tens column gives the right answer. 54
True. But in binary, it turns out that the twos complement can be computed easily
Twos complement of 011 is 101, because 011 + 101 is 1000 Could compute complement of 011 as 1000 011 = 101 Easier method: Just invert all the bits, and add 1 The complement of 011 is 100+1 = 101. It works!
a
A: 1100+1=1101
55
Twos Complement
Twos complement can represent negative numbers
Suppose have 4 bits Positive numbers 0 to 7: 0000 to 0111 Negative numbers
-1: Take twos complement of 1: 0001 1110+1 = 1111 -2: 0010 1101+1 = 1110 -8: 1000 0111+1 = 1000 So -1 to -8: 1111 to 1000
Quick method to determine magnitude of negative number 4-bit: subtract right 3 bits from 8. Ex. 1110: -(8 6) = -2 Or just take twos complement again: 1110 -(0001+1) = -0010 = -2
Leftmost bit indicates sign of number, known as sign bit. 1 means negative.
56
A Adder
B cin
57
Adder/Subtractor
Adder/subtractor: control input determines whether add or subtract
Can use 2x1 mux sub input passes either B or inverted B Alternatively, can use XOR gates if sub input is 0, Bs bits pass through; if sub input is 1, XOR inverts Bs bits
B A 0 1 N-bit 2x1 A B Adder cin S N-bit b7 b6 sub
sub
adders B inputs
58
e clk
LEDs
8 8 A B wi 0 8-bit subt ract or wo S
8 B ci 0 8-bit adder co S 8 ld 0 2x 1 8 1
1 0 clk
f e
LEDs
59
Overflow
Sometimes result cant be represented with given number of bits
Either too large magnitude of positive or negative Ex. 4-bit twos complement addition of 0111+0001 (7+1=8). But 4-bit twos complement cant represent number >7
0111+0001 = 1000 WRONG answer, 1000 in twos complement is -8, not +8
Adder/subtractor should indicate when overflow has occurred, so result can be discarded
60
1 1 1 1 +1 0 0 0 0 1 1 1 overflow (b)
1 0 0 0 +0 1 1 1 1 1 1 1 no overflow (c)
If the numbers sign bits have the same value, which differs from the results sign bit, overflow has occurred.
61
1 1 1 0 1 1 1 +0 0 0 1 0 1 0 0 0 overflow (a)
0 0 0 1 1 1 1 +1 0 0 0 10 1 1 1 overflow (b)
0 0 0 1 0 0 0 +0 1 1 1 01 1 1 1 no overflow (c)
If the carry into the sign bit column differs from the carry out of that column, overflow has occurred.
62
4.7
63
+ 8
+1 8 8 8
AND
OR
XOR NOT
8 8
8 A lot of wires
1 0
x y z
e
clk
CALC 8
LEDs
64
ALU
More efficient design uses ALU
ALU design not just separate components multiplexed (same problem as previous slide) Instead, ALU design uses single adder, plus logic in front of adders A and B inputs
Logic in front is called an arithmetic-logic extender
Extender modifies A and B inputs so desired operation appears at output of the adder
A x y z B a7 b7 a6 b6 a0 b0 AL-extender AL-extender x y z abext abext abext cinext
a
IA IB Adder cin
IS
ALU S (a)
Digital Design 2e Copyright 2010 Frank Vahid
ia7 ib7
ia0 ib0
cin
65
a7 b7
a6 b6
a0 b0
AL-extender
AL-extender x y z
abext
abext
abext
cinext
ia7 ib7
ia0 ib0
cin
xyz=000 Want S=A+B : just pass a to ia, b to ib, and set cin=0 xyz=001 Want S=A-B : pass a to ia, b to ib and set cin=1 (twos complement) xyz=010 Want S=A+1 : pass a to ia, set ib=0, and set cin=1 xyz=011 Want S=A : pass a to ia, set ib=0, and set cin=0 xyz=100 Want S=A AND B : set ia=a*b, b=0, and cin=0 Others: likewise Based on above, create logic for ia(x,y,z,a,b) and ib(x,y,z,a,b) for each abext, and create logic for cin(x,y,z), to complete design of the AL-extender component
Digital Design 2e Copyright 2010 Frank Vahid
66
CALC
LEDs
67
Shifters
Shifting (e.g., left shifting 0011 yields 0110) useful for:
Manipulating bits Converting serial data to parallel (remember earlier above-mirror display example with shift registers) Multiply/divide by 2 (unsigned numbers only)
Shift left once is same as multiplying by 2. Ex: 0011 (3) becomes 0110 (6)
Why? Essentially appending a 0 -- Note that multiplying decimal number by 10 accomplished just be appending 0, i.e., by shifting left (55 becomes 550)
4.8
i3
i2
i1
i0 inL
shL shR
2 01 201 2 01 2 01 s0 s1
a
q3
q2
q1
q0
Symbol
Digital Design 2e Copyright 2010 Frank Vahid
Left shifter
q3
q2
q1
q0
68
ld +
+
+
a
shift in 0
0
0101010 (42)
>>2
divide by 4
Note rounding
0001010 (10)
ld Ravg Tavg
69
Strength Reduction
Many multiplications not by power of 2 constants (2, 4, 8, )
E.g., by 5, or 10 Could use multiplier component, but shifters are small and fast
70
+
a
Note: Uses wider buses, padded on the left, to avoid losing bits during shifts Determine biggest possible internal values, set width accordingly Do divisions as late as possible to reduce rounding errors
>>7
0000000000100000
+ 16 F = C +(C*64+C*32+C*4+C*2)/128 + 32
71
Barrel Shifter
A shifter that can shift by any amount
4-bit barrel left shift can shift left by 0, 1, 2, or 3 positions 8-bit barrel left shifter can shift left by 0, 1, 2, 3, 4, 5, 6, or 7 positions
i3 01
i2 01
i1 01
i0 in 01 sh
q3
q2
q1
q0
(Shifting an 8-bit number by 8 positions is pointless -- you just lose all the bits) Q: xyz=??? to
Shift by 1 shifter uses 2x1 muxes. 8x1 mux solution for 8-bit barrel shifter: too many wires.
shift by 5?
1
x sh
00000110
in
<<4 8
0
a
0
y
01100000
in
0
sh
<<2
8
1
z
01100000
in 0
72
sh
<<1
Q
11000000
4.9
0 1 0
clr cnt
4-bit up-counter tc C
4
0 1
4-bit up-counter
Internal design
Register, incrementer, and N-input AND gate to detect terminal count
cnt
4-bit register
4 tc C
+1
73
Display
8,406
74
Up/Down-Counter
Can count either up or down
Includes both incrementer and decrementer Use dir input to select, via 2x1 mux: dir=0 means up Likewise, dir selects appropriate terminal count value (all 1s or all 0s)
dir 4-bit up/down counter
4-bit 2 x 1 0 4
clr cn t
clr ld
4-bit register
4 4
4 1 4
4 +1 4
1 2x 1 0 tc
Digital Design 2e Copyright 2010 Frank Vahid
75
cnt clr
4 4 tc C
4 +1
76
1000
4
4-bit down-counter
tc 4 C
clk
77
Counter Example:
New Years Eve Countdown Display
Chapter 2 example previously used microprocessor to count from 59 down to 0 in binary Can use 8-bit (or 7- or 6-bit) down-counter instead, initially loaded with 59
8 d0 d1 d2 0 Happy New Year!
59
c0 c1 c2 c3 c4 c5 c6 c7
i0 i1 i2 i3 i4 i5
1
2 3
Note: Use 8bit counter, not 60-bit counter
ld
0 clr cnt
d3
clk 1 Hz
Digital Design 2e Copyright 2010 Frank Vahid
d62
58 59
fireworks
78
(unused)
79
Clock Division by Amount not Power of 2 Example: 1 Hz Pulse Generator from 60 Hz Clock
Example: U.S. electricity standard uses 60 Hz signal
Device may convert that to 1 Hz signal to count seconds
clr cnt
osc 60 Hz
ld cnt
1 Hz
Digital Design 2e Copyright 2010 Frank Vahid
80
vehicle b a
Digital Design 2e Copyright 2010 Frank Vahid
S1
81
Timers
Pulses output at userspecified timer interval when enabled
Ticks like a clock Interval specified as multiple of base time unit If base is 1 microsec and user wants pulse every 300 ms, loads 300,000 into timer
load ld 1 ld enable 1 microsec oscillator cnt tc
M -1
32
32-bit register
4-bit 2x1 0
(a)
32
load enable
(b)
(c)
Digital Design 2e Copyright 2010 Frank Vahid
82
laser
clk patient
(a)
300,000 (in binary) ld Controller clk en Q M 32-bit 1 microsec timer Q x
load enable
(b)
10 ns clk Inputs: b Q ... 300 ms ... ...
Use timer
Controller FSM loads timer, enables, then waits for Q=1
Inputs: b, Q Outputs: ld, en, x x=0 ld=1 en=0
State Off Off Off Off Strt On ... On Off Off b x=0 ld=0 en=1 Strt b' Q On Q' ld x=1 ld=0 en=1 en Outputs: x ... ... ...
(d)
(c)
83
Register Files
Accessing one of several registers is:
OK if just a few registers Problematic when many Ex: Earlier above-mirror display, with 16 registers
Much fanout (branching of wire): Weakens signal Many wires: Congestion
load
load 32 C C 8 d0d0 4x16 2 4 4 a0 d1 i0 d2 load reg2
4.10
9
load reg0 load
reg0 T huge mux 32 too much fanout load reg1
9
A
9
9
8
i1
i1 i3-i0 a1
9
9
dd
8
328
DD
i2 congestion
d15 e
d3
32
4 32-bit registers tolerable 16 32-bit registers begins to have fanout and wire problems
84
Register File
MxN register file: Efficient design for one-at-a-time write/read of many registers
Consider 16 32-bit registers
32 4
32-bit data that is read 4-bit address to specifies which register to read
read port
Enable read
85
Register File
W_data
32 bus d0 2x4 d1 load reg0 32 load reg1 32 d2 write decoder d3 e load reg2 32 driver
9
d0
32
R_data
9
9 9
W_addr
i0 i1
9
1
1
R_addr
Boosts signal
W_en
load reg3
9
32
three-state driver
a
86
1
9 3 22 1
2
X X
32 2
87
OLD design
a
d0
4 16 C 4 WA i3-i0 load
load reg0
32 t oo much 32 W_data fanout 4 W_addr W_en
32 RA
congestion e
d15
load reg15
load
i15
32 s3-s0
88
Chapter Summary
Need datapath components to store and operate on multi-bit data
Also known as register-transfer-level (RTL) components
Components introduced
Registers Adders Comparators Multipliers Subtractors Arithmetic-Logic Units Shifters Counters and Timers Register Files
Next chapter combines knowledge of combinational logic design, sequential logic design, and datapath components, to build digital circuits that can perform general and powerful computations
Digital Design 2e Copyright 2010 Frank Vahid
89