runtime/hifive1: use CLINT peripheral for timekeeping

The CLINT is implemented both on the fe310-g002 chip and in the sifive_e
QEMU machine type. Therefore, use that peripheral for consistency.

The only difference is the clock speed, which runs at 10MHz in QEMU for
some reason instead of 32.768kHz as on the physical HiFive1 boards.
This commit is contained in:
Ayke van Laethem
2020-01-08 17:48:34 +01:00
committed by Ron Evans
parent 3e521f710a
commit ed9b2dbc03
3 changed files with 27 additions and 37 deletions
+2 -10
View File
@@ -7,6 +7,8 @@ import (
"unsafe"
)
const tickMicros = 100 // CLINT.MTIME increments every 100ns
// Special memory-mapped device to exit tests, created by SiFive.
var testExit = (*volatile.Register32)(unsafe.Pointer(uintptr(0x100000)))
@@ -16,13 +18,3 @@ func abort() {
// Signal a successful exit.
testExit.Set(0x5555)
}
func ticks() timeUnit {
return timestamp
}
func sleepTicks(d timeUnit) {
// Note: QEMU doesn't seem to support the RTC peripheral at the time of
// writing so just simulate sleeping here.
timestamp += d
}