Judging from the survey results, it seems a number of people have trouble with RTIOUnderflow and want a graphical tool to display slack.
Such functionality already exists through artiq_coreanalyzer
and GtkWave (development of the few patches required to make it work on the GtkWave side was funded by Joe a long time ago).
Take the following experiment:
from artiq.experiment import *
class BlinkForever(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("led")
@kernel
def run(self):
self.core.reset()
while True:
self.led.pulse(.1*us)
delay(.1*us)
which underflows:
> artiq_run repository/blink_forever.py
Core Device Traceback (most recent call last):
File "repository/blink_forever.py", line 13, in artiq_run_blink_forever.BlinkForever.run(..., ...) (RA=+0x3e4)
self.led.pulse(.1*us)
File "<artiq>/coredevice/ttl.py", line 79, in ... artiq.coredevice.ttl.TTLOut.pulse<artiq.coredevice.ttl.TTLOut>(...) (inlined)
self.on()
File "<artiq>/coredevice/ttl.py", line 53, in ... artiq.coredevice.ttl.TTLOut.on<artiq.coredevice.ttl.TTLOut>(...) (inlined)
self.set_o(True)
File "<artiq>/coredevice/ttl.py", line 45, in ... artiq.coredevice.ttl.TTLOut.set_o<artiq.coredevice.ttl.TTLOut>(...) (inlined)
rtio_output(self.target_o, 1 if o else 0)
File "ksupport/rtio.rs", line 67, column 14, in (Rust function)
<unknown>
^
artiq.coredevice.exceptions.RTIOUnderflow(0): RTIO underflow at 269814732751296 mu, channel 19, slack -280 mu
Traceback (most recent call last):
File "/nix/store/28b9qy0b45zwdk9rdszf82n5m7pdc001-python3.8-artiq-7.7613.eb38b664.beta/bin/.artiq_run-wrapped", line 9, in <module>
sys.exit(main())
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/frontend/artiq_run.py", line 225, in main
return run(with_file=True)
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/frontend/artiq_run.py", line 211, in run
raise exn
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/frontend/artiq_run.py", line 204, in run
exp_inst.run()
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/language/core.py", line 54, in run_on_core
return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/coredevice/core.py", line 137, in run
self.comm.serve(embedding_map, symbolizer, demangler)
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/coredevice/comm_kernel.py", line 644, in serve
self._serve_exception(embedding_map, symbolizer, demangler)
File "/nix/store/3ids0mmd1wbdsm7ahrjr1r8bv5ak3x1s-python3-3.8.8-env/lib/python3.8/site-packages/artiq/coredevice/comm_kernel.py", line 636, in _serve_exception
raise python_exn
artiq.coredevice.exceptions.RTIOUnderflow: RTIO underflow at 269814732751296 mu, channel 19, slack -280 mu
You can then get a VCD trace of the event using:
artiq_coreanalyzer -w underflow.vcd
The VCD file can then be opened in GtkWave. In the signal list, select rtio_slack[63:0]
and ttl/led
, then click Append
. Then right click rtio_slack[63:0]
in the graph legend, and select Data Format > BitsToReal
followed by Data Format>Analog>Step
(or "Interpolated" if you want a smoother display).
The RTIO slack is then plotted alongside the TTL state:

Under the hood, the value of the RTIO timestamp counter (TSC) is stored when an event is submitted. Then, at each event, the difference between the TSC and the time of the event is plotted as rtio_slack
.
Let's look at a more interesting example:
@kernel
def run(self):
self.core.reset()
for i in range(10):
for i in range(30):
self.led.pulse(10*ns)
delay(10*ns)
delay(50*us)
for i in range(30):
self.led.pulse(10*ns)
delay(10*ns)
On the "interpolated" display, the slack can clearly be seen to be consumed by the short pulses, and recovering during the 50-microsecond delay:

It is also possible to look at the actual value of the slack (in seconds) for any given output event, by disabling the "analog" plotting and/or by looking at the value on the left panel:
