-
Notifications
You must be signed in to change notification settings - Fork 0
/
booth_test.v
71 lines (48 loc) · 1.3 KB
/
booth_test.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
`timescale 1ns / 1ps
module tb_Booth_Multiplier;
parameter N = 2;
// UUT Signals
reg Rst;
reg Clk;
reg Ld;
reg [(2**N - 1):0] M;
reg [(2**N - 1):0] R;
wire Valid;
wire [(2**(N+1) - 1):0] P;
// Simulation Variables
reg [2**(N+1):0] i;
// Instantiate the Unit Under Test (UUT)
BoothMultipilcation #(
.pN(N)
) uut (
.Rst(Rst),
.Clk(Clk),
.Ld(Ld),
.M(M),
.R(R),
.Valid(Valid),
.P(P)
);
initial begin
// Initialize Inputs
Rst = 1;
Clk = 1;
Ld = 0;
M = 0;
R = 0;
i = 0;
// Wait 100 ns for global reset to finish
#101 Rst = 0;
// Add stimulus here
for(i = 0; i < (2**(2**(N+1))); i = i + 1) begin
@(posedge Clk) #1 Ld = 1;
M = i[(2**(N+1) - 1):2**N];
R = i[(2**N - 1):0];
@(posedge Clk) #1 Ld = 0;
@(posedge Valid);
end
end
///////////////////////////////////////////////////////////////////////////////
always #5 Clk = ~Clk;
///////////////////////////////////////////////////////////////////////////////
endmodule