-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestbench.v
52 lines (47 loc) · 918 Bytes
/
testbench.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
`timescale 1ns / 1ps
`include "def.v"
module testbench();
reg [7:0] seg;
reg [3:0] segsel;
//
reg clk, reset;
wire signed [31:0] osecpu_dr;
wire [15:0] osecpu_pc;
wire [7:0] osecpu_cr;
//
reg [31:0] counter = 0;
//
OSECPU osecpu(clk, reset, osecpu_dr, osecpu_cr, osecpu_pc);
initial begin
$dumpfile("testbench.vcd");
$dumpvars(0, testbench);
//
reset <= 1;
#20;
reset <= 0;
end
always begin
// gen 50MHz clock
clk <= 1; #20;
clk <= 0; #20;
end
always @(posedge clk) begin
counter = counter + 1;
if(osecpu_cr[`BIT_CR_HLT]) begin
$display ("DR: 0x%x = %d", osecpu_dr, osecpu_dr);
/*
if(osecpu_dr == -4)
$display ("Simulation PASS");
else begin
$display ("Simulation **** FAILED ****");
$display ("%x", osecpu_dr);
end
*/
$finish;
end
if(counter >= 2000) begin
$display ("aborted due to counter value");
$finish;
end
end
endmodule