diff options
author | Larry Doolittle <ldoolitt@recycle.lbl.gov> | 2020-04-23 18:00:16 +0200 |
---|---|---|
committer | Claire Wolf <claire@symbioticeda.com> | 2020-04-23 18:00:16 +0200 |
commit | e03c43ea4392c2f87d7ebf23656a60ed8cda185b (patch) | |
tree | 4952245eea0f1316bbf20b2d96eb5e15cc4623a6 | |
parent | 9129d18bf5699e69f25edffa7864aaf88d6dd385 (diff) | |
download | picorv32-e03c43ea4392c2f87d7ebf23656a60ed8cda185b.tar.gz picorv32-e03c43ea4392c2f87d7ebf23656a60ed8cda185b.zip |
Add plusargs support to testbench.cc
Signed-off-by: Claire Wolf <claire@symbioticeda.com>
-rw-r--r-- | testbench.cc | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/testbench.cc b/testbench.cc index cd835df..61c4366 100644 --- a/testbench.cc +++ b/testbench.cc @@ -7,12 +7,25 @@ int main(int argc, char **argv, char **env) printf("Recommended: Verilator 4.0 or later.\n"); Verilated::commandArgs(argc, argv); - Verilated::traceEverOn(true); Vpicorv32_wrapper* top = new Vpicorv32_wrapper; - VerilatedVcdC* tfp = new VerilatedVcdC; - top->trace (tfp, 99); - tfp->open ("testbench.vcd"); + // 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"); + } + top->clk = 0; int t = 0; while (!Verilated::gotFinish()) { @@ -20,10 +33,11 @@ int main(int argc, char **argv, char **env) top->resetn = 1; top->clk = !top->clk; top->eval(); - tfp->dump (t); + if (tfp) tfp->dump (t); + if (trace_fd && top->clk && top->trace_valid) fprintf(trace_fd, "%9.9lx\n", top->trace_data); t += 5; } - tfp->close(); + if (tfp) tfp->close(); delete top; exit(0); } |