Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiplication and Division Lab 9. Multiplication 13 x11 13 143 = 8Fh 1101 x1011 1101 100111 0000 100111 1101 10001111.

Similar presentations


Presentation on theme: "Multiplication and Division Lab 9. Multiplication 13 x11 13 143 = 8Fh 1101 x1011 1101 100111 0000 100111 1101 10001111."— Presentation transcript:

1 Multiplication and Division Lab 9

2 Multiplication 13 x11 13 143 = 8Fh 1101 x1011 1101 100111 0000 100111 1101 10001111

3 Multiplication 1101 x1011 1101 100111 0000 100111 1101 10001111 1101 00001011 01101101 adsh 1101 10011110 adsh 1001111 sh 1101 10001111 adsh

4 Multiplication UM* ( u1 u2 -- upL upH ) TN N2 mpp (multiply partial product) if N(0) = 1 then adsh else sh end if; : UM* ( u1 u2 -- ud) LIT 0 mpp mpp ROT DROP ; All other signed and unsigned multiplication can be derived from UM*

5 y1 Modifications for Multiplication and Division

6 variable AVector: STD_LOGIC_VECTOR (width downto 0); variable BVector: STD_LOGIC_VECTOR (width downto 0); variable CVector: STD_LOGIC_VECTOR (width downto 0); variable yVector: STD_LOGIC_VECTOR (width downto 0); variable y1_tmp: STD_LOGIC_VECTOR (width-1 downto 0); AVector := '0' & a; BVector := '0' & b; CVector := '0' & c; y1_tmp := false; yVector := '0' & false; begin

7 when "011101" =>-- mpp if b(0) = '1' then yVector := AVector + CVector; else yVector := AVector; end if; y <= yVector(width downto 1); y1 <= yVector(0) & b(width-1 downto 1); mpp (multiply partial product) if N(0) = 1 then adsh else sh end if; TN N2

8 : UM* ( u1 u2 - upL upH ) 0 mpp mpp ROT_DROP ; 16 x 16 = 32 Multiplication

9 Division 1101 10000111 1010 1101 00111 0000 01111 1101 00101 0000 0101 13 135 13 05 10

10 Division 8-bit/4-bit = 4:4 1101 10000111 1010 1101 00111 0000 01111 1101 00101 0000 0101 _10000111 1101 numer[8:0] denom[3:0] If denom < numer[7:4] then overflow (quotient won’t fit in 4 bits) Let T = numer[8:4] N = numer[3:0] N2 = denom[3:0]

11 Division 8-bit/4-bit = 4:4 1101 10000111 1010 1101 00111 0000 01111 1101 00101 0000 0101 100001110 1101 sll TN N2 for I in 0 to 3 loop sll T & N; if T[8:4] > N2 then T := T - (0 & N2); N(0) := ‘1’; end if; end loop;

12 Division 8-bit/4-bit = 4:4 1101 10000111 1010 1101 00111 0000 01111 1101 00101 0000 0101 100001110 1101 sll TN N2 001111110 1101 sub1sll 011111100 1101 sll 001011010 sub1sll rem quot

13 Division : UM/MOD ( unumL unumH udenom -- urem uquot ) All other signed and unsigned division operations can be derived as WHYP words from UM/MOD TN N2 TN -ROT\ udenom unumL unumH SHLDC SHLDC \ denom quot rem ROT_DROP_SWAP ;

14 when "011110" =>-- shldc yVector := a & b(width-1); y1_tmp := b(width-2 downto 0) & '0'; if yVector > CVector then yVector := yVector - CVector; y1_tmp(0) := '1'; end if; for I in 0 to 3 loop sll T & N; if T[8:4] > N2 then T := T - (0 & N2); N(0) := ‘1’; end if; end loop; 100001110 1101 sll TN N2 y <= yVector(width-1 downto 0); y1 <= y1_tmp;

15 32 / 16 = 16:16 Division : UM/MOD ( unL unH ud -- ur uq ) -ROT shldc shldc ROT_DROP_SWAP ;

16 Hex Division EE BC2F C C x E = A8 C x E = A8 + A = B2 B28 9AF A

17 Hex Division EE BC2F C A x E = 8C A x E = 8C + 8 = 94 B28 9AF A 94C 63 Dividend = BC2F Divisor = EE Quotient = CA Remainder = 63

18

19

20

21


Download ppt "Multiplication and Division Lab 9. Multiplication 13 x11 13 143 = 8Fh 1101 x1011 1101 100111 0000 100111 1101 10001111."

Similar presentations


Ads by Google