summaryrefslogtreecommitdiff
path: root/software/dhrystone
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2017-01-03 17:45:33 -0800
committerAndrew Waterman <andrew@sifive.com>2017-01-03 18:53:28 -0800
commit005b1a8f84ff743710ebd693b70d208da583098d (patch)
treeebc479178e5e74a3a7ecd5e6e99e3b1cc2a06fb9 /software/dhrystone
parent2398dfda399f445cf114e29b61d9331fddb09b4e (diff)
Regularize timing code
Provide get_timer_value() and get_timer_freq() and use them. On Arty, they use mcycle and the known-fixed core frequency, whereas on HiFive1 they use mtime and the known-fixed mtime frequency.
Diffstat (limited to 'software/dhrystone')
-rw-r--r--software/dhrystone/dhry_stubs.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/software/dhrystone/dhry_stubs.c b/software/dhrystone/dhry_stubs.c
index d3bd14c..0616f86 100644
--- a/software/dhrystone/dhry_stubs.c
+++ b/software/dhrystone/dhry_stubs.c
@@ -3,16 +3,13 @@
/* The functions in this file are only meant to support Dhrystone on an
* embedded RV32 system and are obviously incorrect in general. */
-// return the cycle counter as though it were the current time
long time(void)
{
- long t;
- asm volatile ("csrr %0, mcycle" : "=r" (t));
- return t / (get_cpu_freq() / 1000);
+ return get_timer_value() / get_timer_freq();
}
// set the number of dhrystone iterations
void __wrap_scanf(const char* fmt, int* n)
{
- *n = 1500000;
+ *n = 100000000;
}