Computer Architecture
Appendix B
Fall 2005 Department of Computer Science Kent State University
Computer Architecture Appendix B Fall 2005 Department of Computer - - PowerPoint PPT Presentation
Computer Architecture Appendix B Fall 2005 Department of Computer Science Kent State University Logic Values Logic '0' False, off, deasserted, low Logic '1' True, on, asserted, high Combinational vs. Sequential Logic is
Fall 2005 Department of Computer Science Kent State University
B A A B
The Bubble in front of the gate is an inverter.
The Bubble in front of the gate is an inverter.
Complete the Truth Table for the NAND and NOR Gates
Hint: Think of the AND and OR truth tables. The outputs for the NAND and NOR are inverted.
Combining Logic Gates
Add the boolean expressions at the output for each AND gate
A B Y C A•B B•C
Combining Logic Gates Next add the boolean expressions at the output for the OR gate
The Boolean expression for the complete logic circuit is: Y = (A•B)+(B•C)
B•C A B Y C A•B (A•B) + (B•C)
Combining Logic: Truth Table Given : Y = (A•B)+(B•C)
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Y C B A
Laws of Boolean Algebra , Babbage(B.3,pB6)
· Identity law: A + 0 = A and A • 1 = A · Zero and One laws: A + 1 = 1 and A • 0 = 0 · Inverse Laws: A + A = 1 and A • A = 0 · Commutative laws: A + B = B + A and A • B = B • A (switch inputs) · Associative laws: A + (B + C) = (A + B) + C and A • (B • C) = (A • B) • C (reorder inputs) · Distributive laws: A • (B + C) = (A • B) + (A • C) and A + (B • C) = (A + B) • (A + C) _____ __ __ · De Morgan’s laws: (A + B) = (A) • (B) and _____ __ __ (A • B) = (A) + (B) (invert inputs)
each combination of its n inputs
interpreted as an n-bit binary number
and 2n outputs is called a n-to-2n decoder (eg, a 3-to- 8 decoder)
Out0 Out1 Out2 Out3 Out4 Out5 Out6 Out7 Decoder
3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
i0 i1 i2 Outputs Inputs
1 A C B S M u x C A B S
value of its n selector inputs, to become its output
number
(eg, a 4-to-1 multiplexer)
M u x Select 32 A 32 B 32 C M u x Select A31 B31 C31 M u x A30 B30 C30 M u x A0 B0 C0
an array of 32 1-bit multiplexors
= = = =
26
2004 Morgan Kaufmann Publishers
Output D is true if at least one input is true Output E is true if exactly two inputs are true Output F is true only if all three inputs are true
27
2004 Morgan Kaufmann Publishers
32 32 32
result a b
ALU
28
2004 Morgan Kaufmann Publishers
– we'll just build a 1 bit ALU, and use 32 of them
b a
result
b res
29
2004 Morgan Kaufmann Publishers
S C A B
1
note: we call this a 2-input mux even though it has 3 inputs!
30
2004 Morgan Kaufmann Publishers
– Don't want too many inputs to a single gate – Don’t want to have to go through too many gates – for our purposes, ease of comprehension is important
cout = a b + a cin + b cin sum = a xor b xor cin
Sum CarryIn CarryOut a b
31
2004 Morgan Kaufmann Publishers
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
i0 i1 i2 Outputs Inputs
32
2004 Morgan Kaufmann Publishers
b 2 Result Operation a 1 CarryIn CarryOut
Result31 a31 b31 Result0 CarryIn a0 b0 Result1 a1 b1 Result2 a2 b2 Operation ALU0 CarryIn CarryOut ALU1 CarryIn CarryOut ALU2 CarryIn CarryOut ALU31 CarryIn
33
2004 Morgan Kaufmann Publishers
2 Result Operation a 1 CarryIn CarryOut 1 Binvert b
34
2004 Morgan Kaufmann Publishers
Binvert a b CarryIn CarryOut Operation 1 2 + Result 1 Ainvert 1
35
2004 Morgan Kaufmann Publishers
– remember: slt is an arithmetic instruction – produces a 1 if rs < rt and 0 otherwise – use subtraction: (a-b) < 0 implies a < b
– use subtraction: (a-b) = 0 implies a = b
36
2004 Morgan Kaufmann Publishers
Binvert a b CarryIn CarryOut Operation 1 2 + Result 1 Ainvert 1 3 Less Binvert a b CarryIn Operation 1 2 + Result 1 3 Less Overflow detection Set Overflow Ainvert 1
Use this ALU for most significant bit all other bits
a0 Operation CarryIn ALU0 Less CarryOut b0 CarryIn a1 CarryIn ALU1 Less CarryOut b1 Result0 Result1 a2 CarryIn ALU2 Less CarryOut b2 a31 CarryIn ALU31 Less b31 Result2 Result31 . . . . . . . . . Binvert Ainvert Overflow Set CarryIn
38
2004 Morgan Kaufmann Publishers
0000 = and 0001 = or 0010 = add 0110 = subtract 0111 = slt 1100 = NOR
a0 Operation CarryIn ALU0 Less CarryOut b0 a1 CarryIn ALU1 Less CarryOut b1 Result0 Result1 a2 CarryIn ALU2 Less CarryOut b2 a31 CarryIn ALU31 Less b31 Result2 Result31 . . . . . . . . . Bnegate Ainvert Overflow Set CarryIn . . . . . . Zero
39
2004 Morgan Kaufmann Publishers
– key idea: use multiplexor to select the output we want – we can efficiently perform subtraction using two’s complement – we can replicate a 1-bit ALU to produce a 32-bit ALU
– all of the gates are always working – the speed of a gate is affected by the number of inputs to the gate – the speed of a circuit is affected by the number of gates in series (on the “critical path” or the “deepest level of logic”)
– Clever changes to organization can improve performance (similar to using better algorithms in software) – We saw this in multiplication, let’s look at addition now
40
2004 Morgan Kaufmann Publishers
allow designers to completely automate the creation of hardware!
Clock period Rising edge Falling edge
R S Q Q
D C Q
Q C D _ Q
D C Q
Read register number 1 Read data 1 Read data 2 Read register number 2
Register file
Write register Write data Write
M u x Register 0 Register 1 Register n – 1 Register n M u x Read data 1 Read data 2 Read register number 1 Read register number 2
n-to-1 decoder Register 0 Register 1 Register n – 1 C C D D Register n C C D D Register number Write Register data 1 n – 1 n
Clock cycle State element 1 Combinational logic State element 2
State element Combinational logic
edge (setup time) and after (hold time)
D C Set-up time Hold time
Recall:
1000ten X 1001ten 1000
0000
0000 1000 1001000ten
Observations
More storage required to store the product
Place copy of multiplicand in proper location if multiplier is a 1
Place 0 in proper location if multiplier is 0
Product of n-bit Multiplicand and m-Multiplier is (n + m)-bit long
Number of steps (move digits to LHS) is n -1; where n rep the number of digits (1,0)
Let's examine 2 versions of multiplication algorithm for binary numbers
Multiplicand Multiplier Product
Multiplicand Shift left 64 bits 64-bit ALU Product Write 64 bits Control test Multiplier Shift right 32 bits
32nd repetition?
place the result in Product register Multiplier0 = 0
Multiplier0 Start Multiplier0 = 1
No: < 32 repetitions Yes: 32 repetitions Done
Datapath Control
Multiplicand 32 bits 32-bit ALU Product Write 64 bits Control test Shift right
32nd repetition? Product0 = 0
Product0 Start Product0 = 1
No: < 32 repetitions Yes: 32 repetitions Done
Add multiplicand to product and place the result in ?