Skip to content

Commit

Permalink
Copy verilator_lib.cc from snax_cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Josse Van Delm committed Nov 27, 2024
1 parent 8c7f2fd commit 3b992d0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions target/rtl/test/verilator_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
// SPDX-License-Identifier: SHL-0.51

#include <printf.h>
#include <filesystem>
#include <string>

#include "Vtestharness.h"
#include "Vtestharness__Dpi.h"
#include "sim.hh"
#include "tb_lib.hh"
#include "verilated.h"
#include "verilated_vcd_c.h"

// Declare these as globally declared (and parsed) in tb_bin.cc
extern bool WRAPPER_disable_tracing;
extern char *WRAPPER_trace_prefix;

namespace sim {

// Number of cycles between HTIF checks.
Expand Down Expand Up @@ -106,6 +113,25 @@ void tb_memory_write(long long addr, int len, const svOpenArrayHandle data,
(const uint8_t *)strb_ptr);
}

svBit disable_tracing() {
// function to enable/disable tracers
return WRAPPER_disable_tracing;
}

const char *get_trace_file_prefix() {
if (WRAPPER_trace_prefix == nullptr) {
// Use the standard prefix, and create a logs directory if necessary
std::string foldername = "logs/";
std::filesystem::create_directories(foldername);
static std::string log_file_name = "logs/";
return log_file_name.c_str();
}
// Return the one parsed from the command line otherwise
else {
return WRAPPER_trace_prefix;
}
}

const long long clint_addr = sim::BOOTDATA.clint_base;
const long num_cores = sim::BOOTDATA.core_count;

Expand Down

0 comments on commit 3b992d0

Please sign in to comment.