Skip to content

Commit

Permalink
refactor device/parameter management, immediate parameter updates, st…
Browse files Browse the repository at this point in the history
…art introducing results
sbourdeauducq committed Jan 12, 2015
1 parent c938e3f commit 891c0d1
Showing 31 changed files with 497 additions and 508 deletions.
2 changes: 1 addition & 1 deletion artiq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from artiq.language.core import *
from artiq.language.context import *
from artiq.language.db import *
from artiq.language.units import check_unit
from artiq.language.units import ps, ns, us, ms, s
from artiq.language.units import Hz, kHz, MHz, GHz
7 changes: 4 additions & 3 deletions artiq/coredevice/comm_dummy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from operator import itemgetter

from artiq.language.context import AutoContext
from artiq.language.db import AutoDB
from artiq.language.units import ms, ns
from artiq.coredevice.runtime import LinkInterface

@@ -14,8 +14,9 @@ def emit_object(self):
return str(self.llvm_module)


class Comm(AutoContext):
implicit_core = False
class Comm(AutoDB):
class DBKeys:
implicit_core = False

def get_runtime_env(self):
return _RuntimeEnvironment(1*ns)
11 changes: 6 additions & 5 deletions artiq/coredevice/comm_serial.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

from artiq.language import core as core_language
from artiq.language import units
from artiq.language.context import *
from artiq.language.db import *
from artiq.coredevice.runtime import Environment
from artiq.coredevice import runtime_exceptions
from artiq.coredevice.rpc_wrapper import RPCWrapper
@@ -60,10 +60,11 @@ def _read_exactly(f, n):
return r


class Comm(AutoContext):
serial_dev = Parameter("/dev/ttyUSB1")
baud_rate = Parameter(115200)
implicit_core = False
class Comm(AutoDB):
class DBKeys:
serial_dev = Parameter("/dev/ttyUSB1")
baud_rate = Parameter(115200)
implicit_core = False

def build(self):
self.port = serial.Serial(self.serial_dev, baudrate=115200)
11 changes: 6 additions & 5 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from artiq.language.core import *
from artiq.language.context import *
from artiq.language.db import *

from artiq.transforms.inline import inline
from artiq.transforms.lower_units import lower_units
@@ -44,10 +44,11 @@ def _no_debug_unparse(label, node):
pass


class Core(AutoContext):
comm = Device("comm")
external_clock = Parameter(None)
implicit_core = False
class Core(AutoDB):
class DBKeys:
comm = Device()
external_clock = Parameter(None)
implicit_core = False

def build(self):
self.runtime_env = self.comm.get_runtime_env()
13 changes: 7 additions & 6 deletions artiq/coredevice/dds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from artiq.language.core import *
from artiq.language.context import *
from artiq.language.db import *
from artiq.language.units import *
from artiq.coredevice import rtio

@@ -10,7 +10,7 @@
PHASE_MODE_TRACKING = 2


class DDS(AutoContext):
class DDS(AutoDB):
"""Core device Direct Digital Synthesis (DDS) driver.
Controls DDS devices managed directly by the core device's runtime. It also
@@ -24,15 +24,16 @@ class DDS(AutoContext):
the DDS device.
"""
dds_sysclk = Parameter(1*GHz)
reg_channel = Parameter()
rtio_switch = Parameter()
class DBKeys:
dds_sysclk = Parameter(1*GHz)
reg_channel = Argument()
rtio_switch = Argument()

def build(self):
self.previous_on = False
self.previous_frequency = 0*MHz
self.set_phase_mode(PHASE_MODE_CONTINUOUS)
self.sw = rtio.RTIOOut(self, channel=self.rtio_switch)
self.sw = rtio.RTIOOut(core=self.core, channel=self.rtio_switch)

@portable
def frequency_to_ftw(self, frequency):
7 changes: 4 additions & 3 deletions artiq/coredevice/gpio.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from artiq.language.core import *
from artiq.language.context import *
from artiq.language.db import *


class GPIOOut(AutoContext):
channel = Parameter()
class GPIOOut(AutoDB):
class DBKeys:
channel = Argument()

@kernel
def on(self):
12 changes: 7 additions & 5 deletions artiq/coredevice/rtio.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from artiq.language.core import *
from artiq.language.context import *
from artiq.language.db import *


class LLRTIOOut(AutoContext):
class LLRTIOOut(AutoDB):
"""Low-level RTIO output driver.
Allows setting RTIO outputs at arbitrary times, without time unit
@@ -12,7 +12,8 @@ class LLRTIOOut(AutoContext):
``RTIOOut`` instead.
"""
channel = Parameter()
class DBKeys:
channel = Argument()

def build(self):
self._set_oe()
@@ -50,8 +51,9 @@ def off(self, t):
self.set_value(t, 0)


class _RTIOBase(AutoContext):
channel = Parameter()
class _RTIOBase(AutoDB):
class DBKeys:
channel = Argument()

def build(self):
self.previous_timestamp = int64(0) # in RTIO cycles
19 changes: 10 additions & 9 deletions artiq/devices/pdq2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from artiq.language.core import *
from artiq.language.context import *
from artiq.language.db import *
from artiq.language.units import *
from artiq.coredevice import rtio

@@ -111,16 +111,17 @@ def _invalidate(self):
del self.fn


class CompoundPDQ2(AutoContext):
ids = Parameter()
rtio_trigger = Parameter()
rtio_frame = Parameter()
class CompoundPDQ2(AutoDB):
class DBKeys:
ids = Argument()
rtio_trigger = Argument()
rtio_frame = Argument()

def build(self):
self.trigger = rtio.LLRTIOOut(self, channel=self.rtio_trigger)
self.frame0 = rtio.LLRTIOOut(self, channel=self.rtio_frame[0])
self.frame1 = rtio.LLRTIOOut(self, channel=self.rtio_frame[1])
self.frame2 = rtio.LLRTIOOut(self, channel=self.rtio_frame[2])
self.trigger = rtio.LLRTIOOut(core=self.core, channel=self.rtio_trigger)
self.frame0 = rtio.LLRTIOOut(core=self.core, channel=self.rtio_frame[0])
self.frame1 = rtio.LLRTIOOut(core=self.core, channel=self.rtio_frame[1])
self.frame2 = rtio.LLRTIOOut(core=self.core, channel=self.rtio_frame[2])

self.frames = []
self.current_frame = -1
179 changes: 0 additions & 179 deletions artiq/language/context.py

This file was deleted.

Loading

0 comments on commit 891c0d1

Please sign in to comment.