2018-03-04 15:20:29 -05:00
|
|
|
#include "Vpicorv32_wrapper.h"
|
|
|
|
#include "verilated_vcd_c.h"
|
|
|
|
|
|
|
|
int main(int argc, char **argv, char **env)
|
|
|
|
{
|
2019-03-19 09:33:50 -04:00
|
|
|
printf("Built with %s %s.\n", Verilated::productName(), Verilated::productVersion());
|
|
|
|
printf("Recommended: Verilator 4.0 or later.\n");
|
|
|
|
|
2018-03-04 15:20:29 -05:00
|
|
|
Verilated::commandArgs(argc, argv);
|
|
|
|
Vpicorv32_wrapper* top = new Vpicorv32_wrapper;
|
|
|
|
|
2020-04-23 12:00:16 -04:00
|
|
|
// Tracing (vcd)
|
|
|
|
VerilatedVcdC* tfp = NULL;
|
|
|
|
const char* flag_vcd = Verilated::commandArgsPlusMatch("vcd");
|
|
|
|
if (flag_vcd && 0==strcmp(flag_vcd, "+vcd")) {
|
|
|
|
Verilated::traceEverOn(true);
|
|
|
|
tfp = new VerilatedVcdC;
|
|
|
|
top->trace (tfp, 99);
|
|
|
|
tfp->open("testbench.vcd");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tracing (data bus, see showtrace.py)
|
|
|
|
FILE *trace_fd = NULL;
|
|
|
|
const char* flag_trace = Verilated::commandArgsPlusMatch("trace");
|
|
|
|
if (flag_trace && 0==strcmp(flag_trace, "+trace")) {
|
|
|
|
trace_fd = fopen("testbench.trace", "w");
|
|
|
|
}
|
|
|
|
|
2018-03-04 15:20:29 -05:00
|
|
|
top->clk = 0;
|
|
|
|
int t = 0;
|
|
|
|
while (!Verilated::gotFinish()) {
|
|
|
|
if (t > 200)
|
|
|
|
top->resetn = 1;
|
|
|
|
top->clk = !top->clk;
|
|
|
|
top->eval();
|
2020-04-23 12:00:16 -04:00
|
|
|
if (tfp) tfp->dump (t);
|
|
|
|
if (trace_fd && top->clk && top->trace_valid) fprintf(trace_fd, "%9.9lx\n", top->trace_data);
|
2018-03-04 15:20:29 -05:00
|
|
|
t += 5;
|
|
|
|
}
|
2020-04-23 12:00:16 -04:00
|
|
|
if (tfp) tfp->close();
|
2018-03-04 15:20:29 -05:00
|
|
|
delete top;
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|