Skip to content

Commit

Permalink
Scale time as picoseconds instead of half-nanoseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Raragyay committed Oct 25, 2023
1 parent 5b7080a commit 1cd8832
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion target/common/test/verilator_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const int HTIFTimeInterval = 200;
void sim_thread_main(void *arg) { ((Sim *)arg)->main(); }

// Sim time.
int TIME = 0;
vluint64_t TIME = 0;

Sim::Sim(int argc, char **argv) : htif_t(argc, argv), ipc(argc, argv) {
// Search arguments for `--vcd` flag and enable waves if requested
Expand Down Expand Up @@ -78,7 +78,15 @@ void Sim::main() {
} // namespace sim

// Verilator callback to get the current time.
<<<<<<< Updated upstream
double sc_time_stamp() { return sim::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;
}
>>>>>>> Stashed changes

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

0 comments on commit 1cd8832

Please sign in to comment.