test.coredevice.rtio: simplify.

This commit is contained in:
whitequark 2015-09-01 08:38:53 -06:00
parent 995245b786
commit 3af54f5ffc
1 changed files with 12 additions and 33 deletions

View File

@ -10,9 +10,6 @@ class RTT(EnvExperiment):
self.attr_device("core") self.attr_device("core")
self.attr_device("ttl_inout") self.attr_device("ttl_inout")
def set_rtt(self, rtt):
self.set_result("rtt", rtt)
@kernel @kernel
def run(self): def run(self):
self.ttl_inout.output() self.ttl_inout.output()
@ -25,7 +22,7 @@ class RTT(EnvExperiment):
delay(1*us) delay(1*us)
t0 = now_mu() t0 = now_mu()
self.ttl_inout.pulse(1*us) self.ttl_inout.pulse(1*us)
self.set_rtt(mu_to_seconds(self.ttl_inout.timestamp_mu() - t0)) self.set_result("rtt", mu_to_seconds(self.ttl_inout.timestamp_mu() - t0))
class Loopback(EnvExperiment): class Loopback(EnvExperiment):
@ -34,9 +31,6 @@ class Loopback(EnvExperiment):
self.attr_device("loop_in") self.attr_device("loop_in")
self.attr_device("loop_out") self.attr_device("loop_out")
def set_rtt(self, rtt):
self.set_result("rtt", rtt)
@kernel @kernel
def run(self): def run(self):
self.loop_in.input() self.loop_in.input()
@ -47,7 +41,7 @@ class Loopback(EnvExperiment):
delay(1*us) delay(1*us)
t0 = now_mu() t0 = now_mu()
self.loop_out.pulse(1*us) self.loop_out.pulse(1*us)
self.set_rtt(mu_to_seconds(self.loop_in.timestamp_mu() - t0)) self.set_result("rtt", mu_to_seconds(self.loop_in.timestamp_mu() - t0))
class ClockGeneratorLoopback(EnvExperiment): class ClockGeneratorLoopback(EnvExperiment):
@ -56,9 +50,6 @@ class ClockGeneratorLoopback(EnvExperiment):
self.attr_device("loop_clock_in") self.attr_device("loop_clock_in")
self.attr_device("loop_clock_out") self.attr_device("loop_clock_out")
def set_count(self, count):
self.set_result("count", count)
@kernel @kernel
def run(self): def run(self):
self.loop_clock_in.input() self.loop_clock_in.input()
@ -69,7 +60,7 @@ class ClockGeneratorLoopback(EnvExperiment):
with sequential: with sequential:
delay(200*ns) delay(200*ns)
self.loop_clock_out.set(1*MHz) self.loop_clock_out.set(1*MHz)
self.set_count(self.loop_clock_in.count()) self.set_result("count", self.loop_clock_in.count())
class PulseRate(EnvExperiment): class PulseRate(EnvExperiment):
@ -77,9 +68,6 @@ class PulseRate(EnvExperiment):
self.attr_device("core") self.attr_device("core")
self.attr_device("loop_out") self.attr_device("loop_out")
def set_pulse_rate(self, pulse_rate):
self.set_result("pulse_rate", pulse_rate)
@kernel @kernel
def run(self): def run(self):
dt = seconds_to_mu(1000*ns) dt = seconds_to_mu(1000*ns)
@ -92,7 +80,7 @@ class PulseRate(EnvExperiment):
dt += 1 dt += 1
self.core.break_realtime() self.core.break_realtime()
else: else:
self.set_pulse_rate(mu_to_seconds(2*dt)) self.set_result("pulse_rate", mu_to_seconds(2*dt))
break break
@ -113,9 +101,6 @@ class LoopbackCount(EnvExperiment):
self.attr_device("ttl_inout") self.attr_device("ttl_inout")
self.attr_argument("npulses") self.attr_argument("npulses")
def set_count(self, count):
self.set_result("count", count)
@kernel @kernel
def run(self): def run(self):
self.ttl_inout.output() self.ttl_inout.output()
@ -126,7 +111,7 @@ class LoopbackCount(EnvExperiment):
for i in range(self.npulses): for i in range(self.npulses):
delay(25*ns) delay(25*ns)
self.ttl_inout.pulse(25*ns) self.ttl_inout.pulse(25*ns)
self.set_count(self.ttl_inout.count()) self.set_result("count", self.ttl_inout.count())
class Underflow(EnvExperiment): class Underflow(EnvExperiment):
@ -158,12 +143,9 @@ class TimeKeepsRunning(EnvExperiment):
def build(self): def build(self):
self.attr_device("core") self.attr_device("core")
def set_time_at_start(self, time_at_start) -> TNone:
self.set_result("time_at_start", time_at_start)
@kernel @kernel
def run(self): def run(self):
self.set_time_at_start(now_mu()) self.set_result("time_at_start", now_mu())
class Handover(EnvExperiment): class Handover(EnvExperiment):
@ -171,15 +153,12 @@ class Handover(EnvExperiment):
self.attr_device("core") self.attr_device("core")
@kernel @kernel
def get_now(self): def get_now(self, var):
self.time_at_start = now_mu() self.set_result(var, now_mu())
def run(self): def run(self):
self.time_at_start = int(0, width=64) self.get_now("t1")
self.get_now() self.get_now("t2")
self.set_result("t1", self.time_at_start)
self.get_now()
self.set_result("t2", self.time_at_start)
class CoredeviceTest(ExperimentCase): class CoredeviceTest(ExperimentCase):
@ -248,14 +227,14 @@ class RPCTiming(EnvExperiment):
self.attr_device("core") self.attr_device("core")
self.attr_argument("repeats", FreeValue(100)) self.attr_argument("repeats", FreeValue(100))
def nop(self, x) -> TNone: def nop(self):
pass pass
@kernel @kernel
def bench(self): def bench(self):
for i in range(self.repeats): for i in range(self.repeats):
t1 = self.core.get_rtio_counter_mu() t1 = self.core.get_rtio_counter_mu()
self.nop(1) self.nop()
t2 = self.core.get_rtio_counter_mu() t2 = self.core.get_rtio_counter_mu()
self.ts[i] = mu_to_seconds(t2 - t1) self.ts[i] = mu_to_seconds(t2 - t1)