150 likes | 267 Vues
This lab covers fundamental arithmetic operations related to unsigned and signed multiplication and division within the context of computer architecture. It includes techniques such as shift multiplicand left for unsigned multiplication, Booth's algorithm for signed multiplication, and restoring and non-restoring division methods. Each operation is illustrated with examples using 4-bit and 8-bit registers, emphasizing the efficiency and space considerations in computation. The lab aims to provide hands-on experience in the implementation of these critical arithmetic algorithms and their significance in computer systems.
E N D
Csci136 Computer Architecture IILab#6 Arithmetic Operations HW #5: Due on Mar. 1, before classFeb.23, 2005
Unsigned Multiplication- Shift Multiplicand Left • Example: • 4-bit register • 0010*0011 • Multiplicand: 8 bits • Multiplier: 4 bits • Product: 8 bits
Unsigned Multiplication- Shift Multiplicand Left • Initial • Prod+Mcand • Mcand • Mier • Cost ??? • Time • Space
Unsigned Multiplication- Shift Product Right • Observations: • Work on one bit each time • 1/2 bits in multiplicand always 0 • least significant bits of product never changed once formed • Save Space? • Example: • 4-bit register • 0010*0011 • Multiplicand: 4 bits • Multiplier: N/A • Product: 8 bits • Save Time? M’cand=0010 Product=0000 0011
Signed Multiplication • Booth’s algorithm
Booth’s algorithm • Example: • M’cand =3 = 0011 • -m’cand=1101 • M’ier = -2 = 1110
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 2a. Shift the Quotient register to the left setting the new rightmost bit to 1. 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. 33 repetition? No: < 33 repetitions Yes: 33 repetitions Done Unsigned Division- Restoring Division
Unsigned Division- Restoring Division • Example: • 4-bit register • Dividend=0111, divisor=0010 initial Rem = Rem-Div Rem<0+Div, sll, Q0=0 / sll, Q0=1 Div srl
31 30 23 22 0 S Exponent Significand 1 bit 8 bits 23 bits Floating-point Representation • IEEE 754 Standard • (-1)S x (1 + Significand) x 2(Exponent-127) • Double precision identical, except with exponent bias of 1023
1 0111 1101 100 0000 0000 0000 0000 0000 Decimal Floating-point Representation • Example: -0.375 • -0.375 = -3/8 • -11two/1000two = -0.011two • Normalized to -1.1two x 2-2 • (-1)S x (1 + Significand) x 2(Exponent-127) • (-1)1 x (1 + .100 0000 ... 0000) x 2(125-127)
1 10000001 010 0000 0000 0000 0000 0000 Floating-point Representation Decimal • Example: • (-1)S x (1 + Significand) x 2(Exponent-127) • (-1)1 x (1 + 0.25) x 2(129-127)
Floating-point Addition • Example: 0.5ten + -0.4375ten • 0.5ten = 1/2ten = 1.000two x2-1 • -0.4375ten = -7/16ten = -1.110two x2-2 • Alignment: -1.110two x2-2 = -0.111two x2-1 • 1.000two x2-1 +(-0.111two x2-1) = 0.001two x2-1 • Normalization: 0.001two x2-1 = 1.000two x2-4 • Rounding: 4-bit already • 1.000two x2-4 = 0.0625
Floating-point Multiplication • Example: 0.5ten x -0.4375ten • 0.5ten = 1/2ten = 1.000two x2-1 • -0.4375ten = -7/16ten = -1.110two x2-2 • Exponents: (-1+127)+(-2+127)-127 = 124 • Significands: 1.000twox1.110two=1.110000twox2-3 • Normalization: -126≤exp. ≤127 • Rounding: =1.110twox2-3 • Sign: -1.110twox2-3
HW#5 • Example: • 0111/0011: quotient=0010,remainder=0001 • Difference? • Restoring Division: • (Remainder+Divisor)*2 – Divisor • Non-restoring Division: • Remainder*2 + Divisor