AWG Core Module

class zhinst.toolkit.control.drivers.base.AWGCore(parent: zhinst.toolkit.control.drivers.base.base.BaseInstrument, index: int)

Implements an AWG Core representation.

The AWGCore class implements basic functionality of the AWG sequencer without the need for the user to write their own ‘.seqC’ code. The AWGCore holds a SequenceProgram object whose parameters can be set using the set_sequence_params(…) method of the AWG.

This module takes over the functionality of configuring the seuqence program and compiling it on the instrument. Given the ‘Simple’ sequence type, sample-defined waveforms can be queued and uploaded to the AWG.

This base class AWGCore is inherited by device-specific AWGs for the HDAWG or the UHFQA/UHFLI. The device-specific AWGs add certain zhinst-toolkit Parameters and apply certain instrument settings, depending on the sequence_type and the trigger_mode (sending out a trigger signal or waiting for a trigger) of the sequence program.

For example, a predefined Rabi sequence with a sweep over 101 different amplitudes could be programmed like this:

>>> awg = hdawg.awgs[0]
>>> awg.set_sequence_params(
>>>     sequence_type="Rabi",
>>>     trigger_mode="None",
>>>     repetitions=1e3,
>>>     period=20e-6,
>>>     pulse_amplitudes=np.linspace(0, 1.0, 101),
>>>     pulse_width=20e-9,
>>>     pulse_truncation=4,
>>> )
>>> awg.compile()
>>> ...
>>> awg.wait_done()

The sequence type ‘Simple’ allows the user to upload sample-defined waveforms as numpy arrays. The waveforms in the queue are played one after the other with a specified period and alignment/delay to a time origin.

>>> awg.set_sequence_params(
>>>     sequence_type="Simple",
>>>     trigger_mode="Send Trigger",
>>>     repetitions=1e3,
>>>     period=20e-6,
>>> )
>>> for amp in np.linspace(-1, 1, 101):
>>>     wave = amp * np.linspace(-1.0, 1.0, 800)
>>>     awg.queue_waveform(wave, -wave)
Current length of queue: 1
Current length of queue: 2
Current length of queue: 3
Current length of queue: 4
>>> awg.compile_and_upload_waveforms()
Compilation successful
hd1-0: Sequencer status: ELF file uploaded
Upload of 101 waveforms took 0.20005226135253906 s
>>> awg.wait_done()

The parent instrument that this AWGCore is associated to.




An integer specifying the index in the parent instrument.




A list of Waveforms that represent the queued up waveforms in for a ‘Simple’ sequence.




A SequenceProgram object used to program predefined ‘.seqC’ sequences on the device.




The name of the AWG Core.




A flag that shows if the AWG Core is currently running or not.




A dictionary of all the sequence parameters currently set on the SequenceProgram.



compile() → None

Compiles the current SequenceProgram on the AWG Core.

  • ToolkitConnectionError – If the AWG Core has not been set up yet

  • ToolkitError – if the compilation has failed or the ELF upload is not successful.

  • TimeoutError – if the program upload is not completed before timeout.

compile_and_upload_waveforms() → None

Compiles the Sequence Program and uploads the queued waveforms.

Simply combines the two methods to make sure the sequence is compiled before the waveform queue is uplaoded.


Sets both signal outputs simultaneously.


value (tuple) – Tuple of values {‘on’, ‘off’} for channel 1 and 2 (default: None).


A tuple with the states {‘on’, ‘off’} for the two output channels if the keyword argument is not given.


ValueError – If the value argument is not a list or tuple of length 2.

queue_waveform(wave1: Union[List, numpy.array], wave2: Union[List, numpy.array], delay: float = 0) → None

Queues up a waveform to the AWG Core.

Uploading custom waveforms is only possible when using the ‘Simple’ or ‘Custom’ sequence types. The waveform is specified with two numpy arrays for the two channels of the AWG Core. The waveform will then automatically align them to the correct minimum waveform length, sample granularity and scaling. An individual delay can be specified to shift the individual waveform with respect to the time origin of the period.

  • wave1 (array like) – A list or array of samples in the waveform to be queued for channel 1. An empty list ‘[]’ will upload zeros of the minimum waveform length.

  • wave2 (array like) – A list or array of samples in the waveform to be queued for channel 2. An empty list ‘[]’ will upload zeros of the minimum waveform length.

  • delay (float) – An individual delay for the queued sequence with respect to the time origin. Positive values shift the start of the waveform forwards in time. (default: 0)


ToolkitError – If the sequence is not of type ‘Simple’ or ‘Custom’.

replace_waveform(wave1: Union[List, numpy.array], wave2: Union[List, numpy.array], i: int = 0, delay: float = 0) → None

Replaces the data in a waveform in the queue.

The new data must have the same length as the previous data s.t. the waveform data can be replaced without recompilation of the sequence program.

  • wave1 (array) – Waveform to replace current wave for Channel 1.

  • wave2 (array) – Waveform to replace current wave for Channel 2.

  • i (int) – The index of the waveform in the queue to be replaced.

  • delay (int) – An individual delay in seconds for this waveform w.r.t. the time origin of the sequence (default: 0).


ValueError – If the given index is out of range.

reset_queue() → None

Resets the waveform queue to an empty list.

run(sync=True) → None

Run the AWG Core.


sync (bool) – A flag that specifies if a synchronisation should be performed between the device and the data server after enabling the AWG Core (default: True).

set_sequence_params(**kwargs) → None

Sets the parameters of the Sequence Program.

Passes all the keyword arguments to the set_param(…) method of the Sequence Program. The available sequence parameters may vary between different sequences. For a list of all current sequence parameters see the method sequence_params().

They include:

‘sequence_type’, ‘period’, ‘repetitions’, ‘trigger_mode’, ‘trigger_delay’, …

>>> hdawg.awgs[0]
<zhinst.toolkit.hdawg.AWG object at 0x0000021E467D3320>
    parent  : <zhinst.toolkit.hdawg.HDAWG object at 0x0000021E467D3198>
    index   : 0
            type: None
            ('target', 'hdawg')
            ('clock_rate', 2400000000.0)
            ('period', 0.0001)
            ('trigger_mode', 'None')
            ('repetitions', 1)
            ('alignment', 'End with Trigger')
>>> hdawg.awgs[0].set_sequence_params(
>>>     sequence_type="Simple",
>>>     trigger_mode="Send Trigger",
>>>     repetitions=1e6,
>>>     alignemnt="Start with Trigger"
>>> )
stop(sync=True) → None

Stop the AWG Core.


sync (bool) – A flag that specifies if a synchronisation should be performed between the device and the data server after disabling the AWG Core (default: True).

upload_waveforms() → None

Uploads all waveforms in the queue to the AWG Core.

This method only works as expected if the Sequence Program is in ‘Simple’ or ‘Custom’ modes and has been compiled beforehand. See compile_and_upload_waveforms(...)().

wait_done(timeout: float = 10, sleep_time: float = 0.005) → None

Wait until the AWG Core is finished.

  • timeout (float) – The maximum waiting time in seconds for the AWG Core (default: 10).

  • sleep_time (float) – Time in seconds to wait between requesting AWG state

  • ToolkitError – If the AWG is running in continuous mode.

  • TimeoutError – If the AWG is not finished before the timeout.