From 5105b88302b4b1e94c68030832c77d1ba1a78e81 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 21 Oct 2014 23:41:02 +0800 Subject: [PATCH] rtio: raise input overflow exception --- artiq/coredevice/runtime_exceptions.py | 11 ++++++++++- soc/runtime/exceptions.h | 3 ++- soc/runtime/rtio.c | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/artiq/coredevice/runtime_exceptions.py b/artiq/coredevice/runtime_exceptions.py index fe3521470..5d2fcef08 100644 --- a/artiq/coredevice/runtime_exceptions.py +++ b/artiq/coredevice/runtime_exceptions.py @@ -13,7 +13,8 @@ class OutOfMemory(RuntimeException): class RTIOUnderflow(RuntimeException): - """Raised when the CPU fails to submit a RTIO event early enough (with respect to the event's timestamp). + """Raised when the CPU fails to submit a RTIO event early enough + (with respect to the event's timestamp). """ eid = 1 @@ -28,6 +29,14 @@ class RTIOSequenceError(RuntimeException): eid = 2 +class RTIOOverflow(RuntimeException): + """Raised when at least one event could not be registered into the RTIO + input FIFO because it was full (CPU not reading fast enough). + + """ + eid = 3 + + exception_map = {e.eid: e for e in globals().values() if inspect.isclass(e) and issubclass(e, RuntimeException) diff --git a/soc/runtime/exceptions.h b/soc/runtime/exceptions.h index bc53ea487..39a2ef9e8 100644 --- a/soc/runtime/exceptions.h +++ b/soc/runtime/exceptions.h @@ -4,7 +4,8 @@ enum { EID_OUT_OF_MEMORY = 0, EID_RTIO_UNDERFLOW = 1, - EID_RTIO_SEQUENCE_ERROR = 2 + EID_RTIO_SEQUENCE_ERROR = 2, + EID_RTIO_OVERFLOW = 3, }; int exception_setjmp(void *jb) __attribute__((returns_twice)); diff --git a/soc/runtime/rtio.c b/soc/runtime/rtio.c index 07148a961..06d2d0622 100644 --- a/soc/runtime/rtio.c +++ b/soc/runtime/rtio.c @@ -59,6 +59,11 @@ long long int rtio_get(int channel) rtio_chan_sel_write(channel); while(rtio_i_readable_read() || (rtio_o_level_read() != 0)) { + if(rtio_i_overflow_read()) { + rtio_reset_logic_write(1); + rtio_reset_logic_write(0); + exception_raise(EID_RTIO_OVERFLOW); + } if(rtio_i_readable_read()) { r = rtio_i_timestamp_read(); rtio_i_re_write(1);