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: ac5061c205df
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: dbc0a89903e3
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 18, 2016

  1. Bring back target print function.

    whitequark committed Mar 18, 2016
    Copy the full SHA
    f4ab507 View commit details
  2. dds.c: turn off batch mode before an underflow can be raised.

    Fixes #334.
    whitequark committed Mar 18, 2016
    Copy the full SHA
    dbc0a89 View commit details
Showing with 42 additions and 3 deletions.
  1. +1 −0 artiq/compiler/prelude.py
  2. +2 −0 artiq/compiler/targets.py
  3. +3 −2 artiq/compiler/transforms/llvm_ir_generator.py
  4. +1 −1 artiq/runtime/dds.c
  5. +2 −0 artiq/runtime/ksupport.c
  6. +33 −0 artiq/test/coredevice/test_rtio.py
1 change: 1 addition & 0 deletions artiq/compiler/prelude.py
Original file line number Diff line number Diff line change
@@ -47,4 +47,5 @@ def globals():

# ARTIQ utility functions
"rtio_log": builtins.fn_rtio_log(),
"core_log": builtins.fn_print(),
}
2 changes: 2 additions & 0 deletions artiq/compiler/targets.py
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@ class Target:
triple = "unknown"
data_layout = ""
features = []
print_function = "printf"


def __init__(self):
@@ -195,3 +196,4 @@ class OR1KTarget(Target):
triple = "or1k-linux"
data_layout = "E-m:e-p:32:32-i64:32-f64:32-v64:32-v128:32-a:0:32-n32"
features = ["mul", "div", "ffl1", "cmov", "addc"]
print_function = "core_log"
5 changes: 3 additions & 2 deletions artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -358,7 +358,7 @@ def llbuiltin(self, name):
llty = ll.FunctionType(llptr, [])
elif name == "llvm.stackrestore":
llty = ll.FunctionType(llvoid, [llptr])
elif name == "printf":
elif name == self.target.print_function:
llty = ll.FunctionType(llvoid, [llptr], var_arg=True)
elif name == "rtio_log":
llty = ll.FunctionType(llvoid, [lli64, llptr], var_arg=True)
@@ -904,7 +904,8 @@ def get_outer(llenv, env_ty):
elif insn.op in ("printf", "rtio_log"):
# We only get integers, floats, pointers and strings here.
llargs = map(self.map, insn.operands)
return self.llbuilder.call(self.llbuiltin(insn.op), llargs,
func_name = self.target.print_function if insn.op == "printf" else insn.op
return self.llbuilder.call(self.llbuiltin(func_name), llargs,
name=insn.name)
elif insn.op == "exncast":
# This is an identity cast at LLVM IR level.
2 changes: 1 addition & 1 deletion artiq/runtime/dds.c
Original file line number Diff line number Diff line change
@@ -192,6 +192,7 @@ void dds_batch_exit(void)

if(!batch_mode)
artiq_raise_from_c("DDSBatchError", "DDS batch error", 0, 0, 0);
batch_mode = 0;
/* + FUD time */
now = batch_ref_time - batch_count*(DURATION_PROGRAM + DURATION_WRITE);
for(i=0;i<batch_count;i++) {
@@ -201,7 +202,6 @@ void dds_batch_exit(void)
batch[i].amplitude);
now += DURATION_PROGRAM + DURATION_WRITE;
}
batch_mode = 0;
}

void dds_set(long long int timestamp, int bus_channel, int channel,
2 changes: 2 additions & 0 deletions artiq/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -97,6 +97,8 @@ static const struct symbol runtime_exports[] = {
{"abort", &ksupport_abort},

/* proxified syscalls */
{"core_log", &core_log},

{"now", &now},

{"watchdog_set", &watchdog_set},
33 changes: 33 additions & 0 deletions artiq/test/coredevice/test_rtio.py
Original file line number Diff line number Diff line change
@@ -102,6 +102,32 @@ def run(self):
break


class PulseRateDDS(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("core_dds")
self.setattr_device("dds0")
self.setattr_device("dds1")

@kernel
def run(self):
dt = seconds_to_mu(150*us)
while True:
try:
delay(10*ms)
for i in range(100):
with self.core_dds.batch:
self.dds0.set(100*MHz)
self.dds1.set(100*MHz)
delay_mu(dt)
except RTIOUnderflow:
dt += 100
self.core.break_realtime()
else:
self.set_dataset("pulse_rate", mu_to_seconds(2*dt))
break


class Watchdog(EnvExperiment):
def build(self):
self.setattr_device("core")
@@ -228,6 +254,13 @@ def test_pulse_rate(self):
self.assertGreater(rate, 100*ns)
self.assertLess(rate, 2500*ns)

def test_pulse_rate_dds(self):
self.execute(PulseRateDDS)
rate = self.dataset_mgr.get("pulse_rate")
print(rate)
self.assertGreater(rate, 100*us)
self.assertLess(rate, 2500*us)

def test_loopback_count(self):
npulses = 2
self.execute(LoopbackCount, npulses=npulses)