2024 Lecture5 Come321
2024 Lecture5 Come321
• Arithmetic Microoperations
• Logic Microoperations
• Shift Microoperations
Binary Adder C3 C2 C1 C0
FA FA FA FA
C4 S3 S2 S1 S0
Binary Adder-Subtractor
B3 A3 B2 A2 B1 A1 B0 A0
FA C3 FA C2 FA C1 FA C0
C4 S3 S2 S1 S0
Binary Incrementer A3 A2 A1 A0 1
x y x y x y x y
HA HA HA HA
C S C S C S C S
C4 S3 S2 S1 S0
ARITHMETIC CIRCUIT
Ai
0
Bi
1
4X1 Fi
MUX
2
3 Select
S1
S0
Function table
S1 S0 Output -operation
0 0 F=AB AND
0 1 F = AB OR
1 0 F=AB XOR
1 1 F = A’ Complement
APPLICATIONS OF LOGIC MICROOPERATIONS
• Selective-set AA+B
• Selective-complement AAB
• Selective-clear A A • B’
• Mask (Delete) AA•B
• Clear AAB
• Insert A (A • B) + C
• Compare AAB
• ...
SELECTIVE SET
1100 At
1010 B
1110 At+1 (A A + B)
1100 At
1010 B
0110 At+1 (A A B)
1100 At
1010 B
0100 At+1 (A A B’)
1100 At
1010 B
1000 At+1 (A A B)
• In a clear operation, if the bits in the same position in A and B are the
same, they are cleared in A, otherwise they are set in A
1100 At
1010 B
0110 At+1 (A A B)
INSERT OPERATION
• An insert operation is used to introduce a specific bit pattern into A register,
leaving the other bit positions unchanged
• This is done as
1. A mask operation to clear the desired bit positions, followed by
2. An OR operation to introduce the new bits into the desired positions
• Example
• Suppose you wanted to introduce 1010 into the low order four bits of A:
1101 1000 1011 0001 A (Original) 1101 1000
1011 1010 A (Desired)
Serial
input
• Examples:
• R2 shr R2
• R3 shl R3
CIRCULAR SHIFT
• In a circular shift the serial input is the bit that is shifted out of the other
end of the register.
sign
bit
Examples:
» R2 ashr R2
» R3 ashl R3
HARDWARE IMPLEMENTATION OF
SHIFT MICROOPERATIONS
S
MUX H0
0
1
A0
A1 S
MUX H1
0
A2 1
A3
S
MUX H2
0
1
S
MUX H3
0
1
Serial
input (IR)
ARITHMETIC LOGIC SHIFT
UNIT
Implementation
ARITHMETIC LOGIC SHIFT
UNIT Implementation
0 0 0 0 0 F=A Transfer A
0 0 0 0 1 F=A+1 Increment A
0 0 0 1 0 F=A+B Addition
0 0 0 1 1 F=A+B+1 Add with carry
0 0 1 0 0 F = A + B’ Subtract with borrow
0 0 1 0 1 F = A + B’+ 1 Subtraction
0 0 1 1 0 F=A-1 Decrement A
0 0 1 1 1 F=A Transfer A
0 1 0 0 X F=AB AND
0 1 0 1 X F = A B OR
0 1 1 0 X F=AB XOR
0 1 1 1 X F = A’ Complement A
S3
S2 C i
S1
S0
Di
ONE bit circuit
Arithmetic
Circuit
Select
0 4x1 F
C i+1 i
1 MUX
2
3
E i
Logic
Bi S3 S2 S1 S0 Cin Operation
Circuit
A 0 0 0 0 0 F=A
i 0 0 0 0 1 F=A+1
shr
A i-1 0 0 0 1 0 F=A+B
shl 0 0 0 1 1 F=A+B+1
A
i+1 0 0 1 0 0 F = A + B’
0 0 1 0 1 F = A + B’+ 1
0 0 1 1 0 F=A-1
0 0 1 1 1 F=A
0 1 0 0 X F=AB
0 1 0 1 X F = A B
0 1 1 0 X F=AB
0 1 1 1 X F = A’
1 0 X X X F = shr A
1 1 X X X F = shl A
References