-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtop_tb.v
63 lines (45 loc) · 1.16 KB
/
top_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
// Name: Joshua Bone, Jonathan Hall
// BU ID: U22742355,U21798292
// EC413 Project: Top Level Module Test Bench
module top_tb();
reg clock;
reg reset;
wire [31:0] result;
integer x;
top dut (
.clock(clock),
.reset(reset),
.wb_data(result)
);
always #5 clock = ~clock;
task print_state;
begin
$display("Time:\t%0d", $time);
for( x=0; x<32; x=x+1) begin
$display("Register %d: %h", x, dut.regFile_inst.reg_file[x]);
end
$display("--------------------------------------------------------------------------------");
$display("\n\n");
end
endtask
initial begin
clock = 1'b1;
reset = 1'b1;
print_state();
// Make sure the .vmh file is in the same directory that you launched the
// simulation from.
//$readmemh("./fibonacci.vmh", dut.main_memory.ram); // Should put 0x00000015 in register x9
$readmemh("./gcd.vmh", dut.main_memory.ram); // Should put 0x00000010 in register x9
for( x=0; x<32; x=x+1) begin
dut.regFile_inst.reg_file[x] = 32'd0;
end
#1
#20
reset = 1'b0; //PC now at 0, should begin executing instructions
#60000
print_state();
#100
$display("done!\n");
$stop();
end
endmodule