ADSD Fall2011 12 Multipliers
-
Upload
rehan-hafiz -
Category
Documents
-
view
226 -
download
0
Transcript of ADSD Fall2011 12 Multipliers
-
8/3/2019 ADSD Fall2011 12 Multipliers
1/32
Dr. Rehan Hafiz Lecture # 12
ADSD Fall 2011
-
8/3/2019 ADSD Fall2011 12 Multipliers
2/32
Course Website for ADSD Fall 2011
http://lms.nust.edu.pk/
2
Lectures: Tuesday @ 5:30-6:20 pm, Friday @ 6:30-7:20 pm
Contact: By appointment/EmailOffice: VISpro Lab above SEECS Library
Acknowledgement: Material from the following sources has been consulted/used in theseslides:1. [CIL] Advanced Digital Design with the Verilog HDL, M D. Ciletti2. [SHO] Digital Design of Signal Processing System by Dr Shoab A Khan3. [STV] Advanced FPGA Design, Steve Kilts4. Ercegovacs Book: Digital Arithmetic 20045. Dr. Shoab A Khans CASE Lectures on Advanced Digital System Design
Material/Slides from these slides CAN be used with following citing reference:
Dr. Rehan Hafiz: Advanced Digital System Design 2010
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/ -
8/3/2019 ADSD Fall2011 12 Multipliers
3/32
Lecture Overview
3
Last Lecture Multi-Operand Addition
This Lecture
Binary Multiplication
Signed/Unsigned Numbers
Architecture
Q format MultiplicationCorrection Vector
-
8/3/2019 ADSD Fall2011 12 Multipliers
4/32
Binary Multiplication
4
Addition of multiple terms
Sequential using a single adder
Combinational Logic using compression trees
[CIL]
-
8/3/2019 ADSD Fall2011 12 Multipliers
5/32
Sequential Multiplier-1
5
-
8/3/2019 ADSD Fall2011 12 Multipliers
6/32
How Right Shifting the Accumulator
Register helps ?6
If Multiplying bit is 1 ADD Multiplicand & Shift
If Multiplying bit is 0 Just Shift
http://www.parl.clemson.edu/~walt/ece327/mult.v
http://www.parl.clemson.edu/~walt/ece327/mult.vhttp://www.parl.clemson.edu/~walt/ece327/mult.v -
8/3/2019 ADSD Fall2011 12 Multipliers
7/32
Sequential Multiplier-2
7
-
8/3/2019 ADSD Fall2011 12 Multipliers
8/32
Sequential Multiplier-2
8
Can we furthersave a register
Add 0 or Add 1
-
8/3/2019 ADSD Fall2011 12 Multipliers
9/32
Sequential Multiplier-3
9
Make use of
Product Register
-
8/3/2019 ADSD Fall2011 12 Multipliers
10/32
Sequential Multiplier-3 Example
10
-
8/3/2019 ADSD Fall2011 12 Multipliers
11/32
Fractional Numbers
11
Multiplication of two numbers Qm.n & Qo.p
result into a product with Q(m+o).(n+p) bits.
Taking 2s complement of fractional number
Same as for usual integer binary numbers
Take Bitwise Complement
Add 1
-Dont Get Confused by Book Example
-
8/3/2019 ADSD Fall2011 12 Multipliers
12/32
Signed Number Multiplication
12
(Incorrect; result should be 1)
-
8/3/2019 ADSD Fall2011 12 Multipliers
13/32
13
Negative Multiplicand, Positive Multiplier
Sign Extend the Multiplicand equal to the product bits before the multiplication process
-
8/3/2019 ADSD Fall2011 12 Multipliers
14/32
14
Signed Multiplicand, Positive Multiplier[Fractional Number]
Align the bits & then forget about the fractional dot !
Sign Extend the Multiplicand equal to the product bits before the multiplication process
-
8/3/2019 ADSD Fall2011 12 Multipliers
15/32
15
Positive Multiplicand, Negative Multiplier
Sign Extend the Multiplier equal to Multiplicand bit
Last Partial Product needs to be subtracted OR Add 2s complement
-
8/3/2019 ADSD Fall2011 12 Multipliers
16/32
16
Positive Multiplicand, Signed Multiplier[Fractional Number]
Align the bits & then forget about the fractional dot !
Sign Extend the Multiplier equal to Multiplicand bit
Last Partial Product needs to be subtracted OR Add 2s complement
-
8/3/2019 ADSD Fall2011 12 Multipliers
17/32
17
Signed Multiplicand, Signed Multiplier
Sign Extend the Multiplier
Last Partial Product needs to be subtracted OR Add 2s complement
-
8/3/2019 ADSD Fall2011 12 Multipliers
18/32
18
Signed Negative Multiplicand, Signed Negative Multiplier(Fractional Number)
Align the bits & then forget about the fractional dot !
Sign Extend the Multiplier
Last Partial Product needs to be subtracted OR Add 2s complement
-
8/3/2019 ADSD Fall2011 12 Multipliers
19/32
Signed Multiplier
19
We can adjust the previous algorithm to work
with signed integers
make sure each shift is an arithmetic shift
right shift extend the sign bit (keep the MS bit the sameinstead of shifting in a 0).
-
8/3/2019 ADSD Fall2011 12 Multipliers
20/32
Example (-1 * -1)
20
P 0 0 0 0 1 0 1 1
Add 1 1 1 1
= 1 1 1 1 1 0 1 1
S 1 1 1 1 1 1 0 1
Add 1 1 1 1
= 1 1 1 0 1 1 0 1
S 1 1 1 1 0 1 1 0
Add 1 1 1 1
= 1 1 1 0 0 1 1 0S 1 1 1 1 0 0 1 1
Add(2s
)
0 0 0 1
= 0 0 0 0 0 0 1 1
S 0 0 0 0 0 0 1
At each addition Perform 4 bit
addition, Discard Carry out & Shift
Right while replicating MSB
-
8/3/2019 ADSD Fall2011 12 Multipliers
21/32
Example (-1 * -5) (1111*1011)
21
P 0 0 0 0 1 0 1 1
Add 1 1 1 1
= 1 1 1 1 1 0 1 1
S 1 1 1 1 1 1 0 1
Add 1 1 1 1
= 1 1 1 0 1 1 0 1
S 1 1 1 1 0 1 1 0
Add 0 0 0 0
= 1 1 1 1 0 1 1 0S 1 1 1 1 1 0 1 1
Add(2s
)
0 0 0 1
= 0 0 0 0 1 0 1 1
S 0 0 0 0 0 1 0 1
-
8/3/2019 ADSD Fall2011 12 Multipliers
22/32
Example (1 * -5) (0001*1011)
22
P 0 0 0 0 1 0 1 1
Add 0 0 0 1
= 1
S 1
Add 1
= 1 1
S 1 1
Add
= 1 1S 0 1 1
Add(2s
)
1 1 1 1
= 1 1 1 1 0 1 1
S 1 1 1 1 1 0 1 1
C l iti & i l
-
8/3/2019 ADSD Fall2011 12 Multipliers
23/32
Complexities & special cases
Sign Extension, 2c Complement23
Two things have to be done dynamically
Sign Extension
2s Complement
What can be done ?
Wh t d b t
-
8/3/2019 ADSD Fall2011 12 Multipliers
24/32
What can we do about
Sign Extension24
Rather than following a selective sign extension
for signed numbers we follow a common policy
for all (+ve & -ve) numbers
Policy Complement the sign bit
Always extend with ONEs
Add ONE to the sign bit
+
B is positive (S=0)
B=0 0 0 0 0 0 . 1 1 0 1 0 1 1B=1 1 1 1 1 0 . 1 1 0 1 0 1 1
0 0 0 0 0 0 . 1 1 0 1 0 1 1
1
B is negative (S=1)
B=1 1 1 1 1 1 . 1 1 0 1 0 1 1B=1 1 1 1 1 1 . 1 1 0 1 0 1 1
1 1 1 1 1 1 . 1 1 0 1 0 1 1
1+
-
8/3/2019 ADSD Fall2011 12 Multipliers
25/32
Example-Sign Extension
25
(.) (.) (.) (.)
(.) (.) (.) (.)
1 1 1 1 (.) (.) (.) (.)
1 1 1 (.) (.) (.) (.)1 1 (.) (.) (.) (.)
1 (.) (.) (.) (.)
1 1 1 1
Policy
Complement the sign bit
Add ONE to the sign bitAlways extend with ONEs
C d thi b t 2
-
8/3/2019 ADSD Fall2011 12 Multipliers
26/32
Can we do something about 2s
complement & its sign extension26
Do 2s Complement (.)(.)(.)(.)
1+
Than do Sign Extension
1(.)(.)(.)(.)
1 1+
So the MSB is complemented two times; first due to2s complement & secondly due to sign extension.
Since complement of complement is the original bit.
MSB needs not to be complemented
E l
-
8/3/2019 ADSD Fall2011 12 Multipliers
27/32
Example-
Sign Extension & 2s Complement27
(Carries) (.) (.) (.) (.)
(3) (2) (1) (1) (.) (.) (.) (.)
1 1 1 1 (.) (.) (.) (.)
1 1 1 (.) (.) (.) (.)
1 1 (.) (.) (.) (.)
1 (.) (.) (.) (.)
1 1 1 1
1
1 0 0 1 0 0 0 0
Exercise:
-2 * -2 or -2 *2
Correction Vector
for multiplication
of TWO 4-bit signednumbers
Due to 2s
complement
-
8/3/2019 ADSD Fall2011 12 Multipliers
28/32
2s Complement Example
28
1 1 1 0
(1) (1) (2) (2) 1 1 1 0
1 0 0 0
0 1 1 0
0 1 1 0
1 0 0 1
1 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0
-
8/3/2019 ADSD Fall2011 12 Multipliers
29/32
2s Complement Example
29
1 1 1 0
(1) (1) (2) (2) 1 1 1 0
1 0 0 0
0 1 1 0
0 1 1 0
1 0 0 1
1 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 Output
Add
-
8/3/2019 ADSD Fall2011 12 Multipliers
30/32
Correction Vector Examples
30
Discard the carries after the MSBNote the different Correction Vectors for +ve & -ve numbers
-
8/3/2019 ADSD Fall2011 12 Multipliers
31/32
Benefit of Correction Vector
31
Reduced Logic
Generalized Algorithms
Designing a Fast Multiplier
-
8/3/2019 ADSD Fall2011 12 Multipliers
32/32
Designing a Fast Multiplier
(Single Cycle Multiplication)32
Formation of PartialProducts
Sign extension ORGeneration of CorrectionVector
Addition of PP
Wallace/DadaCompression Tree
Final Addition using anyfast Ripple Carry Adder
Formation of PartialProducts
Addition of PartialProducts
(Reduction)
Final Addition Stage
MultiplicationMultiplier
Product