chapter 5pmadden/courses/cs120/slides/ddca_ch5.pdf · chapter 5 digital design and computer...
TRANSCRIPT
![Page 1: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/1.jpg)
Chapter5<1>
DigitalDesignandComputerArchitecture,2nd Edition
Chapter5
DavidMoneyHarrisandSarahL.Harris
![Page 2: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/2.jpg)
Chapter5<2>
Chapter5::Topics
• Introduction• ArithmeticCircuits• NumberSystems• SequentialBuildingBlocks• MemoryArrays• LogicArrays
![Page 3: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/3.jpg)
Chapter5<3>
• Digitalbuildingblocks:– Gates,multiplexers,decoders,registers,arithmeticcircuits,counters,memoryarrays,logicarrays
• Buildingblocksdemonstratehierarchy,modularity,andregularity:– Hierarchyofsimplercomponents– Well-definedinterfacesandfunctions– Regularstructureeasilyextendstodifferentsizes
• WillusethesebuildingblocksinChapter7tobuildmicroprocessor
Introduction
![Page 4: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/4.jpg)
Chapter5<4>
A B0 00 11 01 1
SCout
S =Cout =
HalfAdderA B
S
Cout +
A B0 00 11 01 1
SCout
S =Cout =
FullAdder
Cin
0 00 11 01 1
00001111
A B
S
Cout Cin+
1-BitAdders
![Page 5: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/5.jpg)
Chapter5<5>
A B0 00 11 01 1
0110
SCout0001
S =Cout =
HalfAdderA B
S
Cout +
A B0 00 11 01 1
0110
SCout0001
S =Cout =
FullAdder
Cin
0 00 11 01 1
00001111
1001
0111
A B
S
Cout Cin+
1-BitAdders
![Page 6: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/6.jpg)
Chapter5<6>
A B0 00 11 01 1
0110
SCout0001
S = A BCout = AB
HalfAdderA B
S
Cout +
A B0 00 11 01 1
0110
SCout0001
S = A B CinCout = AB + ACin + BCin
FullAdder
Cin
0 00 11 01 1
00001111
1001
0111
A B
S
Cout Cin+
1-BitAdders
![Page 7: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/7.jpg)
Chapter5<7>
A B
S
Cout Cin+N
NN
• Types of carry propagate adders (CPAs):– Ripple-carry (slow)– Carry-lookahead (fast)– Prefix (faster)
• Carry-lookahead and prefix adders faster for large adders but require more hardware
Symbol
Multibit Adders(CPAs)
![Page 8: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/8.jpg)
Chapter5<8>
S31
A30 B30
S30
A1 B1
S1
A0 B0
S0
C30 C29 C1 C0Cout ++++
A31 B31
Cin
• Chain 1-bit adders together• Carry ripples through entire chain• Disadvantage: slow
Ripple-CarryAdder
![Page 9: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/9.jpg)
Chapter5<9>
tripple = NtFA
where tFA is the delay of a 1-bit full adder
Ripple-CarryAdderDelay
![Page 10: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/10.jpg)
Chapter5<10>
• Compute carry out (Cout) for k-bit blocks using generate and propagate signals
• Some definitions:– Column i produces a carry out by either generating a carry out or
propagating a carry in to the carry out– Generate (Gi) and propagate (Pi) signals for each column:
• Column i will generate a carry out if Ai AND Bi are both 1.
Gi = Ai Bi• Column i will propagate a carry in to the carry out if Ai OR Bi is 1.
Pi = Ai + Bi• The carry out of column i (Ci) is:
Ci = Ai Bi + (Ai + Bi )Ci-1 = Gi + Pi Ci-1
Carry-Lookahead Adder
![Page 11: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/11.jpg)
Chapter5<11>
• Step 1: Compute Gi and Pi for all columns • Step 2: Compute G and P for k-bit blocks• Step 3: Cin propagates through each k-bit
propagate/generate block
Carry-Lookahead Addition
![Page 12: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/12.jpg)
Chapter5<12>
• Example: 4-bit blocks (G3:0 and P3:0) :G3:0 = G3 + P3 (G2 + P2 (G1 + P1G0 )P3:0 = P3P2 P1P0
• Generally,Gi:j = Gi + Pi (Gi-1 + Pi-1 (Gi-2 + Pi-2Gj )Pi:j = PiPi-1 Pi-2Pj
Ci = Gi:j + Pi:j Cj-1
Carry-Lookahead Adder
![Page 13: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/13.jpg)
Chapter5<13>
B0
++++
P3:0
G3P3G2P2G1P1G0
P3P2P1P0
G3:0
Cin
Cout
A0
S0
C0
B1 A1
S1
C1
B2 A2
S2
C2
B3 A3
S3
Cin
A3:0B3:0
S3:0
4-bit CLABlock Cin
A7:4B7:4
S7:4
4-bit CLABlock
C3C7
A27:24B27:24
S27:24
4-bit CLABlock
C23
A31:28B31:28
S31:28
4-bit CLABlock
C27Cout
32-bitCLAwith4-bitBlocks
![Page 14: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/14.jpg)
Chapter5<14>
For N-bit CLA with k-bit blocks:
tCLA = tpg + tpg_block + (N/k – 1)tAND_OR + ktFA
– tpg : delay to generate all Pi, Gi
– tpg_block : delay to generate all Pi:j, Gi:j
– tAND_OR : delay from Cin to Cout of final AND/OR gate in k-bit CLA block
An N-bit carry-lookahead adder is generally much faster than a ripple-carry adder for N > 16
Carry-Lookahead AdderDelay
![Page 15: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/15.jpg)
Chapter5<15>
• Computes carry in (Ci-1) for each column, then computes sum:
Si = (Ai Å Bi) Å Ci• Computes G and P for 1-, 2-, 4-, 8-bit blocks, etc.
until all Gi (carry in) known• log2N stages
PrefixAdder
![Page 16: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/16.jpg)
Chapter5<16>
• Carry in either generated in a column or propagated from a previous column.
• Column -1 holds Cin, so G-1 = Cin, P-1 = 0
• Carry in to column i = carry out of column i-1: Ci-1 = Gi-1:-1
Gi-1:-1: generate signal spanning columns i-1 to -1• Sum equation:
Si = (Ai Å Bi) Å Gi-1:-1
• Goal: Quickly compute G0:-1, G1:-1, G2:-1, G3:-1, G4:-1, G5:-1, … (called prefixes)
PrefixAdder
![Page 17: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/17.jpg)
Chapter5<17>
• Generate and propagate signals for a block spanning bits i:j:
Gi:j = Gi:k + Pi:k Gk-1:j
Pi:j = Pi:kPk-1:j• In words:
– Generate: block i:j will generate a carry if:• upper part (i:k) generates a carry or • upper part propagates a carry generated in lower part
(k-1:j)– Propagate: block i:j will propagate a carry if both the
upper and lower parts propagate the carry
PrefixAdder
![Page 18: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/18.jpg)
Chapter5<18>
0:-1
-1
2:1
1:-12:-1
012
4:3
3
6:5
5:36:3
456
5:-16:-1 3:-14:-1
8:7
7
10:9
9:710:7
8910
12:11
11
14:13
13:1114:11
121314
13:714:7 11:712:7
9:-110:-1 7:-18:-113:-114:-1 11:-112:-1
15
0123456789101112131415
BiAi
Gi:iPi:i
Gk-1:jPk-1:jGi:kPi:k
Gi:jPi:j
ii:j
BiAiGi-1:-1
Si
iLegend
PrefixAdderSchematic
![Page 19: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/19.jpg)
Chapter5<19>
tPA = tpg + log2N(tpg_prefix ) + tXOR
– tpg: delay to produce Pi Gi (AND or OR gate)– tpg_prefix: delay of black prefix cell (AND-OR gate)
PrefixAdderDelay
![Page 20: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/20.jpg)
Chapter5<20>
Compare delay of: 32-bit ripple-carry, carry-lookahead, and prefix adders• CLA has 4-bit blocks• 2-input gate delay = 100 ps; full adder delay = 300 ps
AdderDelayComparisons
![Page 21: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/21.jpg)
Chapter5<21>
Compare delay of: 32-bit ripple-carry, carry-lookahead, and prefix adders• CLA has 4-bit blocks• 2-input gate delay = 100 ps; full adder delay = 300 ps
tripple = NtFA = 32(300 ps) = 9.6 ns
tCLA = tpg + tpg_block + (N/k – 1)tAND_OR + ktFA
= [100 + 600 + (7)200 + 4(300)] ps= 3.3 ns
tPA = tpg + log2N(tpg_prefix ) + tXOR
= [100 + log232(200) + 100] ps= 1.2 ns
AdderDelayComparisons
![Page 22: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/22.jpg)
Chapter5<22>
Symbol Implementation
+
A B
-
YY
A B
NN
N
N N
N
N
Subtracter
![Page 23: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/23.jpg)
Chapter5<23>
Symbol ImplementationA3B3A2B2A1B1A0B0
Equal=
A B
Equal
44
Comparator:Equality
![Page 24: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/24.jpg)
Chapter5<24>Copyright©2007Elsevier 5-<24>
A < B
-
BA
[N-1]
N
N N
Comparator:LessThan
![Page 25: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/25.jpg)
Chapter5<25>Copyright©2007Elsevier 5-<25>
ALU
N N
N3
A B
Y
F
F2:0 Function000 A & B001 A | B010 A + B011 not used100 A & ~B101 A | ~B110 A - B111 SLT
ArithmeticLogicUnit(ALU)
![Page 26: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/26.jpg)
Chapter5<26>Copyright©2007Elsevier 5-<26>
+
2 01
A B
Cout
Y
3
01
F2
F1:0
[N-1] S
NN
N
N
N NNN
N
2
ZeroExtend
F2:0 Function000 A & B001 A | B010 A + B011 not used100 A & ~B101 A | ~B110 A - B111 SLT
ALUDesign
![Page 27: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/27.jpg)
Chapter5<27>
Compare delay of: 32-bit ripple-carry, carry-lookahead, and prefix adders• CLA has 4-bit blocks• 2-input gate delay = 100 ps; full adder delay = 300 ps
tripple = NtFA = 32(300 ps) = 9.6 ns
tCLA = tpg + tpg_block + (N/k – 1)tAND_OR + ktFA
= [100 + 600 + (7)200 + 4(300)] ps= 3.3 ns
tPA = tpg + log2N(tpg_prefix ) + tXOR
= [100 + log232(200) + 100] ps= 1.2 ns
AdderDelayComparisons
![Page 28: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/28.jpg)
Chapter5<28>Copyright©2007Elsevier 5-<28>
+
2 01
A B
Cout
Y
3
01
F2
F1:0
[N-1] S
NN
N
N
N NNN
N
2
ZeroExtend
• Configure 32-bit ALU for SLT operation: A = 25 and B = 32
SetLessThan(SLT)Example
![Page 29: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/29.jpg)
Chapter5<29>Copyright©2007Elsevier 5-<29>
+
2 01
A B
Cout
Y
3
01
F2
F1:0
[N-1] S
NN
N
N
N NNN
N
2
ZeroExtend
• Configure 32-bit ALU for SLT operation: A = 25 and B = 32– A < B, so Y should be 32-bit
representation of 1 (0x00000001)– F2:0 = 111
– F2 = 1 (adder acts as subtracter), so 25 - 32 = -7
– -7 has 1 in the most significant bit (S31 = 1)
– F1:0 = 11 multiplexer selects Y = S31 (zero extended) = 0x00000001.
SetLessThan(SLT)Example
![Page 30: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/30.jpg)
Chapter5<30>Copyright©2007Elsevier 5-<30>
• Logicalshifter:shiftsvaluetoleftorrightandfillsemptyspaceswith0’s– Ex:11001 >>2=– Ex:11001 <<2=
• Arithmeticshifter: sameaslogicalshifter,butonrightshift,fillsemptyspaceswiththeoldmostsignificantbit(msb).– Ex:11001 >>>2=– Ex:11001 <<<2=
• Rotator: rotatesbitsinacircle,suchthatbitsshiftedoffoneendareshiftedintotheotherend– Ex:11001ROR2=– Ex:11001ROL2=
Shifters
![Page 31: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/31.jpg)
Chapter5<31>
• Logicalshifter:– Ex:11001 >>2=00110– Ex:11001 <<2=00100
• Arithmeticshifter:– Ex:11001 >>>2=11110– Ex:11001 <<<2=00100
• Rotator:– Ex:11001ROR2=01110– Ex:11001 ROL2=00111
Shifters
![Page 32: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/32.jpg)
Chapter5<32>
A3:0 Y3:0
shamt1:0
>>
2
4 4
A3 A2 A1 A0
Y3
Y2
Y1
Y0
shamt1:0
00
01
10
11
S1:0
S1:0
S1:0
S1:0
00
01
10
11
00
01
10
11
00
01
10
11
2
ShifterDesign
![Page 33: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/33.jpg)
Chapter5<33>
• A <<N =A × 2N– Example: 00001<<2=00100(1× 22 =4)– Example:11101<<2=10100(-3× 22 =-12)
• A >>>N =A ÷ 2N– Example: 01000>>>2=00010(8÷ 22 =2)– Example: 10000>>>2=11100(-16÷ 22 =-4)
ShiftersasMultipliers,Dividers
![Page 34: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/34.jpg)
Chapter5<34>
• Partialproductsformedbymultiplyingasingledigitofthemultiplierwithmultiplicand
• Shifted partialproductssummed toformresult
Decimal Binary230
42x01010111
5 x 7 = 35
460920+9660
01010101
01010000
x
+0100011
230 x 42 = 9660
multipliermultiplicand
partialproducts
result
Multipliers
![Page 35: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/35.jpg)
Chapter5<35>
4x4Multiplier
x B3 B2 B1 B0
A3B0 A2B0 A1B0 A0B0
A3 A2 A1 A0
A3B1 A2B1 A1B1 A0B1
A3B2 A2B2 A1B2 A0B2
A3B3 A2B3 A1B3 A0B3+P7 P6 P5 P4 P3 P2 P1 P0
0
P2
0
0
0
P1 P0P5 P4 P3P7 P6
A3 A2 A1 A0
B0B1
B2
B3
x
A B
P
44
8
![Page 36: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/36.jpg)
Chapter5<36>
4x4Divider
1
A3000
Q3
1
Q2
B0B1B2B3
R0R1R2R3
A2
1
Q1
A1
1
Q0
A0
+
R B
D
R'
N
CinCout
1 0
R B
DR'N
CoutCin
Legend
A/B = Q + R/BAlgorithm:R’ = 0for i = N-1 to 0R = {R’ << 1. Ai}D = R - Bif D < 0, Qi=0, R’=Relse Qi=1, R’=D
R’=R
![Page 37: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/37.jpg)
Chapter5<37>
• Numbers we can represent using binary representations– Positive numbers
• Unsigned binary– Negative numbers
• Two’s complement• Sign/magnitude numbers
• What about fractions?
NumberSystems
![Page 38: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/38.jpg)
Chapter5<38>
• Two common notations:– Fixed-point: binary point fixed– Floating-point: binary point floats to the right of the
most significant 1
NumberswithFractions
![Page 39: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/39.jpg)
Chapter5<39>
011011000110.110022 + 21 + 2-1 + 2-2 = 6.75
• 6.75 using 4 integer bits and 4 fraction bits:
• Binary point is implied• The number of integer and fraction bits must be
agreed upon beforehand
Fixed-PointNumbers
![Page 40: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/40.jpg)
Chapter5<40>
• Represent 7.510 using 4 integer bits and 4 fraction bits.
Fixed-PointNumberExample
![Page 41: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/41.jpg)
Chapter5<41>
• Represent 7.510 using 4 integer bits and 4 fraction bits.
01111000
Fixed-PointNumberExample
![Page 42: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/42.jpg)
Chapter5<42>
• Representations:– Sign/magnitude– Two’s complement
• Example: Represent -7.510 using 4 integer and 4 fraction bits– Sign/magnitude:
– Two’s complement:
SignedFixed-PointNumbers
![Page 43: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/43.jpg)
Chapter5<43>
• Representations:– Sign/magnitude– Two’s complement
• Example: Represent -7.510 using 4 integer and 4 fraction bits– Sign/magnitude:
11111000– Two’s complement:
1. +7.5: 011110002. Invert bits: 100001113. Add 1 to lsb: + 1
10001000
SignedFixed-PointNumbers
![Page 44: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/44.jpg)
Chapter5<44>
• Binary point floats to the right of the most significant 1• Similar to decimal scientific notation
• For example, write 27310 in scientific notation:273 = 2.73 × 102
• In general, a number is written in scientific notation as:± M × BE
– M = mantissa– B = base– E = exponent– In the example, M = 2.73, B = 10, and E = 2
Floating-PointNumbers
![Page 45: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/45.jpg)
Chapter5<45>
Sign Exponent Mantissa
1 bit 8 bits 23 bits
• Example: represent the value 22810 using a 32-bit floating point representation
We show three versions –final version is called the IEEE 754 floating-point standard
Floating-PointNumbers
![Page 46: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/46.jpg)
Chapter5<46>
0 00000111 11 1001 0000 0000 0000 0000Sign Exponent Mantissa
1 bit 8 bits 23 bits
1. Convert decimal to binary (don’t reverse steps 1 & 2!):22810 = 111001002
2. Write the number in “binary scientific notation”:111001002 = 1.110012 × 27
3. Fill in each field of the 32-bit floating point number:– The sign bit is positive (0)
– The 8 exponent bits represent the value 7
– The remaining 23 bits are the mantissa
Floating-PointRepresentation1
![Page 47: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/47.jpg)
Chapter5<47>
0 00000111 110 0100 0000 0000 0000 0000Sign Exponent Fraction
1 bit 8 bits 23 bits
• First bit of the mantissa is always 1:– 22810 = 111001002 = 1.11001 × 27
• So, no need to store it: implicit leading 1
• Store just fraction bits in 23-bit field
Floating-PointRepresentation2
![Page 48: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/48.jpg)
Chapter5<48>
0 10000110Sign Biased
ExponentFraction
1 bit 8 bits 23 bits 110 0100 0000 0000 0000 0000
• Biased exponent: bias = 127 (011111112)– Biased exponent = bias + exponent
– Exponent of 7 is stored as:
127 + 7 = 134 = 0x100001102
• The IEEE 754 32-bit floating-point representation of 22810
in hexadecimal: 0x43640000
Floating-PointRepresentation3
![Page 49: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/49.jpg)
Chapter5<49>
Write -58.2510 in floating point (IEEE 754)
Floating-PointExample
![Page 50: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/50.jpg)
Chapter5<50>
1 100 0010 0 110 1001 0000 0000 0000 0000Sign Exponent Fraction
1 bit 8 bits 23 bits
Write -58.2510 in floating point (IEEE 754)1. Convert decimal to binary:
58.2510 = 111010.012
2. Write in binary scientific notation:
1.1101001 × 25
3. Fill in fields:Sign bit: 1 (negative)8 exponent bits: (127 + 5) = 132 = 10000100223 fraction bits: 110 1001 0000 0000 0000 0000
in hexadecimal: 0xC2690000
Floating-PointExample
![Page 51: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/51.jpg)
Chapter5<51>
Number Sign Exponent Fraction
0 X 00000000 00000000000000000000000
∞ 0 11111111 00000000000000000000000
- ∞ 1 11111111 00000000000000000000000
NaN X 11111111 non-zero
Floating-Point:SpecialCases
![Page 52: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/52.jpg)
Chapter5<52>
• Single-Precision:– 32-bit– 1 sign bit, 8 exponent bits, 23 fraction bits– bias = 127
• Double-Precision:– 64-bit– 1 sign bit, 11 exponent bits, 52 fraction bits– bias = 1023
Floating-PointPrecision
![Page 53: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/53.jpg)
Chapter5<53>
• Overflow: number too large to be represented• Underflow: number too small to be represented• Rounding modes:
– Down– Up– Toward zero– To nearest
• Example: round 1.100101 (1.578125) to only 3 fraction bits– Down: 1.100– Up: 1.101– Toward zero: 1.100– To nearest: 1.101 (1.625 is closer to 1.578125 than 1.5 is)
Floating-Point:Rounding
![Page 54: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/54.jpg)
Chapter5<54>
1. Extract exponent and fraction bits2. Prepend leading 1 to form mantissa3. Compare exponents4. Shift smaller mantissa if necessary5. Add mantissas6. Normalize mantissa and adjust exponent if necessary7. Round result8. Assemble exponent and fraction back into floating-point
format
Floating-PointAddition
![Page 55: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/55.jpg)
Chapter5<55>
Add the following floating-point numbers:0x3FC000000x40500000
Floating-PointAdditionExample
![Page 56: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/56.jpg)
Chapter5<56>
0 01111111 100 0000 0000 0000 0000 0000Sign Exponent Fraction
1 bit 8 bits 23 bits
0 10000000 101 0000 0000 0000 0000 00001 bit 8 bits 23 bits
Sign Exponent Fraction
1. Extract exponent and fraction bits
For first number (N1): S = 0, E = 127, F = .1For second number (N2): S = 0, E = 128, F = .101
2. Prepend leading 1 to form mantissaN1: 1.1N2: 1.101
Floating-PointAdditionExample
![Page 57: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/57.jpg)
Chapter5<57>
3. Compare exponents127 – 128 = -1, so shift N1 right by 1 bit
4. Shift smaller mantissa if necessaryshift N1’s mantissa: 1.1 >> 1 = 0.11 (× 21)
5. Add mantissas0.11 × 21
+ 1.101 × 21
10.011 × 21
Floating-PointAdditionExample
![Page 58: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/58.jpg)
Chapter5<58>
0 10000001 001 1000 0000 0000 0000 0000Sign Exponent Fraction
1 bit 8 bits 23 bits
6. Normalize mantissa and adjust exponent if necessary10.011 × 21 = 1.0011 × 22
7. Round resultNo need (fits in 23 bits)
8. Assemble exponent and fraction back into floating-point formatS = 0, E = 2 + 127 = 129 = 100000012, F = 001100..
in hexadecimal: 0x40980000
FloatingPointAdditionExample
![Page 59: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/59.jpg)
Chapter5<59>
Q
CLK
ResetN
+ N
1
CLK
Reset
N
NQN
r
Symbol Implementation
• Increments on each clock edge• Used to cycle through numbers. For example,
– 000, 001, 010, 011, 100, 101, 110, 111, 000, 001…
• Example uses:– Digital clock displays– Program counter: keeps track of current instruction executing
Counters
![Page 60: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/60.jpg)
Chapter5<60>
NQ
Sin Sout
CLKSin Sout
Q0 Q1 QN-1Q2
Implementation:
• Shift a new bit in on each clock edge• Shift a bit out on each clock edge• Serial-to-parallel converter: converts serial input (Sin) to
parallel output (Q0:N-1)
ShiftRegisters
Symbol:
![Page 61: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/61.jpg)
Chapter5<61>
Clk01
01
01
01
D0 D1 DN-1D2
Q0 Q1 QN-1Q2
Sin Sout
Load
• When Load = 1, acts as a normal N-bit register• When Load = 0, acts as a shift register• Now can act as a serial-to-parallel converter (Sin to Q0:N-1) or
a parallel-to-serial converter (D0:N-1 to Sout)
ShiftRegisterwithParallelLoad
![Page 62: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/62.jpg)
Chapter5<62>
Address
Data
ArrayN
M
• Efficiently store large amounts of data• 3 common types:
– Dynamic random access memory (DRAM)– Static random access memory (SRAM)– Read only memory (ROM)
• M-bit data value read/ written at each unique N-bit address
MemoryArrays
![Page 63: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/63.jpg)
Chapter5<63>
Address
Data
ArrayN
M
Address Data11100100
depth
0 1 01 0 01 1 00 1 1
width
Address
Data
Array2
3
• 2-dimensional array of bit cells • Each bit cell stores one bit• N address bits and M data bits:
– 2N rows and M columns– Depth: number of rows (number of words)– Width: number of columns (size of word)– Array size: depth × width = 2N × M
MemoryArrays
![Page 64: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/64.jpg)
Chapter5<64>
Address Data11100100
depth
0 1 01 0 01 1 00 1 1
width
Address
Data
Array2
3
• 22 × 3-bit array• Number of words: 4• Word size: 3-bits• For example, the 3-bit word stored at address 10 is 100
MemoryArrayExample
![Page 65: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/65.jpg)
Chapter5<65>
Address
Data
1024-word x32-bitArray
10
32
MemoryArrays
![Page 66: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/66.jpg)
Chapter5<66>
stored bit
wordlinebitline
stored bit = 0
wordline = 1
stored bit = 1
stored bit = 0
stored bit = 1
bitline =
(a) (b)
wordline = 1
wordline = 0
wordline = 0
bitline =
bitline =
bitline =
MemoryArrayBitCells
![Page 67: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/67.jpg)
Chapter5<67>
stored bit
wordlinebitline
stored bit = 0
wordline = 1
stored bit = 1
stored bit = 0
stored bit = 1
bitline =
(a) (b)
wordline = 1
wordline = 0
wordline = 0
bitline =
bitline =
bitline = 0
1
Z
Z
MemoryArrayBitCells
![Page 68: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/68.jpg)
Chapter5<68>
wordline311
10
2:4Decoder
Address
01
00
storedbit = 0wordline2
wordline1
wordline0
storedbit = 1
storedbit = 0
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
bitline2 bitline1 bitline0
Data2 Data1 Data0
2
• Wordline: – like an enable– single row in memory array read/written– corresponds to unique address– only one wordline HIGH at once
MemoryArray
![Page 69: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/69.jpg)
Chapter5<69>
• Random access memory (RAM): volatile• Read only memory (ROM): nonvolatile
TypesofMemory
![Page 70: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/70.jpg)
Chapter5<70>
• Volatile: loses its data when power off• Read and written quickly• Main memory in your computer is RAM
(DRAM)
Historically called random access memory because any data word accessed as easily as any other (in contrast to sequential access memories such as a tape recorder)
RAM:RandomAccessMemory
![Page 71: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/71.jpg)
Chapter5<71>
• Nonvolatile: retains data when power off• Read quickly, but writing is impossible or
slow• Flash memory in cameras, thumb drives, and
digital cameras are all ROMs
Historically called read only memory because ROMs were written at manufacturing time or by burning fuses. Once ROM was configured, it could not be written again. This is no longer the case for Flash memory and other types of ROMs.
ROM:ReadOnlyMemory
![Page 72: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/72.jpg)
Chapter5<72>
• DRAM (Dynamic random access memory)• SRAM (Static random access memory)• Differ in how they store data:
– DRAM uses a capacitor– SRAM uses cross-coupled inverters
TypesofRAM
![Page 73: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/73.jpg)
Chapter5<73>
• Invented DRAM in 1966 at IBM
• Others were skeptical that the idea would work
• By the mid-1970’s DRAM in virtually all computers
RobertDennard,1932-
![Page 74: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/74.jpg)
Chapter5<74>
stored bit
wordlinebitline
wordline
bitline
storedbit
• Data bits stored on capacitor• Dynamic because the value needs to be refreshed
(rewritten) periodically and after read:– Charge leakage from the capacitor degrades the value– Reading destroys the stored value
DRAM
![Page 75: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/75.jpg)
Chapter5<75>
wordline
bitline
wordline
bitline
+ +storedbit = 1
storedbit = 0
DRAM
![Page 76: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/76.jpg)
Chapter5<76>
stored bit
wordlinebitline
wordlinebitline bitline
SRAM
![Page 77: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/77.jpg)
Chapter5<77>
wordline311
10
2:4Decoder
Address
01
00
storedbit = 0wordline2
wordline1
wordline0
storedbit = 1
storedbit = 0
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
bitline2 bitline1 bitline0
Data2 Data1 Data0
2
wordlinebitline bitline
wordline
bitline
DRAMbitcell: SRAMbitcell:
MemoryArraysReview
![Page 78: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/78.jpg)
Chapter5<78>
11
10
2:4 Decoder
Address
Data0Data1Data2
01
00
2
wordline
bitline
wordline
bitline
bit cellcontaining 0
bit cellcontaining 1
ROM:DotNotation
![Page 79: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/79.jpg)
Chapter5<79>
• DevelopedmemoriesandhighspeedcircuitsatToshiba,1971-1994
• InventedFlashmemoryasanunauthorizedprojectpursuedduringnightsandweekendsinthelate1970’s
• Theprocessoferasingthememoryremindedhimoftheflashofacamera
• Toshibaslowtocommercializetheidea;Intelwasfirsttomarketin1988
• Flashhasgrownintoa$25billionperyearmarket
Fujio Masuoka,1944-
![Page 80: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/80.jpg)
Chapter5<80>
11
10
2:4 Decoder
Address
Data0Data1Data2
01
00
2
Address Data11100100
depth
0 1 01 0 01 1 00 1 1
width
ROMStorage
![Page 81: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/81.jpg)
Chapter5<81>
11
10
2:4 Decoder
Address
Data0Data1Data2
01
00
2 Data2 =A1 Å A0
Data1 =A1 +A0
Data0 =A1A0
ROMLogic
![Page 82: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/82.jpg)
Chapter5<82>
11
10
2:4Decoder
A, B
ZYX
01
00
2
Implement the following logic functions using a 22 × 3-bit ROM:
– X = AB– Y = A + B– Z = A B
Example:LogicwithROMs
![Page 83: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/83.jpg)
Chapter5<83>
11
10
2:4Decoder
A, B
ZYX
01
00
2
Implement the following logic functions using a 22 × 3-bit ROM:
– X = AB– Y = A + B– Z = A B
Example:LogicwithROMs
![Page 84: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/84.jpg)
Chapter5<84>
wordline311
10
2:4Decoder
Address
01
00
storedbit = 0wordline2
wordline1
wordline0
storedbit = 1
storedbit = 0
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
bitline2 bitline1 bitline0
Data2 Data1 Data0
2
Data2 =A1 Å A0
Data1 =A1 +A0
Data0 =A1A0
LogicwithAnyMemoryArray
![Page 85: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/85.jpg)
Chapter5<85>
Implement the following logic functions using a 22 × 3-bit memory array:
– X = AB– Y = A + B– Z = A B
LogicwithMemoryArrays
![Page 86: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/86.jpg)
Chapter5<86>
wordline311
10
2:4Decoder
A, B
01
00
storedbit = 1wordline2
wordline1
wordline0
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 1
storedbit = 1
storedbit = 0
storedbit = 1
storedbit = 0
storedbit = 0
storedbit = 0
storedbit = 0
bitline2 bitline1 bitline0
X Y Z
2
Implement the following logic functions using a 22 × 3-bit memory array:
– X = AB– Y = A + B– Z = A B
LogicwithMemoryArrays
![Page 87: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/87.jpg)
Chapter5<87>
storedbit = 1
storedbit = 0
00
01
2:4Decoder
A
storedbit = 0
bitline
storedbit = 0
Y
B
10
11
4-word x 1-bit Array
A B Y0 00 11 01 1
0001
TruthTable
A1
A0
Called lookup tables (LUTs): look up output at each input combination (address)
LogicwithMemoryArrays
![Page 88: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/88.jpg)
Chapter5<88>
A1
A3WD3
WE3
A2
CLK
Array
RD2RD1 M
MNN
NM
• Port: address/data pair• 3-ported memory
– 2 read ports (A1/RD1, A2/RD2)– 1 write port (A3/WD3, WE3 enables writing)
• Register file: small multi-ported memory
Multi-portedMemories
![Page 89: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/89.jpg)
Chapter5<89>
// 256 x 3 memory module with one read/write portmodule dmem( input logic clk, we,
input logic [7:0] a,input logic [2:0] wd,
output logic [2:0] rd);
logic [2:0] RAM[255:0];
assign rd = RAM[a];
always @(posedge clk)if (we)RAM[a] <= wd;
endmodule
SystemVerilog MemoryArrays
![Page 90: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/90.jpg)
Chapter5<90>
• PLAs (Programmable logic arrays)– AND array followed by OR array– Combinational logic only– Fixed internal connections
• FPGAs (Field programmable gate arrays)– Array of Logic Elements (LEs)– Combinational and sequential logic– Programmable internal connections
LogicArrays
![Page 91: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/91.jpg)
Chapter5<91>
X Y
A B C
AND ARRAY
OR ARRAY
ABC
AB
ABC
ANDARRAY
ORARRAY
Inputs
Outputs
ImplicantsN
M
P
• X = ABC + ABC• Y = AB
PLAs
![Page 92: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/92.jpg)
Chapter5<92>
ANDARRAY
ORARRAY
Inputs
Outputs
ImplicantsN
M
P
X Y
ABC
AB
ABC
A B C
AND ARRAY
OR ARRAY
PLAs:DotNotation
![Page 93: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/93.jpg)
Chapter5<93>
• Composed of:– LEs (Logic elements): perform logic– IOEs (Input/output elements): interface with outside
world– Programmable interconnection: connect LEs and
IOEs– Some FPGAs include other building blocks such as
multipliers and RAMs
FPGA:FieldProgrammableGateArray
![Page 94: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/94.jpg)
Chapter5<94>
GeneralFPGALayout
![Page 95: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/95.jpg)
Chapter5<95>
• Composed of:– LUTs (lookup tables): perform combinational logic– Flip-flops: perform sequential logic– Multiplexers: connect LUTs and flip-flops
LE:LogicElement
![Page 96: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/96.jpg)
Chapter5<96>
AlteraCycloneIVLE
![Page 97: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/97.jpg)
Chapter5<97>
• The Altera Cyclone IV LE has:– 1 four-input LUT – 1 registered output – 1 combinational output
AlteraCycloneIVLE
![Page 98: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/98.jpg)
Chapter5<98>
Show how to configure a Cyclone IV LE to perform the following functions:
– X = ABC + ABC– Y = AB
LEConfigurationExample
![Page 99: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/99.jpg)
Chapter5<99>
Show how to configure a Cyclone IV LE to perform the following functions:
– X = ABC + ABC– Y = AB
LEConfigurationExample
LUT output0 00 11 01 1
0100
data 20000
0 00 11 01 1
1111
0010
XXXXXXXX
data 1(A) (B) (C) (X)
data 1
0
AB0 Y
data 4data 3
data 2data 3data 4 LUT
data 1
0
ABC X
data 2data 3data 4 LUT
LUT output0101
0010
data 20011
XXXX
data 1(A) (B) (Y)
data 4data 3XXXX
LE 1
LE 2
![Page 100: Chapter 5pmadden/courses/cs120/Slides/DDCA_Ch5.pdf · Chapter 5 Digital Design and Computer Architecture, 2nd Edition Chapter 5 David Money Harris and Sarah L. Harris. Chapter](https://reader030.vdocuments.us/reader030/viewer/2022041018/5ecccdc934590767ee474243/html5/thumbnails/100.jpg)
Chapter5<100>
Using a CAD tool (such as Altera’s Quartus II)• Enter the design using schematic entry or an HDL• Simulate the design• Synthesize design and map it onto FPGA• Download the configuration onto the FPGA• Test the design
FPGADesignFlow