Title: Multiplication and Division
1Multiplication and Division
2Multiplication
1101 x1011 1101 1101 100111
0000 100111 1101 10001111
13 x11 13 13 143 8Fh
3Multiplication
1101 x1011 1101 1101 100111
0000 100111 1101 10001111
1101 00001011 01101101 adsh 1101 10011110 adsh
1001111 sh 1101 10001111 adsh
4Multiplication
UM ( u1 u2 -- upL upH )
T
N
N2
mpp (multiply partial product) if N(0) 1
then adsh else sh end if
UM ( u1 u2 -- ud) LIT 0 mpp mpp
mpp mpp ROT DROP
All other signed and unsigned multiplication can
be derived from UM
5Modifications for Multiplication and Division
y1
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)
begin
AVector '0' a BVector '0'
b CVector '0' c y1_tmp false
yVector '0' false
7mpp (multiply partial product) if N(0) 1
then adsh else sh end if
when "011101" gt -- mpp if b(0) '1' then
yVector AVector CVector else yVector
AVector end if y lt yVector(width downto
1) y1 lt yVector(0) b(width-1 downto 1)
T
N
N2
816 x 16 32 Multiplication
UM ( u1 u2 - upL upH ) 0 mpp mpp mpp mpp
mpp mpp mpp mpp mpp mpp mpp mpp mpp mpp mpp
mpp ROT_DROP
9Division
10
1010
13 135 13 05
1101 10000111
1101 00111 0000 01111 1101 00101 0000
0101
10Division 8-bit/4-bit 44
1010
_10000111 1101
numer80 denom30
1101 10000111
1101 00111 0000 01111 1101 00101 0000
0101
If denom lt numer74 then overflow (quotient
wont fit in 4 bits)
Let T numer84 N numer30 N2
denom30
11Division 8-bit/4-bit 44
T
N
1010
sll
100001110 1101
1101 10000111
1101 00111 0000 01111 1101 00101 0000
0101
N2
for I in 0 to 3 loop sll T N if T84 gt
N2 then T T - (0 N2) N(0)
1 end if end loop
12Division 8-bit/4-bit 44
T
N
1010
sll
100001110 1101
1101 10000111
N2
1101 00111 0000 01111 1101 00101 0000
0101
13Division
N2
T
N
UM/MOD ( unumL unumH udenom -- urem uquot )
N2
T
N
-ROT \ udenom unumL unumH SHLDC SHLDC SHLDC SHLD
C \ denom quot rem ROT_DROP_SWAP
All other signed and unsigned division operations
can be derived as WHYP words from UM/MOD
14when "011110" gt -- shldc yVector a
b(width-1) y1_tmp b(width-2 downto 0)
'0' if yVector gt CVector then yVector
yVector - CVector y1_tmp(0) '1' end
if
y lt yVector(width-1 downto 0) y1 lt y1_tmp
for I in 0 to 3 loop sll T N if T84 gt
N2 then T T - (0 N2) N(0)
1 end if end loop
T
N
sll
100001110 1101
N2
1532 / 16 1616 Division
UM/MOD ( unL unH ud -- ur uq ) -ROT shldc
shldc shldc shldc shldc shldc shldc shldc shldc
shldc shldc shldc shldc shldc shldc shldc
ROT_DROP_SWAP
16 Hex Division
C
A
EE BC2F
B28
9A
F
C x E A8 C x E A8 A B2
17 Hex Division
C
A
EE BC2F
B28
9A
F
94C
63
Dividend BC2F Divisor EE Quotient
CA Remainder 63
A x E 8C A x E 8C 8 94
18(No Transcript)
19(No Transcript)
20(No Transcript)
21(No Transcript)