150 likes | 355 Views
LAB8 Multiplier. 乘法器. Multiplier. A ( 被乘數 ) <8 bit>. B ( 乘數 ) <8bit>. Multiplier ( 乘法器 ). start <1 bit>. reset <1 bit>. clock <1 bit>. done <1 bit>. P ( 乘積 ) <16 bit>. 二進位乘法. Multiplication. 十進位乘法. A. 1. 0. 1. 1. A. B. B. x. 1. 1. 0. 1. 1. 0. 1. 1.
E N D
LAB8 Multiplier 乘法器
Multiplier A(被乘數) <8 bit> B(乘數) <8bit> Multiplier (乘法器) start <1 bit> reset <1 bit> clock <1 bit> done <1 bit> P(乘積) <16 bit>
二進位乘法 Multiplication • 十進位乘法 A 1 0 1 1 A B B x 1 1 0 1 1 0 1 1 0 0 0 0 0 1 0 1 1 0 0 P + 1 0 1 1 0 0 0 1 0 0 0 1 1 1 1 P
Pseudo code P=0;done=0; While(B!=0){ if(B[0]) P = P+A; left_shift A; right_shift B; } done=1;
A A B B Example • Step 1. • Step 2. P P Done=0 Done=0
A A B B Example • Step 3. • Step 4. P P Done=0 Done=0
A A B B Example • Step 5. • Step 6. P P Done=0 Done=1
ASM chart Reset S1 P←0 Load A Load B 0 0 1 s s 1 S2 S3 Shift left A, Shift right B Done 1 P←P+A B = 0 ? 0 0 B[0] 1
Datapath DataB DataA 0 n n n LA LB L L Shift-left register Shift-right register EA E E EB B A Clock n 2n + z Sum B[0] 0 2n 2n Psel 0 1 2n DataP EP E Register 2n P
Reset S1 Psel=0, EP 0 s 1 0 1 s S2 S3 Psel = 1, EA, EB Done 1 z EP 0 0 B[0] 1 Control Unit LA, LB
RTL for multiplier s reset clk A B n n LA Control Unit Datapath EA LB EB Psel EP z B[0] 2 2n 2n n done CurrentState P Left A Right B
ABP done reset / start