Core drivers reference

These drivers are for the core device and the peripherals closely integrated into it, which do not use the controller mechanism.

artiq.coredevice.core module

class artiq.coredevice.core.Core(dmgr, host, ref_period, external_clock=False, ref_multiplier=8)[source]

Core device driver.

Parameters:
  • host – hostname or IP address of the core device.
  • ref_period – period of the reference clock for the RTIO subsystem. On platforms that use clock multiplication and SERDES-based PHYs, this is the period after multiplication. For example, with a RTIO core clocked at 125MHz and a SERDES multiplication factor of 8, the reference period is 1ns. The time machine unit is equal to this period.
  • external_clock – whether the core device should switch to its external RTIO clock input instead of using its internal oscillator.
  • ref_multiplier – ratio between the RTIO fine timestamp frequency and the RTIO coarse timestamp frequency (e.g. SERDES multiplication factor).
break_realtime()[source]

Set the time cursor after the current value of the hardware RTIO counter plus a margin of 125000 machine units.

If the time cursor is already after that position, this function does nothing.

mu_to_seconds(mu)[source]

Converts machine units (RTIO cycles) to seconds.

Parameters:mu – cycle count to convert.
reset()[source]

Clear RTIO FIFOs, release RTIO PHY reset, and set the time cursor at the current value of the hardware RTIO counter plus a margin of 125000 machine units.

seconds_to_mu(seconds)[source]

Converts seconds to the corresponding number of machine units (RTIO cycles).

Parameters:seconds – time (in seconds) to convert.

artiq.coredevice.ttl module

Drivers for TTL signals on RTIO.

TTL channels (including the clock generator) all support output event replacement. For example, pulses of “zero” length (e.g. on() immediately followed by off(), without a delay) are suppressed.

class artiq.coredevice.ttl.TTLClockGen(dmgr, channel, core_device='core')[source]

RTIO TTL clock generator driver.

This should be used with TTL channels that have a clock generator built into the gateware (not compatible with regular TTL channels).

The time cursor is not modified by any function in this class.

Parameters:channel – channel number
frequency_to_ftw(frequency)[source]

Returns the frequency tuning word corresponding to the given frequency.

ftw_to_frequency(ftw)[source]

Returns the frequency corresponding to the given frequency tuning word.

set(frequency)[source]

Like set_mu, but using Hz.

set_mu(frequency)[source]

Set the frequency of the clock, in machine units, at the current position of the time cursor.

This also sets the phase, as the time of the first generated rising edge corresponds to the time of the call.

The clock generator contains a 24-bit phase accumulator operating on the RTIO clock. At each RTIO clock tick, the frequency tuning word is added to the phase accumulator. The most significant bit of the phase accumulator is connected to the TTL line. Setting the frequency tuning word has the additional effect of setting the phase accumulator to 0x800000.

Due to the way the clock generator operates, frequency tuning words that are not powers of two cause jitter of one RTIO clock cycle at the output.

stop()[source]

Stop the toggling of the clock and set the output level to 0.

sync()[source]

Busy-wait until all programmed frequency switches and stops have been effected.

class artiq.coredevice.ttl.TTLInOut(dmgr, channel, core_device='core')[source]

RTIO TTL input/output driver.

In output mode, provides functions to set the logic level on the signal.

In input mode, provides functions to analyze the incoming signal, with real-time gating to prevent overflows.

RTIO TTLs supports zero-length transition suppression. For example, if two pulses are emitted back-to-back with no delay between them, they will be merged into a single pulse with a duration equal to the sum of the durations of the original pulses.

This should be used with bidirectional channels.

Note that the channel is in input mode by default. If you need to drive a signal, you must call output. If the channel is in output mode most of the time in your setup, it is a good idea to call output in the startup kernel.

There are three input APIs: gating, sampling and watching. When one API is active (e.g. the gate is open, or the input events have not been fully read out), another API must not be used simultaneously.

Parameters:channel – channel number
count()[source]

Poll the RTIO input during all the previously programmed gate openings, and returns the number of registered events.

This function does not interact with the time cursor.

gate_both(duration)[source]

Register both rising and falling edge events for the specified duration (in seconds).

The time cursor is advanced by the specified duration.

gate_both_mu(duration)[source]

Register both rising and falling edge events for the specified duration (in machine units).

The time cursor is advanced by the specified duration.

gate_falling(duration)[source]

Register falling edge events for the specified duration (in seconds).

The time cursor is advanced by the specified duration.

gate_falling_mu(duration)[source]

Register falling edge events for the specified duration (in machine units).

The time cursor is advanced by the specified duration.

gate_rising(duration)[source]

Register rising edge events for the specified duration (in seconds).

The time cursor is advanced by the specified duration.

gate_rising_mu(duration)[source]

Register rising edge events for the specified duration (in machine units).

The time cursor is advanced by the specified duration.

input()[source]

Set the direction to input at the current position of the time cursor.

There must be a delay of at least one RTIO clock cycle before any other command can be issued.

off()[source]

Set the output to a logic low state at the current position of the time cursor.

The channel must be in output mode.

The time cursor is not modified by this function.

on()[source]

Set the output to a logic high state at the current position of the time cursor.

The channel must be in output mode.

The time cursor is not modified by this function.

output()[source]

Set the direction to output at the current position of the time cursor.

There must be a delay of at least one RTIO clock cycle before any other command can be issued.

pulse(duration)[source]

Pulses the output high for the specified duration (in seconds).

The time cursor is advanced by the specified duration.

pulse_mu(duration)[source]

Pulses the output high for the specified duration (in machine units).

The time cursor is advanced by the specified duration.

sample_get()[source]

Returns the value of a sample previously obtained with sample_input.

Multiple samples may be queued (using multiple calls to sample_input) into the RTIO FIFOs and subsequently read out using multiple calls to this function.

This function does not interact with the time cursor.

sample_get_nonrt()[source]

Convenience function that obtains the value of a sample at the position of the time cursor, breaks realtime, and returns the sample value.

sample_input()[source]

Instructs the RTIO core to read the value of the TTL input at the position of the time cursor.

The time cursor is not modified by this function.

sync()[source]

Busy-wait until all programmed level switches have been effected.

timestamp_mu()[source]

Poll the RTIO input and returns an event timestamp (in machine units), according to the gating.

If the gate is permanently closed, returns a negative value.

This function does not interact with the time cursor.

watch_done()[source]

Stop watching the input at the position of the time cursor.

Returns True if the input has not changed state while it was being watched.

The time cursor is not modified by this function. This function always makes the slack negative.

watch_stay_off()[source]

Like watch_stay_on, but for low levels.

watch_stay_on()[source]

Checks that the input is at a high level at the position of the time cursor and keep checking until watch_done is called.

Returns True if the input is high. A call to this function must always be followed by an eventual call to watch_done (use e.g. a try/finally construct to ensure this).

The time cursor is not modified by this function.

class artiq.coredevice.ttl.TTLOut(dmgr, channel, core_device='core')[source]

RTIO TTL output driver.

This should be used with output-only channels.

Parameters:channel – channel number
off()[source]

Set the output to a logic low state at the current position of the time cursor.

The time cursor is not modified by this function.

on()[source]

Sets the output to a logic high state at the current position of the time cursor.

The time cursor is not modified by this function.

pulse(duration)[source]

Pulse the output high for the specified duration (in seconds).

The time cursor is advanced by the specified duration.

pulse_mu(duration)[source]

Pulse the output high for the specified duration (in machine units).

The time cursor is advanced by the specified duration.

sync()[source]

Busy-wait until all programmed level switches have been effected.

artiq.coredevice.dds module

Drivers for direct digital synthesis (DDS) chips on RTIO.

Output event replacement is not supported and issuing commands at the same time is an error.

class artiq.coredevice.dds.DDSChannel(dmgr, bus_channel, channel, core_dds_device='core_dds')[source]

Core device Direct Digital Synthesis (DDS) channel driver.

Controls one DDS channel managed directly by the core device’s runtime.

This class should not be used directly, instead, use the chip-specific drivers such as DDSChannelAD9914.

The time cursor is not modified by any function in this class.

Parameters:
  • bus_channel – RTIO channel number of the DDS bus.
  • channel – channel number (on the bus) of the DDS device to control.
init()[source]

Resets and initializes the DDS channel.

This needs to be done for each DDS channel before it can be used, and it is recommended to use the startup kernel for this.

This function cannot be used in a batch; the correct way of initializing multiple DDS channels is to call this function sequentially with a delay between the calls. 2ms provides a good timing margin.

set(frequency, phase=0.0, phase_mode=-1, amplitude=1.0)[source]

Like set_mu, but uses Hz and turns.

set_mu(frequency, phase=0, phase_mode=-1, amplitude=4095)[source]

Sets the DDS channel to the specified frequency and phase.

This uses machine units (FTW and POW). The frequency tuning word width is 32, whereas the phase offset word width depends on the type of DDS chip and can be retrieved via the pow_width attribute. The amplitude width is 12.

The “frequency update” pulse is sent to the DDS with a fixed latency with respect to the current position of the time cursor.

Parameters:
  • frequency – frequency to generate.
  • phase – adds an offset, in turns, to the phase.
  • phase_mode – if specified, overrides the default phase mode set by set_phase_mode for this call.
set_phase_mode(phase_mode)[source]

Sets the phase mode of the DDS channel. Supported phase modes are:

  • PHASE_MODE_CONTINUOUS: the phase accumulator is unchanged when switching frequencies. The DDS phase is the sum of the phase accumulator and the phase offset. The only discrete jumps in the DDS output phase come from changes to the phase offset.
  • PHASE_MODE_ABSOLUTE: the phase accumulator is reset when switching frequencies. Thus, the phase of the DDS at the time of the frequency change is equal to the phase offset.
  • PHASE_MODE_TRACKING: when switching frequencies, the phase accumulator is set to the value it would have if the DDS had been running at the specified frequency since the start of the experiment.
class artiq.coredevice.dds.DDSChannelAD9914(dmgr, bus_channel, channel, core_dds_device='core_dds')[source]

Driver for AD9914 DDS chips. See DDSChannel for a description of the functionality.

init_sync(sync_delay=0)[source]

Resets and initializes the DDS channel as well as configures the AD9914 DDS for synchronisation. The synchronisation procedure follows the steps outlined in the AN-1254 application note.

This needs to be done for each DDS channel before it can be used, and it is recommended to use the startup kernel for this.

This function cannot be used in a batch; the correct way of initializing multiple DDS channels is to call this function sequentially with a delay between the calls. 10ms provides a good timing margin.

Parameters:sync_delay – integer from 0 to 0x3f that sets the value of SYNC_OUT (bits 3-5) and SYNC_IN (bits 0-2) delay ADJ bits.
class artiq.coredevice.dds.DDSGroup(dmgr, sysclk, core_device='core')[source]

Core device Direct Digital Synthesis (DDS) driver.

Gives access to the DDS functionality of the core device.

Parameters:sysclk – DDS system frequency. The DDS system clock must be a phase-locked multiple of the RTIO clock.
amplitude_to_asf(amplitude)[source]

Returns amplitude scale factor corresponding to given amplitude.

asf_to_amplitude(asf)[source]

Returns the amplitude corresponding to the given amplitude scale factor.

frequency_to_ftw(frequency)[source]

Returns the frequency tuning word corresponding to the given frequency.

ftw_to_frequency(ftw)[source]

Returns the frequency corresponding to the given frequency tuning word.

pow_to_turns(pow)[source]

Returns the phase in turns corresponding to the given phase offset word.

turns_to_pow(turns)[source]

Returns the phase offset word corresponding to the given phase in turns.

class artiq.coredevice.dds.DDSGroupAD9914(*args, *, first_dds_bus_channel, dds_bus_count, dds_channel_count, **kwargs)[source]

Driver for AD9914 DDS chips. See DDSGroup for a description of the functionality.

artiq.coredevice.dma module

Direct Memory Access (DMA) extension.

This feature allows storing pre-defined sequences of output RTIO events into the core device’s SDRAM, and playing them back at higher speeds than the CPU alone could achieve.

class artiq.coredevice.dma.CoreDMA(dmgr, core_device='core')[source]

Core device Direct Memory Access (DMA) driver.

Gives access to the DMA functionality of the core device.

erase(name)[source]

Removes the DMA trace with the given name from storage.

get_handle(name)[source]

Returns a handle to a previously recorded DMA trace. The returned handle is only valid until the next call to record() or erase().

playback(name)[source]

Replays a previously recorded DMA trace. This function blocks until the entire trace is submitted to the RTIO FIFOs.

playback_handle(handle)[source]

Replays a handle obtained with get_handle(). Using this function is much faster than playback() for replaying a set of traces repeatedly, but incurs the overhead of managing the handles onto the programmer.

record(name)[source]

Returns a context manager that will record a DMA trace called name. Any previously recorded trace with the same name is overwritten. The trace will persist across kernel switches.

class artiq.coredevice.dma.DMARecordContextManager[source]

Context manager returned by CoreDMA.record().

Upon entering, starts recording a DMA trace. All RTIO operations are redirected to a newly created DMA buffer after this call, and now is reset to zero.

Upon leaving, stops recording a DMA trace. All recorded RTIO operations are stored in a newly created trace, and now is restored to the value it had before the context manager was entered.

artiq.coredevice.spi module

Driver for generic SPI on RTIO.

Output event replacement is not supported and issuing commands at the same time is an error.

class artiq.coredevice.spi.SPIMaster(dmgr, channel, core_device='core')[source]

Core device Serial Peripheral Interface (SPI) bus master. Owns one SPI bus.

Transfer Sequence:

  • If desired, write the config register (set_config()) to configure and activate the core.
  • If desired, write the xfer register (set_xfer()) to set cs_n, write_length, and read_length.
  • write() to the data register (also for transfers with zero bits to be written). Writing starts the transfer.
  • If desired, read_sync() (or read_async() followed by a input_async() later) the data register corresponding to the last completed transfer.
  • If desired, set_xfer() for the next transfer.
  • If desired, write() data queuing the next (possibly chained) transfer.

Notes:

  • In order to chain a transfer onto an in-flight transfer without deasserting cs in between, the second write() needs to happen strictly later than 2*ref_period_mu (two coarse RTIO cycles) but strictly earlier than xfer_period_mu + write_period_mu after the first. Note that write() already applies a delay of xfer_period_mu + write_period_mu.
  • A full transfer takes write_period_mu + xfer_period_mu.
  • Chained transfers can happen every xfer_period_mu.
  • Read data is available every xfer_period_mu starting a bit after xfer_period_mu (depending on clk_phase).
  • As a consequence, in order to chain transfers together, new data must be written before the pending transfer’s read data becomes available.
Parameters:channel – RTIO channel number of the SPI bus to control.
input_async()[source]

Retrieves data read asynchronously from the data register.

input_async() must match a preeeding read_async().

read_async()[source]

Trigger an asynchronous read from the data register.

For bit alignment and bit ordering see set_config().

Reads always finish in two cycles.

Every data register read triggered by a read_async() must be matched by a input_async() to retrieve the data.

This method advances the timeline by the duration of the RTIO-to-Wishbone bus transaction (three RTIO clock cycles).

read_sync()[source]

Read the data register synchronously.

This is a shortcut for read_async() followed by input_async().

set_config(flags=0, write_freq=20000000.0, read_freq=20000000.0)[source]

Set the configuration register.

  • If config.cs_polarity == 0 (cs active low, the default), “cs_n all deasserted” means “all cs_n bits high”.
  • cs_n is not mandatory in the pads supplied to the gateware core. Framing and chip selection can also be handled independently through other means, e.g. TTLOut.
  • If there is a miso wire in the pads supplied in the gateware, input and output may be two signals (“4-wire SPI”), otherwise mosi must be used for both output and input (“3-wire SPI”) and config.half_duplex must to be set when reading data is desired or when the slave drives the mosi signal at any point.
  • The first bit output on mosi is always the MSB/LSB (depending on config.lsb_first) of the data register, independent of xfer.write_length. The last bit input from miso always ends up in the LSB/MSB (respectively) of the data register, independent of xfer.read_length.
  • Writes to the config register take effect immediately.

Configuration flags:

  • SPI_OFFLINE: all pins high-z (reset=1)
  • SPI_ACTIVE: transfer in progress (read-only)
  • SPI_PENDING: transfer pending in intermediate buffer (read-only)
  • SPI_CS_POLARITY: active level of cs_n (reset=0)
  • SPI_CLK_POLARITY: idle level of clk (reset=0)
  • SPI_CLK_PHASE: first edge after cs assertion to sample data on (reset=0). In Motorola/Freescale SPI language (SPI_CLK_POLARITY, SPI_CLK_PHASE) == (CPOL, CPHA):
    • (0, 0): idle low, output on falling, input on rising
    • (0, 1): idle low, output on rising, input on falling
    • (1, 0): idle high, output on rising, input on falling
    • (1, 1): idle high, output on falling, input on rising
  • SPI_LSB_FIRST: LSB is the first bit on the wire (reset=0)
  • SPI_HALF_DUPLEX: 3-wire SPI, in/out on mosi (reset=0)

This method advances the timeline by the duration of the RTIO-to-Wishbone bus transaction (three RTIO clock cycles).

Parameters:
  • flags – A bit map of SPI_* flags.
  • write_freq – Desired SPI clock frequency during write bits.
  • read_freq – Desired SPI clock frequency during read bits.
set_config_mu(flags=0, write_div=6, read_div=6)[source]

Set the config register (in SPI bus machine units).

See also

set_config()

Parameters:
  • write_div – Counter load value to divide the RTIO clock by to generate the SPI write clk. (minimum=2, reset=2) f_rtio_clk/f_spi_write == write_div. If write_div is odd, the setup phase of the SPI clock is biased to longer lengths by one RTIO clock cycle.
  • read_div – Ditto for the read clock.
set_xfer(chip_select=0, write_length=0, read_length=0)[source]

Set the xfer register.

  • Every transfer consists of a write of write_length bits immediately followed by a read of read_length bits.
  • cs_n is asserted at the beginning and deasserted at the end of the transfer if there is no other transfer pending.
  • cs_n handling is agnostic to whether it is one-hot or decoded somewhere downstream. If it is decoded, “cs_n all deasserted” should be handled accordingly (no slave selected). If it is one-hot, asserting multiple slaves should only be attempted if miso is either not connected between slaves, or open collector, or correctly multiplexed externally.
  • For 4-wire SPI only the sum of read_length and write_length matters. The behavior is the same (except for clock speeds) no matter how the total transfer length is divided between the two. For 3-wire SPI, the direction of mosi is switched from output to input after write_length bits.
  • Data output on mosi in 4-wire SPI during the read cycles is what is found in the data register at the time. Data in the data register outside the least/most (depending on config.lsb_first) significant read_length bits is what is seen on miso (or mosi if config.half_duplex) during the write cycles.
  • Writes to xfer are synchronized to the start of the next (possibly chained) transfer.

This method advances the timeline by the duration of the RTIO-to-Wishbone bus transaction (three RTIO clock cycles).

Parameters:
  • chip_select – Bit mask of chip selects to assert. Or number of the chip select to assert if cs is decoded downstream. (reset=0)
  • write_length – Number of bits to write during the next transfer. (reset=0)
  • read_length – Number of bits to read during the next transfer. (reset=0)
write(data=0)[source]

Write data to data register.

  • The data register and the shift register are 32 bits wide. If there are no writes to the register, miso data reappears on mosi after 32 cycles.
  • A wishbone data register write is acknowledged when the transfer has been written to the intermediate buffer. It will be started when there are no other transactions being executed, either beginning a new SPI transfer of chained to an in-flight transfer.
  • Writes take three ref_period cycles unless another chained transfer is pending and the transfer being executed is not complete.
  • The SPI data register is double-buffered: Once a transfer has started, new write data can be written, queuing a new transfer. Transfers submitted this way are chained and executed without deasserting cs in between. Once a transfer completes, the previous transfer’s read data is available in the data register.
  • For bit alignment and bit ordering see set_config().

This method advances the timeline by the duration of the SPI transfer. If a transfer is to be chained, the timeline needs to be rewound.

class artiq.coredevice.spi.NRTSPIMaster(dmgr, busno=0, core_device='core')[source]

Core device non-realtime Serial Peripheral Interface (SPI) bus master. Owns one non-realtime SPI bus.

With this driver, SPI transactions and are performed by the CPU without involving RTIO.

Realtime and non-realtime buses are separate and defined at bitstream compilation time.

See SPIMaster for a description of the methods.

set_config_mu(flags=0, write_div=6, read_div=6)[source]

Set the config register.

Note that the non-realtime SPI cores are usually clocked by the system clock and not the RTIO clock. In many cases, the SPI configuration is already set by the firmware and you do not need to call this method.

The offline bit cannot be set using this method. The SPI bus is briefly taken offline when this method is called.

artiq.coredevice.ad5360 module

Driver for the AD5360 DAC on RTIO.

Output event replacement is not supported and issuing commands at the same time is an error.

class artiq.coredevice.ad5360.AD5360(dmgr, spi_device, ldac_device=None, chip_select=1)[source]

Support for the Analog devices AD53[67][0123] multi-channel Digital to Analog Converters

Parameters:
  • spi_device – Name of the SPI bus this device is on.
  • ldac_device – Name of the TTL device that LDAC is connected to (optional). Needs to be explicitly initialized to high.
  • chip_select – Value to drive on the chip select lines during transactions.
load()[source]

Pulse the LDAC line.

This method advances the timeline by two RTIO clock periods (16 ns).

read_channel_sync(channel=0, op=0)[source]

Read a channel register.

This method advances the timeline by the duration of write() plus three RTIO-to-Wishbone transactions.

Parameters:
  • channel – Channel number to read from.
  • op – Operation to perform, one of _AD5360_READ_X1A, _AD5360_READ_X1B, _AD5360_READ_OFFSET, _AD5360_READ_GAIN (default: _AD5360_READ_X1A).
Returns:

The 16 bit register value.

set(values, op=12582912)[source]

Write to several channels and pulse LDAC to update the channels.

This method does not advance the timeline. Write events are scheduled in the past. The DACs will synchronously start changing their output levels now.

Parameters:
  • values – List of 16 bit values to write to the channels.
  • op – Operation to perform, one of _AD5360_CMD_DATA, _AD5360_CMD_OFFSET, _AD5360_CMD_GAIN (default: _AD5360_CMD_DATA).
setup_bus(write_div=4, read_div=7)[source]

Configure the SPI bus and the SPI transaction parameters for this device. This method has to be called before any other method if the bus has been used to access a different device in the meantime.

This method advances the timeline by the duration of two RTIO-to-Wishbone bus transactions.

Parameters:
  • write_div – Write clock divider.
  • read_div – Read clock divider.
write(data)[source]

Write 24 bits of data.

This method advances the timeline by the duration of the SPI transfer and the required CS high time.

write_channel(channel=0, value=0, op=12582912)[source]

Write to a channel register.

This method advances the timeline by the duration of write().

Parameters:
  • channel – Channel number to write to.
  • value – 16 bit value to write to the register.
  • op – Operation to perform, one of _AD5360_CMD_DATA, _AD5360_CMD_OFFSET, _AD5360_CMD_GAIN (default: _AD5360_CMD_DATA).
write_offsets(value=8191)[source]

Write the OFS0 and OFS1 offset DACs.

This method advances the timeline by twice the duration of write().

Parameters:value – Value to set both offset registers to.

artiq.coredevice.i2c module

Non-realtime drivers for I2C chips on the core device.

class artiq.coredevice.i2c.PCA9548(dmgr, busno=0, address=232, core_device='core')[source]

Driver for the PCA9548 I2C bus switch.

I2C transactions not real-time, and are performed by the CPU without involving RTIO.

On the KC705, this chip is used for selecting the I2C buses on the two FMC connectors. HPC=1, LPC=2.

set(channel)[source]

Select one channel.

Selecting multiple channels at the same time is not supported by this driver.

Parameters:channel – channel number (0-7)
class artiq.coredevice.i2c.TCA6424A(dmgr, busno=0, address=68, core_device='core')[source]

Driver for the TCA6424A I2C I/O expander.

I2C transactions not real-time, and are performed by the CPU without involving RTIO.

On the NIST QC2 hardware, this chip is used for switching the directions of TTL buffers.

set(outputs)[source]

Drive all pins of the chip to the levels given by the specified 24-bit word.

On the QC2 hardware, the LSB of the word determines the direction of TTL0 (on a given FMC card) and the MSB that of TTL23.

A bit set to 1 means the TTL is an output.

artiq.coredevice.cache module

class artiq.coredevice.cache.CoreCache(dmgr, core_device='core')[source]

Core device cache access

get(key)[source]

Extract a value from the core device cache. After a value is extracted, it cannot be replaced with another value using put() until all kernel functions finish executing; attempting to replace it will result in a artiq.coredevice.exceptions.CacheError.

If the cache does not contain any value associated with key, an empty list is returned.

The value is not copied, so mutating it will change what’s stored in the cache.

Parameters:key (str) – cache key
Returns:a list of 32-bit integers
put(key, value)[source]

Put a value into the core device cache. The value will persist until reboot.

To remove a value from the cache, call put() with an empty list.

Parameters:
  • key (str) – cache key
  • value (list) – a list of 32-bit integers

artiq.coredevice.exceptions module

exception artiq.coredevice.exceptions.CacheError[source]

Raised when putting a value into a cache row would violate memory safety.

exception artiq.coredevice.exceptions.ClockFailure[source]

Raised when RTIO PLL has lost lock.

class artiq.coredevice.exceptions.CoreException(name, message, params, traceback)[source]

Information about an exception raised or passed through the core device.

exception artiq.coredevice.exceptions.DDSError[source]

Raised when attempting to start a DDS batch while already in a batch, when too many commands are batched, and when DDS channel settings are incorrect.

exception artiq.coredevice.exceptions.DMAError[source]

Raised when performing an invalid DMA operation.

exception artiq.coredevice.exceptions.I2CError[source]

Raised when a I2C transaction fails.

exception artiq.coredevice.exceptions.InternalError[source]

Raised when the runtime encounters an internal error condition.

exception artiq.coredevice.exceptions.RTIOOverflow[source]

Raised when at least one event could not be registered into the RTIO input FIFO because it was full (CPU not reading fast enough).

This does not interrupt operations further than cancelling the current read attempt and discarding some events. Reading can be reattempted after the exception is caught, and events will be partially retrieved.

exception artiq.coredevice.exceptions.RTIOSequenceError[source]

Raised when an event is submitted on a given channel with a timestamp not larger than the previous one.

The offending event is discarded and the RTIO core keeps operating.

exception artiq.coredevice.exceptions.RTIOUnderflow[source]

Raised when the CPU or DMA core fails to submit a RTIO event early enough (with respect to the event’s timestamp).

The offending event is discarded and the RTIO core keeps operating.

exception artiq.coredevice.exceptions.SPIError[source]

Raised when a SPI transaction fails.

exception artiq.coredevice.exceptions.WatchdogExpired[source]

Raised when a watchdog expires.

artiq.coredevice.spline module

class artiq.coredevice.spline.Spline(width, time_width, channel, core_device, scale=1.0)[source]

Spline interpolating RTIO channel.

One knot of a polynomial basis spline (B-spline) \(u(t)\) is defined by the coefficients \(u_n\) up to order \(n = k\). If the coefficients are evaluated starting at time \(t_0\), the output \(u(t)\) for \(t > t_0, t_0\) is:

\[\begin{split}u(t) &= \sum_{n=0}^k \frac{u_n}{n!} (t - t_0)^n \\ &= u_0 + u_1 (t - t_0) + \frac{u_2}{2} (t - t_0)^2 + \dots\end{split}\]

This class contains multiple methods to convert spline knot data from SI to machine units and multiple methods that set the current spline coefficient data. None of these advance the timeline. The smooth() method is the only method that advances the timeline.

Parameters:
  • width – Width in bits of the quantity that this spline controls
  • time_width – Width in bits of the time counter of this spline
  • channel – RTIO channel number
  • core_device – Core device that this spline is attached to
  • scale – Scale for conversion between machine units and physical units; to be given as the “full scale physical value”.
coeff_as_packed(coeff)[source]

Convert floating point spline coefficients into 32 bit integer packed data.

This is a host-only method that can be used to generate packed spline coefficient data to be frozen into kernels at compile time.

coeff_as_packed_mu(coeff64)[source]

Pack 64 bit integer machine units coefficients into 32 bit integer RTIO data list.

This is a host-only method that can be used to generate packed spline coefficient data to be frozen into kernels at compile time.

coeff_to_mu(coeff, coeff64)[source]

Convert a floating point list of coefficients into a 64 bit integer (preallocated).

Parameters:
  • coeff – TList(TFloat) list of coefficients in physical units.
  • coeff64 – TList(TInt64) preallocated list of coefficients in machine units.
from_mu(value: numpy.int32) → float[source]

Convert 32 bit integer value from machine units to floating point physical units.

pack_coeff_mu(coeff, packed)[source]

Pack coefficients into RTIO data

Parameters:
  • coeff – TList(TInt64) list of machine units spline coefficients. Lowest (zeroth) order first. The coefficient list is zero-extended by the RTIO gateware.
  • packed – TList(TInt32) list for packed RTIO data. Must be pre-allocated. Length in bits is n*width + (n - 1)*n//2*time_width
set(value: float)[source]

Set spline value.

Parameters:value – Spline value relative to full-scale.
set_coeff(coeff)[source]

Set spline coefficients.

Missing coefficients (high order) are zero-extended byt the RTIO gateware.

If more coefficients are supplied than the gateware supports the extra coefficients are ignored.

Parameters:value – List of floating point spline coefficients, lowest order (constant) coefficient first. Units are the unit of this spline’s value times increasing powers of 1/s.
set_coeff_mu(value)[source]

Set spline raw values.

Parameters:value – Spline packed raw values.
set_mu(value: numpy.int32)[source]

Set spline value (machine units).

Parameters:value – Spline value in integer machine units.
smooth(start: float, stop: float, duration: float, order: numpy.int32)[source]

Initiate an interpolated value change.

For zeroth order (step) interpolation, the step is at start + duration/2.

First order interpolation corresponds to a linear value ramp from start to stop over duration.

The third order interpolation is constrained to have zero first order derivative at both start and stop.

For first order and third order interpolation (linear and cubic) the interpolator needs to be stopped explicitly at the stop time (e.g. by setting spline coefficient data or starting a new smooth() interpolation).

This method advances the timeline by duration.

Parameters:
  • start – Initial value of the change. In physical units.
  • stop – Final value of the change. In physical units.
  • duration – Duration of the interpolation. In physical units.
  • order – Order of the interpolation. Only 0, 1, and 3 are valid: step, linear, cubic.
to_mu(value: float) → numpy.int32[source]

Convert floating point value from physical units to 32 bit integer machine units.

to_mu64(value: float) → numpy.int64[source]

Convert floating point value from physical units to 64 bit integer machine units.

artiq.coredevice.sawg module

Driver for the Smart Arbitrary Waveform Generator (SAWG) on RTIO.

The SAWG is an “improved DDS” built in gateware and interfacing to high-speed DACs.

Output event replacement is supported except on the configuration channel.

class artiq.coredevice.sawg.Config(channel, core, cordic_gain=1.0)[source]

SAWG configuration.

Exposes the configurable quantities of a single SAWG channel.

Access to the configuration registers for a SAWG channel can not be concurrent. There must be at least _rtio_interval machine units of delay between accesses. Replacement is not supported and will be lead to an RTIOCollision as this is likely a programming error. All methods therefore advance the timeline by the duration of one configuration register transfer.

Parameters:
  • channel – RTIO channel number of the channel.
  • core – Core device.
set_clr(clr0: numpy.int32, clr1: numpy.int32, clr2: numpy.int32)[source]

Set the accumulator clear mode for the three phase accumulators.

When the clr bit for a given DDS/DUC phase accumulator is set, that phase accumulator will be cleared with every phase offset RTIO command and the output phase of the DDS/DUC will be exactly the phase RTIO value (“absolute phase update mode”).

\[q^\prime(t) = p^\prime + (t - t^\prime) f^\prime\]

In turn, when the bit is cleared, the phase RTIO channels determine a phase offset to the current (carrier-) value of the DDS/DUC phase accumulator. This “relative phase update mode” is sometimes also called “continuous phase mode”.

\[q^\prime(t) = q(t^\prime) + (p^\prime - p) + (t - t^\prime) f^\prime\]

Where:

  • \(q\), \(q^\prime\): old/new phase accumulator
  • \(p\), \(p^\prime\): old/new phase offset
  • \(f^\prime\): new frequency
  • \(t^\prime\): timestamp of setting new \(p\), \(f\)
  • \(t\): running time
Parameters:
  • clr0 – Auto-clear phase accumulator of the phase0/ frequency0 DUC. Default: True
  • clr1 – Auto-clear phase accumulator of the phase1/ frequency1 DDS. Default: True
  • clr2 – Auto-clear phase accumulator of the phase2/ frequency2 DDS. Default: True
set_div(div: numpy.int32, n: numpy.int32 = 0)[source]

Set the spline evolution divider and current counter value.

The divider and the spline evolution are synchronized across all spline channels within a SAWG channel. The DDS/DUC phase accumulators always evolves at full speed.

Note

The spline evolution divider has not been tested extensively and is currently considered a technological preview only.

Parameters:
  • div – Spline evolution divider, such that t_sawg_spline/t_rtio_coarse = div + 1. Default: 0.
  • n – Current value of the counter. Default: 0.
set_duc_max(limit: float)[source]

Set the digital up-converter (DUC) I and Q data summing junctions upper limit.

Each of the three summing junctions has a saturating adder with configurable upper and lower limits. The three summing junctions are:

  • At the in-phase input to the phase0/frequency0 fast DUC, after the anti-aliasing FIR filter.

  • At the quadrature input to the phase0/frequency0 fast DUC, after the anti-aliasing FIR filter. The in-phase and quadrature data paths both use the same limits.

  • Before the DAC, where the following three data streams are added together:

    • the output of the offset spline,
    • (optionally, depending on i_enable) the in-phase output of the phase0/frequency0 fast DUC, and
    • (optionally, depending on q_enable) the quadrature output of the phase0/frequency0 fast DUC of the buddy channel.

Refer to the documentation of SAWG for a mathematical description of the summing junctions.

Parameters:limit – Limit value [-1, 1]. The output of the limiter will never exceed this limit. The default limits are the full range [-1, 1].

See also

set_duc_max_mu(limit: numpy.int32)[source]

Set the digital up-converter (DUC) I and Q data summing junctions upper limit. In machine units.

The default limits are chosen to reach maximum and minimum DAC output amplitude.

For a description of the limiter functions in normalized units see:

See also

set_duc_max()

set_duc_min(limit: float)[source]

See also

set_duc_max()

set_duc_min_mu(limit: numpy.int32)[source]

See also

set_duc_max_mu()

set_iq_en(i_enable: numpy.int32, q_enable: numpy.int32)[source]

Enable I/Q data on this DAC channel.

Every pair of SAWG channels forms a buddy pair. The iq_en configuration controls which DDS data is emitted to the DACs.

Refer to the documentation of SAWG for a mathematical description of i_enable and q_enable.

Note

Quadrature data from the buddy channel is currently a technological preview only. The data is ignored in the SAWG gateware and not added to the DAC output. This is equivalent to the q_enable switch always being 0.

Parameters:
  • i_enable – Controls adding the in-phase DUC-DDS data of this SAWG channel to this DAC channel. Default: 1.
  • q_enable – controls adding the quadrature DUC-DDS data of this SAWG’s buddy channel to this DAC channel. Default: 0.
set_out_max(limit: float)[source]

See also

set_duc_max()

set_out_max_mu(limit: numpy.int32)[source]

See also

set_duc_max_mu()

set_out_min(limit: float)[source]

See also

set_duc_max()

set_out_min_mu(limit: numpy.int32)[source]

See also

set_duc_max_mu()

class artiq.coredevice.sawg.SAWG(dmgr, channel_base, parallelism, core_device='core')[source]

Smart arbitrary waveform generator channel. The channel is parametrized as:

oscillators = exp(2j*pi*(frequency0*t + phase0))*(
    amplitude1*exp(2j*pi*(frequency1*t + phase1)) +
    amplitude2*exp(2j*pi*(frequency2*t + phase2)))

output = (offset +
    i_enable*Re(oscillators) +
    q_enable*Im(buddy_oscillators))

This parametrization can be viewed as two complex (quadrature) oscillators (frequency1/phase1 and frequency2/phase2) that are executing and sampling at the coarse RTIO frequency. They can represent frequencies within the first Nyquist zone from -f_rtio_coarse/2 to f_rtio_coarse/2.

Note

The coarse RTIO frequency f_rtio_coarse is the inverse of ref_period*multiplier. Both are arguments of the Core device, specified in the device database device_db.py.

The sum of their outputs is then interpolated by a factor of parallelism (2, 4, 8 depending on the bitstream) using a finite-impulse-response (FIR) anti-aliasing filter (more accurately a half-band filter).

The filter is followed by a configurable saturating limiter.

After the limiter, the data is shifted in frequency using a complex digital up-converter (DUC, frequency0/phase0) running at parallelism times the coarse RTIO frequency. The first Nyquist zone of the DUC extends from -f_rtio_coarse*parallelism/2 to f_rtio_coarse*parallelism/2. Other Nyquist zones are usable depending on the interpolation/modulation options configured in the DAC.

The real/in-phase data after digital up-conversion can be offset using another spline interpolator offset.

The i_enable/q_enable switches enable emission of quadrature signals for later analog quadrature mixing distinguishing upper and lower sidebands and thus doubling the bandwidth. They can also be used to emit four-tone signals.

Note

Quadrature data from the buddy channel is currently ignored in the SAWG gateware and not added to the DAC output. This is equivalent to the q_enable switch always being 0.

The configuration channel and the nine artiq.coredevice.spline.Spline interpolators are accessible as attributes:

  • config: Config
  • offset, amplitude1, amplitude2: in units of full scale
  • phase0, phase1, phase2: in units of turns
  • frequency0, frequency1, frequency2: in units of Hz

Note

The latencies (pipeline depths) of the nine data channels (i.e. all except config) are matched. Equivalent channels (e.g. phase1 and phase2) are exactly matched. Channels of different type or functionality (e.g. offset vs amplitude1, DDS vs DUC, phase0 vs phase1) are only matched to within one coarse RTIO cycle.

Parameters:
  • channel_base – RTIO channel number of the first channel (amplitude). The configuration channel and frequency/phase/amplitude channels are then assumed to be successive channels.
  • parallelism – Number of output samples per coarse RTIO clock cycle.
  • core_device – Name of the core device that this SAWG is on.
reset()[source]

Re-establish initial conditions.

This clears all spline interpolators, accumulators and configuration settings.

This method advances the timeline by the time required to perform all seven writes to the configuration channel.