Skip to content

Commit

Permalink
Refactor and fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Raragyay committed Nov 4, 2023
1 parent eebc97a commit 010f103
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions target/common/test/verilator_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ namespace sim {

// Number of cycles between HTIF checks.
const int HTIFTimeInterval = 200;

// We want to return timestamp in picosecond accuracy, assuming that one cycle
// takes 1ns Since 1 cycle takes 2 sim::TIME increments, scale by 500 to get
// time = cycle * 1000 + <some constant>
const int TIME_CYCLES_TO_TIMESTAMP = 500;
void sim_thread_main(void *arg) { ((Sim *)arg)->main(); }

// Sim time.
Expand Down Expand Up @@ -78,11 +83,7 @@ void Sim::main() {
} // namespace sim

// Verilator callback to get the current time.
double sc_time_stamp() {
// We want to return timestamp in picosecond accuracy, assuming that one cycle takes 1ns
// Since 1 cycle takes 2 time increments, scale by 500 to get time = cycle * 1000 + <some constant>
return sim::TIME * 500;
}
double sc_time_stamp() { return sim::TIME * TIME_CYCLES_TO_TIMESTAMP; }

// DPI calls.
void tb_memory_read(long long addr, int len, const svOpenArrayHandle data) {
Expand Down

0 comments on commit 010f103

Please sign in to comment.