2014-09-29 18:08:58 +08:00
|
|
|
import inspect
|
|
|
|
|
2014-09-29 17:36:35 +08:00
|
|
|
from artiq.language.core import RuntimeException
|
2014-09-25 12:57:26 +08:00
|
|
|
|
|
|
|
|
2014-09-29 17:36:35 +08:00
|
|
|
# Must be kept in sync with soc/runtime/exceptions.h
|
|
|
|
|
2015-04-05 22:04:50 +08:00
|
|
|
class InternalError(RuntimeException):
|
2015-05-08 16:51:54 +08:00
|
|
|
"""Raised when the runtime encounters an internal error condition."""
|
2014-12-20 21:33:22 +08:00
|
|
|
eid = 1
|
|
|
|
|
|
|
|
|
|
|
|
class _RPCException(RuntimeException):
|
|
|
|
eid = 2
|
2014-09-25 12:57:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
class RTIOUnderflow(RuntimeException):
|
2014-10-21 23:41:02 +08:00
|
|
|
"""Raised when the CPU fails to submit a RTIO event early enough
|
|
|
|
(with respect to the event's timestamp).
|
2014-09-30 19:32:11 +08:00
|
|
|
|
2014-12-01 13:57:25 +08:00
|
|
|
The offending event is discarded and the RTIO core keeps operating.
|
2014-09-30 19:32:11 +08:00
|
|
|
"""
|
2014-12-20 21:33:22 +08:00
|
|
|
eid = 3
|
2014-09-25 12:57:26 +08:00
|
|
|
|
2015-03-13 21:55:18 +08:00
|
|
|
def __str__(self):
|
|
|
|
return "at {} on channel {}, violation {}".format(
|
|
|
|
self.p0*self.core.ref_period,
|
|
|
|
self.p1,
|
|
|
|
(self.p2 - self.p0)*self.core.ref_period)
|
|
|
|
|
2014-09-25 12:57:26 +08:00
|
|
|
|
2014-09-30 19:32:11 +08:00
|
|
|
class RTIOSequenceError(RuntimeException):
|
2014-10-21 23:56:12 +08:00
|
|
|
"""Raised when an event is submitted on a given channel with a timestamp
|
|
|
|
not larger than the previous one.
|
2014-09-30 19:32:11 +08:00
|
|
|
|
2014-12-01 13:57:25 +08:00
|
|
|
The offending event is discarded and the RTIO core keeps operating.
|
2014-09-30 19:32:11 +08:00
|
|
|
"""
|
2014-12-20 21:33:22 +08:00
|
|
|
eid = 4
|
2014-09-30 19:32:11 +08:00
|
|
|
|
2015-03-13 21:55:18 +08:00
|
|
|
def __str__(self):
|
|
|
|
return "at {} on channel {}".format(self.p0*self.core.ref_period,
|
|
|
|
self.p1)
|
|
|
|
|
2014-09-30 19:32:11 +08:00
|
|
|
|
2014-10-21 23:41:02 +08:00
|
|
|
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).
|
|
|
|
|
2014-12-01 13:57:25 +08:00
|
|
|
This does not interrupt operations further than cancelling the current
|
|
|
|
read attempt and discarding some events. Reading can be reattempted after
|
|
|
|
the exception is caught, and events will be partially retrieved.
|
2014-10-21 23:41:02 +08:00
|
|
|
"""
|
2014-12-20 21:33:22 +08:00
|
|
|
eid = 5
|
2014-10-21 23:41:02 +08:00
|
|
|
|
2015-03-13 21:55:18 +08:00
|
|
|
def __str__(self):
|
|
|
|
return "on channel {}".format(self.p0)
|
|
|
|
|
2014-10-21 23:41:02 +08:00
|
|
|
|
2015-05-08 16:51:54 +08:00
|
|
|
class DDSBatchError(RuntimeException):
|
|
|
|
"""Raised when attempting to start a DDS batch while already in a batch,
|
|
|
|
or when too many commands are batched.
|
|
|
|
"""
|
|
|
|
eid = 6
|
|
|
|
|
|
|
|
|
2014-09-25 12:57:26 +08:00
|
|
|
exception_map = {e.eid: e for e in globals().values()
|
2014-09-29 18:08:58 +08:00
|
|
|
if inspect.isclass(e)
|
|
|
|
and issubclass(e, RuntimeException)
|
2014-09-25 12:57:26 +08:00
|
|
|
and hasattr(e, "eid")}
|