-
Notifications
You must be signed in to change notification settings - Fork 0
/
mont_mul_tb.v
95 lines (73 loc) · 1.48 KB
/
mont_mul_tb.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
module mont_mul_tb (
);
reg clk, rst_n, start;
wire valid;
wire [255:0] result;
always begin
clk = 0;
#1;
clk = 1;
#1;
end
wire lsu_ren, lsu_wen, lsu_done;
reg [31 : 0] lsu_addr_base;
wire [31 : 0] lsu_addr_offset;
wire [31 : 0] lsu_wdata;
wire [31 : 0] lsu_rdata;
wire [1:0] mm_op_address_sel;
always @(*) begin
case (mm_op_address_sel)
0: lsu_addr_base = 32'd16; // B
1: lsu_addr_base = 32'd32; // N
2: lsu_addr_base = 32'd0; // A
3: lsu_addr_base = 32'd48; // Result
endcase
end
mont_mul DUT (
.clk(clk), // Clock
.rst_n(rst_n), // Asynchronous reset active low
.start(start),
.op_address_sel (mm_op_address_sel),
.lsu_ren(lsu_ren),
.lsu_wen(lsu_wen),
.lsu_type(),
.lsu_addr_offset(lsu_addr_offset),
.lsu_done(lsu_done),
.lsu_rdata(lsu_rdata),
.lsu_wdata(lsu_wdata),
.result(result),
.done(valid)
);
dp_ram
#(
.INIT_FILE_BIN("mont.txt"),
.SIZE_BYTES(1024)
) ram (
.clk (clk),
// Instruction memory interface
.a_valid_i(lsu_ren | lsu_wen),
.a_ready_o(lsu_done),
.a_addr_i (lsu_addr_base + lsu_addr_offset),
.a_wdata_i(lsu_wdata),
.a_we_i ({4{lsu_wen}}),
.a_rdata_o(lsu_rdata),
// Data memory interface
.b_valid_i(1'd0),
.b_ready_o(),
.b_addr_i (0),
.b_rdata_o()
);
initial begin
$dumpfile("mont_mul.vcd");
$dumpvars(0,mont_mul_tb);
start = 0;
rst_n = 0;
#10;
rst_n = 1;
#10;
start = 1;
wait(valid == 1);
$display("%x",result);
$finish;
end
endmodule