Call Girls Chickpet ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Shifter and Multiplier
1. ECE2030
Introduction to Computer Engineering
Lecture 13: Building Blocks for Combinational
Logic (4) Shifters, Multipliers
Prof. Hsien-Hsin Sean LeeProf. Hsien-Hsin Sean Lee
School of Electrical and Computer EngineeringSchool of Electrical and Computer Engineering
Georgia TechGeorgia Tech
2. Basic Shifting
• Shift directions
– Left (multiply by 2)
– Right (divide by 2)
•Take floor value if the result is not an integer
•Floor value of XX (or X) is the greatest integer number
less than or equal to X,X, E.g.
5/2 = 2
-3/2 = -2
• Shift types
– Logical (or unsigned)
– Arithmetic (or signed)
3. Logical Shift
• Shift Left
– MSB: Shifted out
– LSB: Shifted in with a “0”
– Examples:
• (11001011 << 1) = 10010110
• (11001011 << 3) = 01011000
• Shift right
– MSB: Shifted in with a “0”
– LSB: Shifted out
– Examples: (Some ISA use triple “>” for logical right shift)
• (11001011 >>> 1) = 01100101
• (11001011 >>> 3) = 00011001
4. Arithmetic Shift
• Shift left
– MSB: Shifted out, however, be aware of
overflow/underflow
– LSB: Shifted in with a “0”
– Examples:
• (1100 << 1) = 1000
• (1100 << 3) = 0000 (Incorrect!) ⇒ Underflow
• Shift right
– MSB: Retain “sign bit”
– LSB: Shifted out
– Examples:
• (1100 >> 1) = 1110 (Retain sign bit)
• (1100 >> 3) = 1111 ( -4/8 = -1 ) ⇒ Floor value of -0.5
5. Examples of Arithmetic Shift
1111 1011 Arithmetic shift right by 1
→ 1111 1101
1111 1011 Arithmetic shift left by 1
→ 1111 0110
1011 1111 (= -65) Arithmetic shift left by 1 (i.e. x2)
→ 0111 1110 (= +126 ≠ -130) ⇒ Underflow !
0100 0010 (= +66) Arithmetic shift left by 1 (i.e. x2)
→ 1000 0100 (= -124 ≠ +132) ⇒ Overflow !
Overflow/Underflow
19. Unsigned Integer Multiplier (2-bit)
s
00100111
1011
0001
01
01
babababa
baba
baba
bbx
aa
+
2-bit by 2-bit
carrycarry out
p0
a0b0
H.A.
p1
c
s
a1b0a0b1
H.A.c
s
p2p3
a1b1
20. Unsigned Integer Multiplier (3-bit)
bababa
bababa
bababa
bbbx
aaa
202122
101112
000102
012
012
3-bit by 3-bit
p0
a0b0
s
F.A.
p1
a1b0a0b1
0
co
s
ci
c
F.A.
p2
s
a2b0a1b1
co
s
ci
c
F.A.
s
co
s
ci
a0b2
00
c
F.A.
p3
a2b1
co
s
ci
c
F.A.co
s
ci
a1b2
0
s
s
s
c
p4
c
F.A.co
s
ci
a2b2
p5
25. Signed Binary Multiply
When the Multiplicand is negativeWhen the Multiplicand is negative
11101 (-3)
01001 (+9)
--------------------
11111101
00
11101
--------------------
11100101
Maintain the sign bits of the
partial product
26. Signed Binary Multiply
When the Multiplier is negativeWhen the Multiplier is negative
01001 (+9)
11101 (-3)
--------------------
01001
01001
--------------------
0101101
01001
--------------------
01110101
10111
--------------------
111100101 (-27)
At the last step, 2’s complement
the multiplicand before adding
27. Signed Binary Multiply
When both the Multiplicand and Multiplier are negativeWhen both the Multiplicand and Multiplier are negative
10111 (-9)
11101 (-3)
--------------------
1110111
10111
--------------------
11010011
10111
--------------------
110001011
01001
--------------------
000011011(+27)
At the last step, 2’s complement
the multiplicand before adding
Maintain the sign bits of the
partial product