diff --git a/src/test/cpp/testA/main.cpp b/src/test/cpp/testA/main.cpp index 13a1088..19286a0 100644 --- a/src/test/cpp/testA/main.cpp +++ b/src/test/cpp/testA/main.cpp @@ -165,15 +165,21 @@ public: virtual void checks(){} virtual void pass(){ throw success();} virtual void fail(){ throw std::exception();} - + void dump(long i){ + #ifdef TRACE + tfp->dump(i); + #endif + } Workspace* run(uint32_t timeout = 5000){ // cout << "Start " << name << endl; currentTime = 4; // init trace dump Verilated::traceEverOn(true); + #ifdef TRACE VerilatedVcdC* tfp = new VerilatedVcdC; top->trace(tfp, 99); tfp->open((string(name)+ ".vcd").c_str()); + #endif // Reset top->clk = 0; @@ -183,7 +189,7 @@ public: top->eval(); currentTime = 3; top->reset = 1; top->eval(); - tfp->dump(0); + dump(0); top->reset = 0; top->eval(); currentTime = 2; top->clk = 1; @@ -258,7 +264,7 @@ public: // dump variables into VCD file and toggle clock for (uint32_t clk = 0; clk < 2; clk++) { - tfp->dump(i+ clk); + dump(i+ clk); top->clk = !top->clk; top->eval(); @@ -291,9 +297,11 @@ public: - tfp->dump(i); - tfp->dump(i+1); + dump(i); + dump(i+1); + #ifdef TRACE tfp->close(); + #endif return this; } }; diff --git a/src/test/cpp/testA/makefile b/src/test/cpp/testA/makefile index 6f3f15f..4e9b703 100644 --- a/src/test/cpp/testA/makefile +++ b/src/test/cpp/testA/makefile @@ -1,8 +1,15 @@ +TRACE=no + +ifeq ($(TRACE),yes) + VERILATOR_ARGS += --trace + ADDCFLAGS += -DTRACE +endif + run: compile ./obj_dir/VVexRiscv verilate: - verilator -cc ../../../../VexRiscv.v -O3 -CFLAGS -std=c++11 --gdbbt --trace -Wno-WIDTH --x-assign unique --exe main.cpp + verilator -cc ../../../../VexRiscv.v -O3 -CFLAGS -std=c++11 ${ADDCFLAGS} --gdbbt ${VERILATOR_ARGS} -Wno-WIDTH --x-assign unique --exe main.cpp compile: verilate make -j -C obj_dir/ -f VVexRiscv.mk VVexRiscv