Skip to content

Commit

Permalink
emu: fix the --dump-wave-full option
Browse files Browse the repository at this point in the history
  • Loading branch information
poemonsense committed Sep 13, 2023
1 parent f5c1f79 commit dd0c523
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
53 changes: 27 additions & 26 deletions src/test/csrc/verilator/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ inline EmuArgs parse_args(int argc, const char *argv[]) {
exit(0);
}

args.enable_waveform = args.enable_waveform && !args.enable_fork;

#ifdef ENABLE_IPC
char *ipc_image = (char *)malloc(255);
char *ipc_file = (char *)malloc(255);
Expand Down Expand Up @@ -320,6 +322,25 @@ Emulator::Emulator(int argc, const char *argv[]):
// init flash
init_flash(args.flash_bin);

#if VM_TRACE == 1
if (args.enable_waveform) {
Verilated::traceEverOn(true); // Verilator must compute traced signals
#ifdef ENABLE_FST
tfp = new VerilatedFstC;
#else
tfp = new VerilatedVcdC;
#endif
dut_ptr->trace(tfp, 99); // Trace 99 levels of hierarchy
if (args.wave_path != NULL) {
tfp->open(args.wave_path);
}
else {
time_t now = time(NULL);
tfp->open(waveform_filename(now)); // Open the dump file
}
}
#endif

// init core
reset_ncycles(10);

Expand Down Expand Up @@ -351,26 +372,6 @@ Emulator::Emulator(int argc, const char *argv[]):
init_db(args.dump_db, (args.select_db != NULL), args.select_db);
#endif

#if VM_TRACE == 1
enable_waveform = args.enable_waveform && !args.enable_fork;
if (enable_waveform) {
Verilated::traceEverOn(true); // Verilator must compute traced signals
#ifdef ENABLE_FST
tfp = new VerilatedFstC;
#else
tfp = new VerilatedVcdC;
#endif
dut_ptr->trace(tfp, 99); // Trace 99 levels of hierarchy
if (args.wave_path != NULL) {
tfp->open(args.wave_path);
}
else {
time_t now = time(NULL);
tfp->open(waveform_filename(now)); // Open the dump file
}
}
#endif

#ifdef VM_SAVABLE
snapshot_slot = new VerilatedSaveMem[2];
if (args.snapshot_path != NULL) {
Expand Down Expand Up @@ -443,7 +444,7 @@ Emulator::Emulator(int argc, const char *argv[]):
Emulator::~Emulator() {
// Simulation ends here, do clean up & display jobs
#if VM_TRACE == 1
if (enable_waveform) tfp->close();
if (args.enable_waveform) tfp->close();
#endif

#if VM_COVERAGE == 1
Expand Down Expand Up @@ -538,7 +539,7 @@ inline void Emulator::reset_ncycles(size_t cycles) {
dut_ptr->eval();

#if VM_TRACE == 1
if (enable_waveform && args.enable_waveform_full && args.log_begin == 0) {
if (args.enable_waveform && args.enable_waveform_full && args.log_begin == 0) {
tfp->dump(2 * i);
}
#endif
Expand All @@ -550,7 +551,7 @@ inline void Emulator::reset_ncycles(size_t cycles) {
dut_ptr->eval();

#if VM_TRACE == 1
if (enable_waveform && args.enable_waveform_full && args.log_begin == 0) {
if (args.enable_waveform && args.enable_waveform_full && args.log_begin == 0) {
tfp->dump(2 * i + 1);
}
#endif
Expand All @@ -574,7 +575,7 @@ inline void Emulator::single_cycle() {
dut_ptr->eval();

#if VM_TRACE == 1
if (enable_waveform) {
if (args.enable_waveform) {
#ifndef CONFIG_NO_DIFFTEST
uint64_t cycle = difftest[0]->get_trap_event()->cycleCnt;
#else
Expand Down Expand Up @@ -613,7 +614,7 @@ inline void Emulator::single_cycle() {
dut_ptr->eval();

#if VM_TRACE == 1
if (enable_waveform && args.enable_waveform_full) {
if (args.enable_waveform && args.enable_waveform_full) {
#ifndef CONFIG_NO_DIFFTEST
uint64_t cycle = difftest[0]->get_trap_event()->cycleCnt;
#else
Expand Down Expand Up @@ -1101,7 +1102,7 @@ void Emulator::fork_child_init() {
tfp->open(cycle_wavefile(cycles, now));
// override output range config, force dump wave
force_dump_wave = true;
enable_waveform = true;
args.enable_waveform = true;
#endif
#ifndef CONFIG_NO_DIFFTEST
#ifdef ENABLE_SIMULATOR_DEBUG_INFO
Expand Down
2 changes: 0 additions & 2 deletions src/test/csrc/verilator/emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class Emulator final : public DUT {
#else
VerilatedVcdC* tfp;
#endif
bool enable_waveform;
bool enable_waveform_full;
bool force_dump_wave = false;
#ifdef VM_SAVABLE
VerilatedSaveMem *snapshot_slot = nullptr;
Expand Down

0 comments on commit dd0c523

Please sign in to comment.