Examples: Add +trace flag at runtime

This commit is contained in:
Wilson Snyder
2017-11-05 06:51:29 -05:00
parent 6edaef9598
commit dfd22b2b07
4 changed files with 25 additions and 15 deletions
+11 -6
View File
@@ -87,13 +87,18 @@ int sc_main(int argc, char* argv[]) {
sc_start(1);
#endif
// Turn on waves
#if VM_TRACE
cout << "Enabling waves into logs/vlt_dump.vcd...\n";
VerilatedVcdSc* tfp = new VerilatedVcdSc;
top->trace (tfp, 99);
mkdir("logs", 0777);
tfp->open ("logs/vlt_dump.vcd");
// If verilator was invoked with --trace argument,
// and if at run time passed the +trace argument, turn on tracing
VerilatedVcdSc* tfp = NULL;
const char* flag = Verilated::commandArgsPlusMatch("trace");
if (flag && 0==strcmp(flag, "+trace")) {
cout << "Enabling waves into logs/vlt_dump.vcd...\n";
VerilatedVcdSc* tfp = new VerilatedVcdSc;
top->trace (tfp, 99);
mkdir("logs", 0777);
tfp->open ("logs/vlt_dump.vcd");
}
#endif
// Simulate until $finish