From 010f10307d68b9502beb53ba5251931d945d59c9 Mon Sep 17 00:00:00 2001 From: Arthur Chen Date: Sat, 4 Nov 2023 18:55:51 +0100 Subject: [PATCH] Refactor and fix formatting --- target/common/test/verilator_lib.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/common/test/verilator_lib.cc b/target/common/test/verilator_lib.cc index 788d59bdd..4b9b18a12 100644 --- a/target/common/test/verilator_lib.cc +++ b/target/common/test/verilator_lib.cc @@ -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 + +const int TIME_CYCLES_TO_TIMESTAMP = 500; void sim_thread_main(void *arg) { ((Sim *)arg)->main(); } // Sim time. @@ -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 + - 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) {