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: df232f540573
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: 8a33d8c868dc
Choose a head ref
  • 3 commits
  • 9 files changed
  • 1 contributor

Commits on Jul 7, 2015

  1. remove workaround

    sbourdeauducq committed Jul 7, 2015
    Copy the full SHA
    d20fb5a View commit details
  2. Copy the full SHA
    a5b6792 View commit details
  3. Copy the full SHA
    8a33d8c View commit details
Showing with 78 additions and 29 deletions.
  1. +8 −4 artiq/coredevice/comm_generic.py
  2. +1 −0 artiq/coredevice/comm_serial.py
  3. +1 −1 artiq/coredevice/core.py
  4. +2 −1 artiq/gateware/rtio/core.py
  5. +42 −0 artiq/test/coredevice.py
  6. +1 −1 soc/runtime/ksupport.c
  7. +11 −8 soc/runtime/main.c
  8. +0 −1 soc/runtime/rtio.c
  9. +12 −13 soc/runtime/session.c
12 changes: 8 additions & 4 deletions artiq/coredevice/comm_generic.py
Original file line number Diff line number Diff line change
@@ -95,7 +95,12 @@ def _read_header(self):
def _write_header(self, length, ty):
self.open()
logger.debug("sending message: type=%r length=%d", ty, length)
self.write(struct.pack(">llB", 0x5a5a5a5a, length, ty.value))
self.write(struct.pack(">ll", 0x5a5a5a5a, length))
if ty is not None:
self.write(struct.pack("B", ty.value))

def reset_session(self):
self._write_header(0, None)

def check_ident(self):
self._write_header(9, _H2DMsgType.IDENT_REQUEST)
@@ -125,9 +130,8 @@ def load(self, kcode):
if ty != _D2HMsgType.LOAD_COMPLETED:
raise IOError("Incorrect reply from device: "+str(ty))

def run(self, kname, reset_now):
self._write_header(len(kname) + 10, _H2DMsgType.RUN_KERNEL)
self.write(struct.pack("B", reset_now))
def run(self, kname):
self._write_header(len(kname) + 9, _H2DMsgType.RUN_KERNEL)
self.write(bytes(kname, "ascii"))
logger.debug("running kernel: %s", kname)

1 change: 1 addition & 0 deletions artiq/coredevice/comm_serial.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ def open(self):
return
self.port = serial.serial_for_url(self.serial_dev,
baudrate=self.baud_rate)
self.reset_session()

def close(self):
if not hasattr(self, "port"):
2 changes: 1 addition & 1 deletion artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ def run(self, k_function, k_args, k_kwargs):
binary, rpc_map, exception_map = self.compile(
k_function, k_args, k_kwargs)
self.comm.load(binary)
self.comm.run(k_function.__name__, self.first_run)
self.comm.run(k_function.__name__)
self.comm.serve(rpc_map, exception_map)
self.first_run = False

3 changes: 2 additions & 1 deletion artiq/gateware/rtio/core.py
Original file line number Diff line number Diff line change
@@ -44,7 +44,8 @@ def __init__(self, width):

# # #

self.sync.rio += self.value_rio.eq(self.value_rio + 1),
# note: counter is in rtio domain and never affected by the reset CSRs
self.sync.rtio += self.value_rio.eq(self.value_rio + 1)
gt = _GrayCodeTransfer(width)
self.submodules += gt
self.comb += gt.i.eq(self.value_rio), self.value_sys.eq(gt.o)
42 changes: 42 additions & 0 deletions artiq/test/coredevice.py
Original file line number Diff line number Diff line change
@@ -147,6 +147,33 @@ def run(self):
self.ttl_out.pulse(25*us)


class TimeKeepsRunning(Experiment, AutoDB):
class DBKeys:
core = Device()
time_at_start = Result()

@kernel
def run(self):
self.time_at_start = now_mu()


class Handover(Experiment, AutoDB):
class DBKeys:
core = Device()
t1 = Result()
t2 = Result()

@kernel
def get_now(self):
self.time_at_start = now_mu()

def run(self):
self.get_now()
self.t1 = self.time_at_start
self.get_now()
self.t2 = self.time_at_start


class CoredeviceTest(ExperimentCase):
def test_rtt(self):
self.execute(RTT)
@@ -192,6 +219,21 @@ def test_watchdog(self):
with self.assertRaises(IOError):
self.execute(Watchdog)

def test_time_keeps_running(self):
self.execute(TimeKeepsRunning)
t1 = self.dbh.get_result("time_at_start").read
self.dbh.close_devices() # a fortiori the core device connection
self.execute(TimeKeepsRunning)
t2 = self.dbh.get_result("time_at_start").read
self.assertGreater(mu_to_seconds(t2 - t1,
self.dbh.get_device("core")),
1*ms)

def test_handover(self):
self.execute(Handover)
self.assertEqual(self.dbh.get_result("t1").read,
self.dbh.get_result("t2").read)


class RPCTiming(Experiment, AutoDB):
class DBKeys:
2 changes: 1 addition & 1 deletion soc/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ long long int now_init(void)

if(now < 0) {
rtio_init();
now = 125000;
now = rtio_get_counter() + 125000;
}

return now;
19 changes: 11 additions & 8 deletions soc/runtime/main.c
Original file line number Diff line number Diff line change
@@ -151,16 +151,18 @@ static void regular_main(void)

#else /* CSR_ETHMAC_BASE */

static void reset_serial_session(void)
static void reset_serial_session(int signal)
{
int i;

session_end();
/* Signal end-of-session inband with zero length packet. */
for(i=0;i<4;i++)
uart_write(0x5a);
for(i=0;i<4;i++)
uart_write(0x00);
if(signal) {
/* Signal end-of-session inband with zero length packet. */
for(i=0;i<4;i++)
uart_write(0x5a);
for(i=0;i<4;i++)
uart_write(0x00);
}
session_start();
}

@@ -181,7 +183,8 @@ static void serial_service(void)
if(r > 0)
rxpending = 0;
if(r < 0)
reset_serial_session();
/* do not signal if reset was requested by host */
reset_serial_session(r != -2);
}

session_poll((void **)&txdata, &txlen);
@@ -191,7 +194,7 @@ static void serial_service(void)
session_ack_data(txlen);
session_ack_mem(txlen);
} else if(txlen < 0)
reset_serial_session();
reset_serial_session(1);
}

static void regular_main(void)
1 change: 0 additions & 1 deletion soc/runtime/rtio.c
Original file line number Diff line number Diff line change
@@ -14,4 +14,3 @@ long long int rtio_get_counter(void)
rtio_counter_update_write(1);
return rtio_counter_read();
}

25 changes: 12 additions & 13 deletions soc/runtime/session.c
Original file line number Diff line number Diff line change
@@ -70,11 +70,13 @@ void session_start(void)
memset(&buffer_out[4], 0, 4);
kloader_stop();
user_kernel_state = USER_KERNEL_NONE;
now = -1;
}

void session_end(void)
{
kloader_stop();
now = -1;
kloader_start_idle_kernel();
}

@@ -189,10 +191,7 @@ static int process_input(void)
}
buffer_in[buffer_in_index] = 0;

if(buffer_in[9])
now = -1;

k = kloader_find((char *)&buffer_in[10]);
k = kloader_find((char *)&buffer_in[9]);
if(k == NULL) {
log("Failed to find kernel entry point '%s' in object", &buffer_in[9]);
buffer_out[8] = REMOTEMSG_TYPE_KERNEL_STARTUP_FAILED;
@@ -217,11 +216,6 @@ static int process_input(void)
memcpy(&reply.eid, &buffer_in[9], 4);
memcpy(&reply.retval, &buffer_in[13], 4);
mailbox_send_and_wait(&reply);
/* HACK/FIXME: workaround for intermittent crashes that happen when running rpc_timing with comm_tcp */
int i;
for(i=0;i<100000;i++)
__asm__ volatile("l.nop");
/* */
user_kernel_state = USER_KERNEL_RUNNING;
break;
}
@@ -316,6 +310,9 @@ int session_input(void *data, int len)
/* receiving length */
buffer_in[buffer_in_index++] = _data[consumed];
consumed++; len--;
if((buffer_in_index == 8) && (get_in_packet_len() == 0))
/* zero-length packet = session reset */
return -2;
} else {
/* receiving payload */
int packet_len;
@@ -470,12 +467,14 @@ static int send_rpc_request(int rpc_num, va_list args)
/* assumes output buffer is empty when called */
static int process_kmsg(struct msg_base *umsg)
{
if(user_kernel_state != USER_KERNEL_RUNNING) {
log("Received message from kernel CPU while not in running state");
return 0;
}
if(!validate_kpointer(umsg))
return 0;
if((user_kernel_state != USER_KERNEL_RUNNING)
&& (umsg->type != MESSAGE_TYPE_NOW_INIT_REQUEST)
&& (umsg->type != MESSAGE_TYPE_NOW_SAVE)) {
log("Received unexpected message from kernel CPU while not in running state");
return 0;
}

switch(umsg->type) {
case MESSAGE_TYPE_NOW_INIT_REQUEST: {