Professional Documents
Culture Documents
Electrical and Computer Engineering Computer Organization and Architecture CSE 332 Credits - 3 Prerequisites: CSE 231 Digital Logic Design
Electrical and Computer Engineering Computer Organization and Architecture CSE 332 Credits - 3 Prerequisites: CSE 231 Digital Logic Design
1
LESSON 3, SESSION 1
Arithmetic & Logic Unit – PART 2
Source:
https://sites.google.com/site/neuro11school/lect
From Lesson 2 -
•ALU Design
• Designing a Simple 1-bit ALU
3
Incorporating Subtraction, NOR and NAND
ALU
4
ALU Control
• Plan to control ALU: main control sends a 2-bit control field (A and B invert)
to the ALU control. Based on them and a function field (from MIPS)
instruction the ALU control generates the 3-bit ALU operation.
3
Ainvert To
Main Binvert ALU
ALU ALU
Control Control
control
input ALUop
??
MIPS Instruction
function field, Fx
Implementation: ALU Control Block
Ainvert
Binvert
TT for ALU Control: 3
ALU Ctrl
Fx
Inputs Outputs
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 011 (nand)
1 1 X 1 100 (nor)
0 0 0 1 000 (and)
0 0 1 0 001 (or)
0 0 1 1 111 (SLT)
Classwork 1: Develop ALU control logic and circuit using k-map (4 marks)?
Homework 1: Develop ALU control logic and circuit using QM method (4 marks)?
Implementation: ALU Control Block
Ainvert
Binvert
TT for ALU Control: 3
ALU Ctrl
Fx
Inputs Outputs
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 011 (nand)
1 1 X 1 100 (nor)
0 0 0 1 000 (and)
0 0 1 0 001 (or)
0 0 1 1 111 (SLT)
Classwork 1: Develop ALU control logic and circuit using k-map (4 marks)?
Homework 1: Develop ALU control logic and circuit using QM method (4 marks)?
Implementation: ALU Control Block
Ainvert
Binvert
TT for ALU Control: 3
ALU Ctrl
Fx
Inputs Outputs
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 011 (nand)
1 1 X 1 100 (nor)
0 0 0 1 000 (and)
0 0 1 0 001 (or)
0 0 1 1 111 (SLT)
Classwork 1: Develop ALU control logic and circuit using k-map (4 marks)?
Homework 1: Develop ALU control logic and circuit using QM method (4 marks)?
Complete Implementation: ALU Control Block
ALUOp Funct field Operation
ALUOp1 ALUOp0 F5 F4 F3 F2 F1 F0
0 0 X X X X X X 010
0* 1 X X X X X X 110 *Typo in text
1 X X X 0 0 0 0 010 Fig. 5.15: if it is X
1 X X X 0 0 1 0 110 then there is potential
conflict between
1 X X X 0 1 0 0 000 line 2 and lines 3-7!
1 X X X 0 1 0 1 001
1 X X X 1 0 1 0 111
Truth table for ALU control bits
ALUOp
ALU control block
ALUOp0
ALUOp1
Operation2
F3
Operation
F2 Operation1
F (5– 0)
F1
Operation0
F0
Introduction
10
END OF LESSON 3 SESSION 1
11
LESSON 3, SESSION 2
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
14
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
products
previous step.
ADD
– Question?
20
Divide by 2N using shift register
A/ 2N
A =10101110
ALS1 =01011100 =A/2
ALS2 =10111000=A/4
Introduction
21
END OF LESSON 3
Introduction
22
Final reminder on Quiz 1
Introduction
23