-
Notifications
You must be signed in to change notification settings - Fork 1
/
boothmultiplier.v
74 lines (59 loc) · 1.58 KB
/
boothmultiplier.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module boothmultiplier(data_in,clk,start,result);
wire ldA,clrA,sftA,ldQ,clrQ,sftQ,done;
wire ldM,clrFF,addsub,decr,ldcount;
input signed [15:0]data_in;
input start,clk;
wire qm1,eqz;
output signed [31:0]result;
wire [4:0] countdata;
wire signed [15:0] A,M,Q,Z; //A->Acc , M->Multiplicand , Q->Multiplier, Z->(A-M,A+M)
assign eqz = ~| (countdata);
assign result = {A,Q};
shiftreg Acc_A(.data_out(A),
.ld_data(Z),
.s_in(A[15]),
.clk(clk),
.ld(ldA),
.rst(clrA),
.sft(sftA));
shiftreg Mlpr_Q(.data_out(Q),
.ld_data(data_in),
.s_in(A[0]),
.clk(clk),
.ld(ldQ),
.rst(clrQ),
.sft(sftQ));
dflipflop d_ff(.data_in(Q[0]),
.clk(clk),
.rst(clrFF),
.data_out(qm1));
PIPO Mlcd_M(.data_out(M),
.data_in(data_in),
.clk(clk),
.ld(ldM));
ALU Adsub(.out(Z),
.in1(A),
.in2(M),
.addsub(addsub));
bitcounter counter(.countdata(countdata),
.decr(decr),
.ldcount(ldcount),
.clk(clk));
controller fsm(.ldA(ldA),
.clrA(clrA),
.sftA(sftA),
.ldQ(ldQ),
.clrQ(clrQ),
.sftQ(sftQ),
.ldM(ldM),
.clrFF(clrFF),
.addsub(addsub),
.start(start),
.decr(decr),
.ldcount(ldcount),
.done(done),
.clk(clk),
.q0(Q[0]),
.qm1(qm1),
.eqz(eqz));
endmodule