From 1d7914a20acf6ada865b356c50ef6ed69ff56835 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 12 Apr 2020 09:45:52 +0800 Subject: [PATCH] add simple ARTIQ kernel --- .gitignore | 1 + examples/blink_forever.py | 14 ++++++++++++++ examples/device_db.py | 38 ++++++++++++++++++++++++++++++++++++++ shell.nix | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 examples/blink_forever.py create mode 100644 examples/device_db.py diff --git a/.gitignore b/.gitignore index 5a57948..05b3413 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ runtime/src/pl.rs target/ +__pycache__ diff --git a/examples/blink_forever.py b/examples/blink_forever.py new file mode 100644 index 0000000..52a66de --- /dev/null +++ b/examples/blink_forever.py @@ -0,0 +1,14 @@ +from artiq.experiment import * + + +class BlinkForever(EnvExperiment): + def build(self): + self.setattr_device("core") + self.setattr_device("led0") + + @kernel + def run(self): + self.core.reset() + while True: + self.led0.pulse(100*ms) + delay(100*ms) diff --git a/examples/device_db.py b/examples/device_db.py new file mode 100644 index 0000000..110c19f --- /dev/null +++ b/examples/device_db.py @@ -0,0 +1,38 @@ +device_db = { + "core": { + "type": "local", + "module": "artiq.coredevice.core", + "class": "Core", + "arguments": { + "host": "192.168.1.52", + "ref_period": 1e-9, + "ref_multiplier": 1, + "target": "cortexa9" + } + }, + + "led0": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 0}, + }, + "led1": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 1}, + }, + "led2": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 2} + }, + "led3": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLInOut", + "arguments": {"channel": 3} + }, +} diff --git a/shell.nix b/shell.nix index 5184b66..e3ba2e6 100644 --- a/shell.nix +++ b/shell.nix @@ -36,12 +36,12 @@ in rustcSrc pkgs.cargo-xbuild - pkgs.pkgsCross.armv7l-hf-multiplatform.buildPackages.gcc pkgs.openocd pkgs.gdb (pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ]))) vivado + artiqpkgs.binutils-arm ]; XARGO_RUST_SRC = "${rustcSrc}/src";