-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtb_processor.sv
64 lines (55 loc) · 1.23 KB
/
tb_processor.sv
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
module tb_processor();
logic clk;
logic rst;
logic timer_interrupt;
processor dut
(
.clk ( clk ),
.rst ( rst ),
.timer_interrupt ( timer_interrupt )
);
timer timer_i
(
.clk( clk ),
.rst( rst ),
.timer_interrupt ( timer_interrupt )
);
// clock generator
initial
begin
clk = 0;
forever
begin
#4 clk = ~clk;
end
end
// reset generator
initial
begin
rst = 1;
#10;
rst = 0;
#10000;
$finish;
end
// initialize memory
initial
begin
$readmemh("inst.mem", dut.inst_mem_i.mem);
$readmemb("rf.mem", dut.reg_file_i.reg_mem);
$readmemb("dm.mem", dut.data_mem_i.data_mem);
$readmemb("csr_reg.mem", dut.csr_reg_i.csr_mem);
end
// dumping the waveform
initial
begin
$dumpfile("processor.vcd");
$dumpvars(0, dut);
end
final
begin
$writememh("rf_out.mem", dut.reg_file_i.reg_mem);
$writememh("dm_out.mem", dut.data_mem_i.data_mem);
$writememh("csr_reg_out.mem", dut.csr_reg_i.csr_mem);
end
endmodule