demo: add more syscalls and features

This commit is contained in:
Sebastien Bourdeauducq 2021-09-24 14:45:44 +08:00
parent 7ab2114882
commit 7ab762a174

View File

@ -2,6 +2,21 @@ from language import *
from numpy import int32, int64 from numpy import int32, int64
@syscall
def now_mu() -> int64:
raise NotImplementedError("syscall not simulated")
@syscall
def at_mu(t: int64):
raise NotImplementedError("syscall not simulated")
@syscall
def delay_mu(dt: int64):
raise NotImplementedError("syscall not simulated")
@syscall @syscall
def rtio_init(): def rtio_init():
raise NotImplementedError("syscall not simulated") raise NotImplementedError("syscall not simulated")
@ -26,11 +41,27 @@ def rtio_input_timestamp(timeout_mu: int64, channel: int32) -> int64:
def rtio_input_data(channel: int32) -> int32: def rtio_input_data(channel: int32) -> int32:
raise NotImplementedError("syscall not simulated") raise NotImplementedError("syscall not simulated")
@kernel
class Core:
@kernel
def reset(self):
rtio_init()
at_mu(rtio_get_counter() + int64(125000))
@kernel
def break_realtime(self):
min_now = rtio_get_counter() + int64(125000)
if now_mu() < min_now:
at_mu(min_now)
@kernel @kernel
class Demo: class Demo:
@kernel @kernel
def run(self): def run(self):
core = Core()
core.reset()
rtio_init() rtio_init()