-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdder_Tree_tb.v
66 lines (53 loc) · 2.28 KB
/
Adder_Tree_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
// wrong version!
`timescale 1ns/10ps
`define CYCLE 10.0
module Adder_Tree_tb;
// ========== clk generation ==============
reg clk = 1;
always #(`CYCLE/2) clk = ~clk;
// ========== dump waveform ===============
initial begin
$fsdbDumpfile("Adder_Tree.fsdb");
$fsdbDumpvars(0, "+mda");
end
// ========== time out ====================
initial begin
# (10000 * `CYCLE);
$display("\n\033[1;31m=============================================");
$display(" Simulation Time Out! ");
$display("=============================================\033[0m");
$finish;
end
// ========== instantiate DUT =============
reg rst_n = 1;
reg STDW = 0, STDR = 0;
reg [1007:0] PSUM = 0;
reg [1:0] mode = 0;
wire [287:0] res;
Adder_Tree Adder_Tree0(
.clk(clk),
.rst_n(rst_n),
.PSUM(PSUM), // 14b x 8 x 9 input
.mode(mode),
.res(res)
);
// ========= input pattern ================
integer i;
initial begin
// reset
@(posedge clk) rst_n = 0;
@(posedge clk) rst_n = 1;
for (i = 0; i < 5; i = i+1) begin
@(posedge clk);
end
// test mode 0
@(posedge clk) mode <= 0;
PSUM = 1008'b100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000;
// test mode 1
@(posedge clk);
@(posedge clk) mode <= 1;
// test mode 2
@(posedge clk);
@(posedge clk) mode <= 2;
end
endmodule