SHF Generator Module

class zhinst.toolkit.control.drivers.base.SHFGenerator(parent: zhinst.toolkit.control.drivers.base.shf_qachannel.SHFQAChannel)

Implements an SHF Generator representation.

The SHFGenerator class implements basic functionality of the SHF Sequencer allowing the user to write and upload their ‘.seqC’ code.

In contrast to other AWG Sequencers, e.g. from the HDAWG, SHF Sequencer does not provide writing access to the Waveform Memories and hence does not come with predefined waveforms such as gauss or ones. Therefore, all waveforms need to be defined in Python and uploaded to the device using upload_waveforms method.

For example, the generator can be programmed with a custom .seqc code like this:

>>> generator = shf.qachannels[0].generator
>>> ...
>>> wait_time = 512
>>> custom_program='''
>>> waitDigTrigger(1);
>>> wait($param1$);
>>> startQA(QA_GEN_0, QA_INT_0, true,  0, 0x1 );
>>> wait($param1$);
>>> startQA(QA_GEN_1, QA_INT_1, true,  0, 0x0 );
>>> wait($param1$);
>>> startQA(QA_GEN_2, QA_INT_2, true,  0, 0x0 );
>>> '''
>>> generator.set_sequence_params(
>>>     sequence_type="Custom",
>>>     program = custom_program,
>>>     custom_params = [wait_time],
>>> )

The user can also upload waveforms defined as numpy arrays:

>>> wave = np.linspace(1, 0, wave_length)
>>> amps = np.linspace(0.5, 1, 3)
>>> data = [amp * wave for amp in amps]
>>> generator.reset_queue()
>>> for wave in data:
>>>     generator.queue_waveform(wave)
Current length of queue: 1
Current length of queue: 2
Current length of queue: 3
>>> generator.compile()
>>> generator.upload_waveforms()
Upload of 3 waveforms took 0.20744 s

To run the sequencer and play the uploaded waveforms:

>>> generator.wait_done()

The parent qachannel that this SHFGenerator is associated to.




The instrument that this SHFGenerator is associated to.




An integer specifying the index in the instrument.




A list of SHFWaveform s that represent the queued up waveforms in for a ‘Custom’ sequence.




The name of the SHFGenerator.




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




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



compile() → None

Compile the current SequenceProgram and load it to sequencer.

  • 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.

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

Add a new waveform to the queue.

  • wave (array) – The waveform to be queued as a 1D numpy array.

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


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

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

Replace a waveform in the queue at a given index.

  • wave (array) – Waveform to replace current wave

  • 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 generator.


sync (bool) – A flag that specifies if a synchronisation should be performed between the device and the data server after enabling the generator (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 property sequence_params.

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

>>> shfqa.qachannels[0].generator
<zhinst.toolkit.control.drivers.shfqa.Generator object at 0x0000016B7B71DDC8>
    parent  : <zhinst.toolkit.control.drivers.shfqa.QAChannel object at 0x0000016B7B71D508>
    index   : 0
        type: SequenceType.CUSTOM
        ('target', <DeviceTypes.SHFQA: 'shfqa'>)
        ('clock_rate', 2400000000.0)
        ('period', 0.0001)
        ('trigger_mode', <TriggerMode.SEND_TRIGGER: 'Send Trigger'>)
        ('trigger_samples', 32)
        ('repetitions', 1)
        ('alignment', <Alignment.END_WITH_TRIGGER: 'End with Trigger'>)
>>> shfqa.qachannels[0].generator.set_sequence_params(
>>>     sequence_type="Custom",
>>>     program = seqc_program_string,
>>>     custom_params = [param1, param2],
>>> )
stop(sync=True) → None

Stop the generator.


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

upload_waveforms() → None

Upload all waveforms in the queue to the Generator.

This method only works as expected if the Sequence Program has been compiled beforehand. See compile_and_upload_waveforms(...)().

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

Wait until the generator is finished.

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

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

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

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