-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathref_tb.cpp
More file actions
57 lines (46 loc) · 1.13 KB
/
Copy pathref_tb.cpp
File metadata and controls
57 lines (46 loc) · 1.13 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
53
54
55
56
57
#include "verilated.h"
#include "verilated_vcd_c.h"
#include "Vtop.h"
#include "vbuddy.cpp"
#define MAX_SIM_CYC 1000000
int main(int argc, char **argv, char **env){
int simcyc;
int tick;
Verilated::commandArgs(argc, argv);
Vtop * top = new Vtop;
Verilated::traceEverOn(true);
VerilatedVcdC* tfp = new VerilatedVcdC;
top->trace (tfp, 99);
tfp->open ("top.vcd");
if (vbdOpen()!=1) return(-1);
vbdHeader("PipelinedRef");
top->clk = 1;
top->rst = 0;
int plot = 0;
for (simcyc=0; simcyc<MAX_SIM_CYC; simcyc++) {
// dump variables into VCD file and toggle clock
for (tick=0; tick<2; tick++) {
tfp->dump (2*simcyc+tick);
top->clk = !top->clk;
top->eval ();
}
if (plot == 0 && top->a0 != 0) {
plot = 1;
}
// plot ROM output and print cycle count
if (plot >= 1) {
vbdPlot(int(top->a0), 0, 255);
vbdCycle(simcyc);
plot += 1;
}
if (plot > 1920) {
break;
}
// either simulation finished, or 'q' is pressed
if ((Verilated::gotFinish()) || (vbdGetkey()=='q'))
exit(0);
}
vbdClose();
tfp->close();
exit(0);
}