Title: CoE EE 00142 Computer Organization Set 3 Multiplication and Division
1CoE - EE 00142Computer OrganizationSet 3
Multiplication and Division
2ALU Block Diagram
Normally, the accumulator has logical and
arithmetic shift capability, both left and right
3Another Symbol for ALU
4Binary Multiply
Binary
Decimal
5Simultaneous Multiplication
6Equations
- P0 X0Y0
- P1 (X0Y1) add to (X1Y0)
- use half adder
- P2 (X0Y2) add to (X1Y1) add to (X2y0) add to
Cin - use half adder full adder
- P3 etc.
7Simultaneous Multiplier
8Multiplication Example
- 1011 Multiplicand (11 dec)
- x 1101 Multiplier (13 dec)
- 1011 Partial products
- 0000 Note if multiplier bit is 1 copy
- 1011 multiplicand (place value)
- 1011 otherwise zero
- 10001111 Product (143 dec)
- Note need double length result
9Binary Multiplication Example
10Example Multiply Algorithm
Multiplicand 0100 4 Multiplier 0101 5 20
11Example using AU-AL Lft Shft
12Example Hardware
Multiplicand left - Multiplier right - PP
stationary
13(No Transcript)
14(No Transcript)
15(No Transcript)
16Multiplicand stationary - Multiplier right - PP
right
17Multiplicand stationary - Multiplier right - PP
right
18Example (3 x 2)
19Another Example - Right Shift
0
0
1
20Multiplying Negative Numbers
- This does not work as is
- Solution
- Convert to positive if required
- Multiply as above
- If signs were different, negate answer
- Use Booths algorithm
21Booths Algorithm
- Designed to improve speed by using fewer adds
- Works best on strings of 1s
- Example premise
- 7 8 1
- 0111 1000 0001 (3 adds vs 1 add 1 sub)
- Algorithm modified to allow for multiplication
with negative numbers
22Multiply in MIPS
23Hardware - Software
- Some compilers replace constants with a series of
shifts, add, and subtracts - Particularly valuable when multiplying by a power
of 2
24Division
- More complex than multiplication
- Negative numbers are really bad
- Based on long division
25Long Hand Division
013
11
147
11
037
Partial Remainders
33
4
26Division of Unsigned Binary Integers
Quotient
00001101
1011
10010011
Divisor
Dividend
1011
001110
Partial Remainders
1011
001111
1011
Remainder
100
27Long Division
28Long Division
29Long Division
30Long Division
31Long Division
32Division Algorithm
33Division Algorithm
34Divide Example
15 - 01111 divided by 5 - 00101
35Long Hand Division Hardware
36Long Hand Division Hardware Algorithm
37Realistic Division Hardware
38Realistic Division Hardware Algorithm
39Divide in MIPS
40Hardware Control Aspects
- How do we create the control within the ALU
- Use examples from 0132 text
41Unsigned Binary Multiplication
42Consider Multiplier Schematic
43Execution of Example
44Binary Multiplier Block Diagram
Figure 8-6 Page 368
45Algorithmic State Machine
Figure 8-1 Page 362
46ASM Block Example
Figure 8-2 Page 363
47Binary Multiplier ASM Chart
Figure 8-7 Page 369
48Binary Multiplier Sequencing
Figure 8-8 Page 372
49Implementation Mechanisms
Algorithmic State Machine ASM
50Binary Multiplier Block Diagram
Figure 8-6 Page 368
51Control Signals
Table 8-1 Page 371
52Multiplier Control Unit
Go
LSB of Multiplier
Figure 8-9 Page 375
53Microprogrammed Control Unit
Figure 8-12 Page 379
54Example Microinstruction
Typically in ROM Each Cn bit is a control
line Nxt is next address, depending on decision
55Floating Point Operations
- Review of IEEE Floating Point
- How would we implement?
- Example flowcharts for
- Addition/Subtraction
- Multiplication
- Division
56Real Numbers
- Numbers with fractions
- Could be done in pure binary
- 1001.1010 24 20 2-1 2-3 9.625
- Fixed point
- Very limited
- Moving or floating point
- How do you show where binary point is
57Floating Point
- (/-) x 1.significand x 2(exponent-127)
- Exponent indicates position of binary point
58Normalization
- FP numbers are usually normalized
- i.e. exponent is adjusted so that leading bit
(MSB) of mantissa is 1 - Example - Scientific notation where numbers are
normalized to give a single digit before the
decimal point - e.g. 3.123 x 103
- Because it is always 1, there is no need to store
it
59FP Ranges
- For a 32 bit number
- 8 bit exponent
- /- 2256 ? 1.5 x 1077
- Accuracy
- The effect of changing lsb of mantissa
- 23 bit mantissa 2-23 ? 1.2 x 10-7
- About 6 decimal places
60IEEE Standard 754
- Standard for floating point storage
- 32 and 64 bit standards
- 8 and 11 bit exponent respectively
- Extended formats (both mantissa and exponent) for
intermediate results
61Floating Point Arithmetic
- Addition Subtraction
- Must align binary points
- e.g. adjust exponents
- Multiplication Division
- Add/sub unbiased exponents
- e.g. adjust exponents
- Normalize the results
62FP Addition - Subtraction
63FP Addition Algorithm
64FP Addition Hardware
65FP Arithmetic x/?
- Check for zero
- Add/subtract exponents
- Multiply/divide significands
- watch sign
- Normalize
- Round
- Double length intermediate results
66FP Multiply Flowchart
67FP Multiplication Algorithm
68FP Divide Flowchart
69End of Set 3