mirror of
https://github.com/verilator/verilator.git
synced 2025-01-06 06:37:45 +00:00
Examples: Add +trace flag at runtime
This commit is contained in:
parent
6edaef9598
commit
dfd22b2b07
@ -73,7 +73,7 @@ run:
|
|||||||
@echo
|
@echo
|
||||||
@echo "-- RUN ---------------------"
|
@echo "-- RUN ---------------------"
|
||||||
@mkdir -p logs
|
@mkdir -p logs
|
||||||
obj_dir/Vtop | tee logs/sim.log
|
obj_dir/Vtop +trace | tee logs/sim.log
|
||||||
|
|
||||||
@echo
|
@echo
|
||||||
@echo "-- COVERAGE ----------------"
|
@echo "-- COVERAGE ----------------"
|
||||||
|
@ -41,14 +41,19 @@ int main(int argc, char** argv, char** env) {
|
|||||||
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
|
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
|
||||||
Vtop* top = new Vtop; // Or use a const unique_ptr, or the VL_UNIQUE_PTR wrapper
|
Vtop* top = new Vtop; // Or use a const unique_ptr, or the VL_UNIQUE_PTR wrapper
|
||||||
|
|
||||||
// If verilator was invoked with --trace, open trace
|
|
||||||
#if VM_TRACE
|
#if VM_TRACE
|
||||||
|
// If verilator was invoked with --trace argument,
|
||||||
|
// and if at run time passed the +trace argument, turn on tracing
|
||||||
|
VerilatedVcdC* tfp = NULL;
|
||||||
|
const char* flag = Verilated::commandArgsPlusMatch("trace");
|
||||||
|
if (flag && 0==strcmp(flag, "+trace")) {
|
||||||
Verilated::traceEverOn(true); // Verilator must compute traced signals
|
Verilated::traceEverOn(true); // Verilator must compute traced signals
|
||||||
VL_PRINTF("Enabling waves into logs/vlt_dump.vcd...\n");
|
VL_PRINTF("Enabling waves into logs/vlt_dump.vcd...\n");
|
||||||
VerilatedVcdC* tfp = new VerilatedVcdC;
|
tfp = new VerilatedVcdC;
|
||||||
top->trace(tfp, 99); // Trace 99 levels of hierarchy
|
top->trace(tfp, 99); // Trace 99 levels of hierarchy
|
||||||
mkdir("logs", 0777);
|
mkdir("logs", 0777);
|
||||||
tfp->open("logs/vlt_dump.vcd"); // Open the dump file
|
tfp->open("logs/vlt_dump.vcd"); // Open the dump file
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set some inputs
|
// Set some inputs
|
||||||
|
@ -81,7 +81,7 @@ run:
|
|||||||
@echo
|
@echo
|
||||||
@echo "-- RUN ---------------------"
|
@echo "-- RUN ---------------------"
|
||||||
@mkdir -p logs
|
@mkdir -p logs
|
||||||
obj_dir/Vtop | tee logs/sim.log
|
obj_dir/Vtop +trace | tee logs/sim.log
|
||||||
|
|
||||||
@echo
|
@echo
|
||||||
@echo "-- COVERAGE ----------------"
|
@echo "-- COVERAGE ----------------"
|
||||||
|
@ -87,13 +87,18 @@ int sc_main(int argc, char* argv[]) {
|
|||||||
sc_start(1);
|
sc_start(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Turn on waves
|
|
||||||
#if VM_TRACE
|
#if VM_TRACE
|
||||||
|
// 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";
|
cout << "Enabling waves into logs/vlt_dump.vcd...\n";
|
||||||
VerilatedVcdSc* tfp = new VerilatedVcdSc;
|
VerilatedVcdSc* tfp = new VerilatedVcdSc;
|
||||||
top->trace (tfp, 99);
|
top->trace (tfp, 99);
|
||||||
mkdir("logs", 0777);
|
mkdir("logs", 0777);
|
||||||
tfp->open ("logs/vlt_dump.vcd");
|
tfp->open ("logs/vlt_dump.vcd");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Simulate until $finish
|
// Simulate until $finish
|
||||||
|
Loading…
Reference in New Issue
Block a user