Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 754a06c62314
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5e994071ce3c
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 14, 2014

  1. Copy the full SHA
    d22c306 View commit details
  2. examples: add RTIO skew

    sbourdeauducq committed Oct 14, 2014
    Copy the full SHA
    5e99407 View commit details
Showing with 47 additions and 1 deletion.
  1. +10 −0 artiq/devices/rtio_core.py
  2. +36 −0 examples/rtio_skew.py
  3. +1 −1 soc/runtime/rtio.c
10 changes: 10 additions & 0 deletions artiq/devices/rtio_core.py
Original file line number Diff line number Diff line change
@@ -137,3 +137,13 @@ def count(self):
while syscall("rtio_get", self.channel) >= 0:
count += 1
return count

@kernel
def timestamp(self):
"""Poll the RTIO input and returns an event timestamp, according to
the gating.
If the gate is permanently closed, returns a negative value.
"""
return cycles_to_time(syscall("rtio_get", self.channel))
36 changes: 36 additions & 0 deletions examples/rtio_skew.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from artiq import *
from artiq.devices import corecom_serial, core, rtio_core


def print_skew(p):
print("Input/output skew: {} ns".format(p))


def print_failed():
print("Pulse was not received back")


class RTIOSkew(AutoContext):
parameters = "i o"

@kernel
def run(self):
with parallel:
self.i.gate_rising(10*us)
with sequential:
delay(5*us)
out_t = now()
self.o.pulse(5*us)
in_t = self.i.timestamp()
if in_t < 0*s:
print_failed()
else:
print_skew(int((out_t - in_t)/(1*ns)))

if __name__ == "__main__":
with corecom_serial.CoreCom() as com:
coredev = core.Core(com)
exp = RTIOSkew(core=coredev,
i=rtio_core.RTIOIn(core=coredev, channel=0),
o=rtio_core.RTIOOut(core=coredev, channel=1))
exp.run()
2 changes: 1 addition & 1 deletion soc/runtime/rtio.c
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ 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_readable_read()) {
r = rtio_i_value_read();
r = rtio_i_timestamp_read();
rtio_i_re_write(1);
return r;
}