Professional Documents
Culture Documents
CSE 332 L3 - 16 & 18 July 2020 PDF
CSE 332 L3 - 16 & 18 July 2020 PDF
CSE 332 L3 - 16 & 18 July 2020 PDF
1
Recap from Lesson 2 -
•ALU Design
• Designing a Simple 1-bit ALU
2
Incorporating NOR and NAND
3
Recap from Lesson 2 -
4
Recap from Lesson 2 -
5
6
LESSON 3, SESSION 1
Arithmetic & Logic Unit – PART 2
Source:
https://sites.google.com/site/neuro11school/lect
ALU Control
• Plan to control ALU: main control sends a 2-bit control field (A and B invert)
to the ALU control. Based on ALUOp and funct field of instruction the ALU
control generates the 3-bit ALU control field
3
Ainvert To
Main Binvert ALU
ALU ALU
Control Control
control
input
??
MIPS Instruction
function field, Fx
Implementation: ALU Control Block
ALUOp Funct field, Fx Operation
Binvert Ainvert F5 F4 F3 F2 F1 F0
0 0 0 0 010 (add)
1 0 X 0 110 (sub)
1 1 X 0 (nand)
1 1 X 0 (nor)
0 0 0 1 000 (and)
0 0 1 0 001 (or)
0 0 1 1 111 (SLT)
ALUOp
ALU control block
ALUOp0
ALUOp1
Operation2
F3
Operation
F2 Operation1
F (5– 0)
F1
Operation0
F0
Introduction
11
LESSON 3, SESSION 3
Arithmetic & Logic Unit – PART 2
Source:
https://sites.google.com/site/neuro11school/lect
Multiplication
Multiplicand 421
Multiplying two 3-digit numbers A and B
Multiplier x 123
1263
842 n partial products, where B is n digits long
+ 421
51783 n - 1 additions
In Binary... 6x5
110
Each partial product is either: x 101
110 (A*1) or 000 (A*0)
110
000
+ 110 Equals 30
Note: Product may take as many
as two times the number of bits! 11110
13
Multiply
Key observations:
Multiplicand 1000
m bits x n bits = m+n bit product Multiplier 1001
(m+n bits required to represent all possible products) x 1000
There are only two possibilities in every
0000
steps 0000
If multiplier bit = 1 1000
copy multiplicand (1 x multiplicand) Product 01001000
If multiplier bit = 0
place 0 (0 x multiplicand)
Need an adder unit (use ALU?) to add
Multiply Q - Can you write an algorithm ?
In text, C, Java, flow chart whatever
Yes: 32 repetitions
Done
Shift-add Multiplier
Observations on Multiply
• 1 step per clock cycle ⇒ nearly 100 clock cycles to multiply two
32-bit numbers
• Half the bits in the multiplicand register always 0
⇒ 64-bit adder is wasted
• 0’s inserted to right as multiplicand is shifted left
⇒ least significant bits of product never
change once formed
• Fast Multiplication
products
previous step.
– Question?
19
Divide by 2N using shift register
Introduction
20
Quiz 1
Introduction
21
END OF LESSON 3
Introduction
22