diff options
author | Andrew Waterman <andrew@sifive.com> | 2020-02-15 15:41:45 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2020-02-15 15:41:45 -0800 |
commit | a8c83b8190f8ac72b04794c03e68cee873a28f3c (patch) | |
tree | 034385e72f29c1b1a36c681d5fce60055d5eaf10 /riscv | |
parent | 9d7c52c6bba57efe895be88fd3ba6a90e66bd3a8 (diff) | |
download | spike-a8c83b8190f8ac72b04794c03e68cee873a28f3c.zip spike-a8c83b8190f8ac72b04794c03e68cee873a28f3c.tar.gz spike-a8c83b8190f8ac72b04794c03e68cee873a28f3c.tar.bz2 |
Make CLINT API use Hz instead of MHz
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/clint.cc | 6 | ||||
-rw-r--r-- | riscv/devices.h | 4 | ||||
-rw-r--r-- | riscv/sim.cc | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/riscv/clint.cc b/riscv/clint.cc index d68f4cc..aee995b 100644 --- a/riscv/clint.cc +++ b/riscv/clint.cc @@ -2,8 +2,8 @@ #include "devices.h" #include "processor.h" -clint_t::clint_t(std::vector<processor_t*>& procs, uint64_t freq_mhz, bool real_time) - : procs(procs), freq_mhz(freq_mhz), real_time(real_time), mtime(0), mtimecmp(procs.size()) +clint_t::clint_t(std::vector<processor_t*>& procs, uint64_t freq_hz, bool real_time) + : procs(procs), freq_hz(freq_hz), real_time(real_time), mtime(0), mtimecmp(procs.size()) { struct timeval base; @@ -77,7 +77,7 @@ void clint_t::increment(reg_t inc) gettimeofday(&now, NULL); diff_usecs = ((now.tv_sec - real_time_ref_secs) * 1000000) + (now.tv_usec - real_time_ref_usecs); - mtime = diff_usecs * freq_mhz; + mtime = diff_usecs * freq_hz / 1000000; } else { mtime += inc; } diff --git a/riscv/devices.h b/riscv/devices.h index 130be3c..1bc9618 100644 --- a/riscv/devices.h +++ b/riscv/devices.h @@ -63,7 +63,7 @@ class mem_t : public abstract_device_t { class clint_t : public abstract_device_t { public: - clint_t(std::vector<processor_t*>&, uint64_t freq_mhz, bool real_time); + clint_t(std::vector<processor_t*>&, uint64_t freq_hz, bool real_time); bool load(reg_t addr, size_t len, uint8_t* bytes); bool store(reg_t addr, size_t len, const uint8_t* bytes); size_t size() { return CLINT_SIZE; } @@ -73,7 +73,7 @@ class clint_t : public abstract_device_t { typedef uint64_t mtimecmp_t; typedef uint32_t msip_t; std::vector<processor_t*>& procs; - uint64_t freq_mhz; + uint64_t freq_hz; bool real_time; uint64_t real_time_ref_secs; uint64_t real_time_ref_usecs; diff --git a/riscv/sim.cc b/riscv/sim.cc index 96fd0b2..dd7b35d 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -66,7 +66,7 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch, } } - clint.reset(new clint_t(procs, CPU_HZ / INSNS_PER_RTC_TICK / 1000000, real_time_clint)); + clint.reset(new clint_t(procs, CPU_HZ / INSNS_PER_RTC_TICK, real_time_clint)); bus.add_device(CLINT_BASE, clint.get()); } |