From 6861d28d2d84bcf0cfa43f9e3c4cc5bdbf88d1b0 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 12 Sep 2014 15:40:34 +0800 Subject: [PATCH] runtime: support arbitrarily long initial DDS setup time --- artiq/devices/runtime.py | 2 +- soc/runtime/dds.c | 19 ++++++++++++++----- soc/runtime/main.c | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/artiq/devices/runtime.py b/artiq/devices/runtime.py index 87ad677af..9e55002de 100644 --- a/artiq/devices/runtime.py +++ b/artiq/devices/runtime.py @@ -73,7 +73,7 @@ class LinkInterface: class Environment(LinkInterface): def __init__(self, ref_period): self.ref_period = ref_period - self.initial_time = 10000 + self.initial_time = 2000 def emit_object(self): tm = lt.TargetMachine.new(triple="or1k", cpu="generic") diff --git a/soc/runtime/dds.c b/soc/runtime/dds.c index 08aae424d..f148df869 100644 --- a/soc/runtime/dds.c +++ b/soc/runtime/dds.c @@ -18,9 +18,19 @@ #define RTIO_FUD_CHANNEL 4 +static void fud_sync(void) +{ + rtio_chan_sel_write(RTIO_FUD_CHANNEL); + while(rtio_o_level_read() != 0); +} + static void fud(long long int fud_time) { + int r; + + r = rtio_reset_read(); rtio_reset_write(0); + rtio_chan_sel_write(RTIO_FUD_CHANNEL); if(fud_time < 0) { rtio_counter_update_write(1); @@ -32,12 +42,11 @@ static void fud(long long int fud_time) rtio_o_timestamp_write(fud_time+3*8); rtio_o_value_write(0); rtio_o_we_write(1); -} -static void fud_sync(void) -{ - rtio_chan_sel_write(RTIO_FUD_CHANNEL); - while(rtio_o_level_read() != 0); + if(r) { + fud_sync(); + rtio_reset_write(1); + } } void dds_init(void) diff --git a/soc/runtime/main.c b/soc/runtime/main.c index 8250bfcd4..49ba853d2 100644 --- a/soc/runtime/main.c +++ b/soc/runtime/main.c @@ -29,8 +29,8 @@ int main(void) if(length > 0) { k = load_elf(resolve_symbol, "run", kbuf, length, kcode, sizeof(kcode)); if(k != NULL) { - dds_init(); rtio_init(); + dds_init(); flush_cpu_icache(); k(); kernel_finished();