tillitis / qemu

Fork of https://gitlab.com/qemu-project/qemu
Other
7 stars 3 forks source link

Timer #5

Closed mchack-work closed 1 year ago

mchack-work commented 1 year ago

Add a timer emulation.

The real timer has two counters: timer and prescaler. The prescaler ticks down to 0 every clock cycle (18 MHz, 55 ns). We don't emulate that. Instead we sleep until the next real timer tick.

Closes #2

mchack-work commented 1 year ago

Currently off by a prescaler cycle from real hardware. Qemu:

% ./cmd/runtimer/runtimer --port /dev/pts/16 --speed 1000000 --timer 10 --prescaler 18000000
Timer expired after 10.010400653 seconds

Real hardware:

Timer expired after 10.973372394 seconds
quite commented 1 year ago

I could run and reproduce this, both on qemu (i've merged the support!) and hw. The --speed 1000000 was for some local test though i suppose

mchack-work commented 1 year ago

Real hardware has now changed to work like the qemu model. Setting --timer 1 --prescaler 18000000 finishes in ~1 second. A prescaler of 36 million doubles it.

quite commented 1 year ago

Merged on the side.