COMP411 alu design

Computer Organization
Brent C. Munsell
ALU Circuit Design Add, Subtract, Shift, and Logic Operations

• Announcements (~ 5 mins)
• No Poll Everywhere
• Quickly finish common circuit design (~25 mins)
• Add/Subtract
(~45 mins)

Announcements
• Release Lab 1 tomorrow (9/8) • 7 segment display circuit design • think you’ll really like
• Great job on Lab 0
• Quiz 1 (see schedule, Canvas announcement)
程序代写 CS代考 加QQ: 749389476
Add and Subtract
Combinational Logic Circuit Design

Binary Addition
Not a single operation
• A + B = Sum and Carry-out
• A, B, Sum (S) and Carry-out (Co) are one bit binary values
Four possibilities (A and B):

Binary Half Adder Circuit Design
Two input bits:
• AandB:1biteach
Two output bits:
• CandS:1biteach
S=𝐴⨁𝐵=𝐴𝐵’+ 𝐴̅𝐵
What is missing?

Binary Full Adder Circuit Design
Three input bits:
• Cin, A, B: 1 bit each
Two output bits:
• Co andS:1biteach
Co =Ci (A+B)+AB =Ci (A⊕B)+AB S=Ci ⊕A⊕B

Full Adder Circuit
Two HA circuits plus one or gate
Schematic Diag.
AB CO FA CI S

Binary Addition Component
circuits, extend to arbitrary # of bits
CO CI A FA B
CO CI A FA B
CO CI A FA B
SnSn-1 S2 S1 S0
GND (Logic 0)
Carry Adder”
carries ripple through from right to left
longest chain of carries has length
Not the most efficient design, why?
CO CI A FA B

Binary Addition/Subtract Component (4-bit Example)
Subtract A
s complement:
B: 2’s complement Operation
~ = bit-wise complement
B = ~B + 1
B3 B2 B1 B0
A3 A2 A1 A0 􏰀+1􏰁?
But what about the
control bit = 0: Add control bit = 1: Subtract
S4 S3 S2 S1 S0
We’ll see how this is used very soon!
control bit
AB CO FA CI S
AB CO FA CI S
AB CO FA CI S
AB CO FA CI S

Bit Shift Circuit
Shift right and left

Shift Operations: Overview Left Shift: shifts in a 0 from the right end
• (X<<1)=0010100 “Logic” Right Shift: shifts in a 0 from the left end “Arithmetic” Right Shift: maintains the sign bit = 00010100 >>> 1) = (11101100
= 2’s complement of X = 11101100
• shiftrightarithmeticnotation(>>>) • shiftrightlogicnotation(>>)

Bit Shift Component Design
Example Shift Left Circuit If SLL1 is true (logic 1)
Shifts the input X one bit to
the left X4
Schematic Diag.
0RX7 R7 16X6 R6 X5 R5
Shift Left One Logical
R5 R4 R3 R2 R1 R0
X X3 X2 X X0
If SLL1 is false (logic 0) X2
X << 1 X3 Do not shift X X1 Shift by other amounts Shift left by 2 X7 Rewire the multiplexors so each X feeds into R i+2 6 Similarly: shift left by 4, etc. X5 Shift right circuits have similar circuitry X4 01 R4 X3 01 R3 shift right logical: each X into a lower numbered shift right arithmetic: sign bit X12 stays the same 5-bit Shift Left Circuit Make five shift components: SLL1, SLL2, SLL4, SLL8, SLL16 Any arbitrary shift amount can be made by combining these shifts Example: SLL13=SLL(8+4+1) shift left by 16 shift left by 8 shift left by 4 shift left by 2 shift left by 1 SLL16 SLL8 SLL4 SLL2 SLL1 shift amount 13 = 01101 in binary! Logic Circuit Bitwise AND, OR, XOR, NOR Boolean Logic Boolean component to perform bit • AND (Y=AB) • OR(Y=A+B) wise logic operations • inputs A, B are only one bit! • outputYisalsoonebit! Code Help
Logic Component Design
Schematic Diag.
1-bit Logic Component
Four gates and MUX to select the logic operation
bit MUX (2 Bool Bits = Supports 4 logic operations!
Select Bits)
Input bits:
A and B: 1 bit each
Bool: 2 bits Bool
Output bits:
00 01 10 11
How many of logic components are needed for a n-bit design?

Control and Datapath
AND operation • Bool bits: 00
OR operation
• Bool bits: 01
XOR operation • Bool bits: 10
NOR operation • Bool bits: 11
00 01 10 11 Bool

Arithmetic and Logic Unit
CS Help, Email: tutorcs@163.com
One component that performs
• Logic operations
• Arithmetic
(Add/Subtract)
operations Sub
• Bit shift operations Schematic
Bidirectional Shifter

Inputs and Output
Inputs to ALU
• A, B: n-bits each • 5 functions bits
• Sub: 1 bit
• Bool: 2 bits
• Shft: 1 bit
• Math: 1 bit
Bidirectional Shifter
Output of ALU
• Result: n-bits

ALU Function Table
Configure ALU: 5 function bits
Bidirectional Shifter
X = don’t care could be 0 or 1
5-bit ALUFN
Sub Bool Shft Math OP 0XXX 1 A+B 1XXX 1 A-B X001 0 B<>A X111 0 B>>>A X 00 0 0 A&B X 01 0 0 A|B X 10 0 0 A^B X 11 0 0 A|B

Bidirectional Shifter
5-bit ALUFN
Sub Bool Shft Math OP
Red = Data Path
Green = Configuration
0XXX 1XXX X001 X101 X111 X 00 0 X 01 0 X 10 0 X 11 0
1 A+B 1 A-B 0 B<
>A 0 B>>>A 0 A&B 0 A|B 0 A^B 0 A|B

Bidirectional Shifter
5-bit ALUFN
Sub Bool Shft Math OP 0XXX 1 A+B 1XXX 1 A-B X001 0 B<
>A
Red = Data Path Green = Configuration
X 00 0 0 A&B X 01 0 0 A|B X 10 0 0 A^B X 11 0 0 A|B