Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Binary Multiplication
147 * 85 10010011 Multiplicand * 01010101 Multiplier 10010011 00000000 10010011 00000000 10010011 00000000 10010011 00000000 011000011001111 Product
12495
Multiplier0 = 0
1a. Add multiplicand to product & place the result in Product register
Yes: 64 repetitions
Done
Computer Architecture Project
Multiplication Hardware 1
32-bit multiplicand
64 bits
Shift_left
lsb
32-bit product 32 bits Write Control
Multiplication Hardware
Product: initialized to all 0s Control: decides when to shift the Multiplier and Multiplicand registers and when to write new values to Product register At the end, the multiplier is out of the product register and the product contains the result
For Version 1:
Product = 0
1a. Add multiplicand to the left half of product & place the result in the left half of Product register
Yes: 64 repetitions
Done
Computer Architecture Project
For FinalVersion :
Multiplication Hardware(Final)
multiplicand
16 bits
Shift_left
16-bit ALU
product 32 bits
Multiply in MIPS
Can
multiply variable by any constant using MIPS sll and add instructions: i' = i * 10; /* assume i: $s0 */
sll $t0, $s0, 3 # i * 23 add $t1, $zero, $t0 sll $t0, $s0, 1 # i * 21 add $s0, $t1, $t0
MIPS mult
$t0, $t1 puts 64-bit product in pair of new registers hi, lo; copy to $n by mfhi, mflo 32-bit integer result in register lo
Computer Architecture Project
For Example:
0110 x 0011 (6x3) This can be done by (8- 2) x3 as well, or (1000 - 0010) x 0011 (using 8 bit words) At start, product = 00000000, looking at each bit of the multiplier 0110, from right to left: 0: product unchanged: 00000000 , shift multiplicand left: 00110 1: start of a sequence: subtract multiplicand from product: 00000000 - 00110 = 11111010 , shift multiplicand left: 001100 1: middle of sequence, product unchanged: 11111010, shift multiplicand left: 0011000
0: end of sequence:
add multiplicand to product: 11111010 + 0011000 = 00010010 = 18 shift multiplicand left: 00110000
Computer Architecture Project
Booths Algorithm
Scan the multiplier from right to left, observing, at each step, both the current bit and the previous bit: 1. Depending on (current, previous) bits: 00 : Middle of a string of 0s: do no arithmetic operation. 10 : Beginning of a string of 1s: subtract multiplicand.
Integer Division
(10) 0001 1001 0000 1010 divided into 1111 1010 -1010 1011 -1010 10 101 1010 -1010 quotient (25) dividend (250)
0 remainder
Computer Architecture Project
Division Algorithm 1
2a. Shift the Quotient register to the left setting the new rightmost bit to 1.
Start: Place Dividend in Remainder 1. Subtract the Divisor register from the Remainder register, and place the result in the Remainder register.
Remainder 0
Test Remainder
Remainder < 0
2b. Restore the original value by adding the Divisor register to the Remainder register, & place the sum in the Remainder register. Also shift the Quotient register to the left, setting the new least significant bit to 0.
3. Shift the Divisor register right 1 bit. n+1 repetition? No: < n+1 repetitions
Division Hardware
Shift Right
Divisor
16 bits
Quotient 16-bit ALU 8 bits Write Control
Shift Left
Remainder
16 bits
Integer Division
ALU,
Divisor, and Remainder registers: 16 bit; Quotient register: 8 bits; 8 bit divisor starts in left of Divisor reg. and it is shifted right 1 on each step Remainder register initialized with dividend
For Version 1:
Remainder 0
Test Remainder
Remainder < 0
3a. Shift the Remainder register to the left setting the new rightmost bit to 1.
3b. Restore the original value by adding the Divisor register to the left half of Remainder register, & place the sum in the left half of Remainder register. Also shift the Remainder register to the left, setting the new rightmost bit to 0.
n repetition?
Yes: n repetitions (n = 8 here) Done. Shift left half of Remainder right 1 bit
Computer Architecture Project
Divisor
8 bits
8-bit ALU Shift Right Remainder Write Control Test Shift Left
16 bits
Mult/Div Hardware
Divisor/multiplicand
8 bits
Carryout of adder 8-bit ALU
alu_control
Top half
Control
16 bits
Result/lsb msb