From 7ab762a17492508e201c71f13f5340e5e5132b4c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 24 Sep 2021 14:45:44 +0800 Subject: [PATCH] demo: add more syscalls and features --- nac3embedded/demo.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/nac3embedded/demo.py b/nac3embedded/demo.py index 532c623d..a5581783 100644 --- a/nac3embedded/demo.py +++ b/nac3embedded/demo.py @@ -2,6 +2,21 @@ from language import * 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 def rtio_init(): 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: 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 class Demo: @kernel def run(self): + core = Core() + + core.reset() rtio_init()