-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestbench.v
More file actions
53 lines (40 loc) · 1.02 KB
/
testbench.v
File metadata and controls
53 lines (40 loc) · 1.02 KB
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
module testbench;
reg clk = 0;
reg reset = 1;
reg [31:0] forced_pc = 0;
reg force_pc = 0;
wire [31:0] pc_out;
// Instantiate UPDATED CPU module (renamed to main_cpu)
main_cpu cpu(
.clk(clk),
.reset(reset),
.force_pc(force_pc),
.forced_pc(forced_pc),
.pc_out(pc_out)
);
always #5 clk = ~clk;
initial begin
$dumpfile("waves.vcd");
$dumpvars(0, testbench);
cpu.rf.r0 = 32'd10;
cpu.rf.r1 = 32'd5;
reset = 1;
#20 reset = 0;
$display("=== ADD Phase ===");
#40;
$display("=== AND Phase ===");
force_pc = 1;
forced_pc = 32'h00000008;
@(posedge clk);
force_pc = 0;
#40;
$display("=== SUB Phase ===");
force_pc = 1;
forced_pc = 32'h00000004;
@(posedge clk);
force_pc = 0;
#40;
$display("=== Test Finished ===");
$finish;
end
endmodule