QASM program class for Qblox backend.

Module Contents



Class that holds the compiled Q1ASM program that is to be executed by the sequencer.

class QASMProgram(static_hw_properties: quantify_scheduler.backends.types.qblox.StaticHardwareProperties, register_manager: quantify_scheduler.backends.qblox.register_manager.RegisterManager)[source]

Class that holds the compiled Q1ASM program that is to be executed by the sequencer.

Apart from this the class holds some convenience functions that auto generate certain instructions with parameters, as well as update the elapsed time.

register_manager :quantify_scheduler.backends.qblox.register_manager.RegisterManager[source]

The register manager that keeps track of the occupied/available registers.

static_hw_properties :quantify_scheduler.backends.types.qblox.StaticHardwareProperties[source]

Dataclass holding the properties of the hardware that this program is to be played on.

elapsed_time :int = 0[source]

The time elapsed after finishing the program in its current form. This is used to keep track of the overall timing and necessary waits.

integration_length_acq :Optional[int][source]

Integration length to use for the square acquisition.

time_last_acquisition_triggered :Optional[int][source]

Time on which the last acquisition was triggered. Is None if no previous acquisition was triggered.

instructions :List[list][source]

A list containing the instructions added to the program. The instructions added are in turn a list of the instruction string with arguments.

static get_instruction_as_list(instruction: str, *args: Union[int, str], label: Optional[str] = None, comment: Optional[str] = None) List[Union[str, int]][source]

Takes an instruction with arguments, label and comment and turns it into the list required by the class.

  • instruction – The instruction to use. This should be one specified in PulsarInstructions or the assembler will raise an exception.

  • args – Arguments to be passed.

  • label – Adds a label to the line. Used for jumps and loops.

  • comment – Optionally add a comment to the instruction.


List that contains all the passed information in the valid format for the program.


SyntaxError – More arguments passed than the sequencer allows.

emit(*args, **kwargs) None[source]

Wrapper around the get_instruction_as_list which adds it to this program.

  • args – All arguments to pass to get_instruction_as_list.

  • **kwargs – All keyword arguments to pass to get_instruction_as_list.

set_marker(marker_setting: Union[str, int] = '0000') None[source]

Sets the marker from a string representing a binary number. Each digit corresponds to a marker e.g. ‘0010’ sets the second marker to True.


marker_setting – The string representing a binary number.

auto_wait(wait_time: int, count_as_elapsed_time: bool = True, comment: Optional[str] = None) None[source]

Automatically emits a correct wait command. If the wait time is longer than allowed by the sequencer it correctly breaks it up into multiple wait instructions. If the number of wait instructions is too high (>4), a loop will be used.

  • wait_time – Time to wait in ns.

  • count_as_elapsed_time – If true, this wait time is taken into account when keeping track of timing. Otherwise, the wait instructions are added but this wait time is ignored in the timing calculations in the rest of the program.

  • comment – Allows to override the default comment.


ValueError – If wait_time <= 0.

wait_till_start_operation(operation: quantify_scheduler.backends.types.qblox.OpInfo) None[source]

Waits until the start of a pulse or acquisition.


operation – The pulse or acquisition that we want to wait for.


ValueError – If wait time < 0.

verify_square_acquisition_duration(acquisition: quantify_scheduler.backends.types.qblox.OpInfo, duration: float)[source]

Verifies if the square acquisition is valid by checking constraints on the duration.

  • acquisition – The operation info of the acquisition to process.

  • duration – The duration to verify.

  • ValueError – When attempting to perform an acquisition of a duration that is not a multiple of 4 ns.

  • ValueError – When using a different duration than previous acquisitions.

_acquire_looped(acquisition: quantify_scheduler.backends.types.qblox.OpInfo, bin_idx: Union[int, str]) None[source]
set_gain_from_amplitude(voltage_path0: float, voltage_path1: float, operation: Optional[quantify_scheduler.backends.types.qblox.OpInfo]) None[source]

Sets the gain such that a 1.0 in waveform memory corresponds to the specified voltage. i.e. changes the full scale range.

  • voltage_path0 – Voltage to set on path0.

  • voltage_path1 – Voltage to set on path1.

  • operation – The operation for which this is done. Used for the exception messages.


ValueError – Trying to set a voltage outside the max range of the instrument.

static expand_from_normalised_range(val: float, immediate_size: int, param: Optional[str] = None, operation: Optional[quantify_scheduler.backends.types.qblox.OpInfo] = None)[source]

Takes the value of a parameter in normalized form (abs(param) <= 1.0), and expands it to an integer in the appropriate range required by the sequencer.

  • val – The value of the parameter to expand.

  • immediate_size – The size of the immediate. Used to find the max int value.

  • param – The name of the parameter, to make a possible exception message more descriptive.

  • operation – The operation this value is expanded for, to make a possible exception message more descriptive.


The expanded value of the parameter.


ValueError – Parameter is not in the normalized range.

__str__() str[source]

Returns a string representation of the program. The pulsar expects the program to be such a string.

The conversion to str is done using columnar, which expects a list of lists, and turns it into a string with rows and columns corresponding to those lists.


The string representation of the program.

loop(label: str, repetitions: int = 1)[source]

Defines a context manager that can be used to generate a loop in the QASM program.

  • label – The label to use for the jump.

  • repetitions – The amount of iterations to perform.


The register used as loop counter.


This adds a loop to the program that loops 10 times over a wait of 100 ns.

from quantify_scheduler.backends.qblox.qasm_program import QASMProgram
from quantify_scheduler.backends.qblox import register_manager, constants
from quantify_scheduler.backends.types.qblox import (

static_hw_properties: StaticHardwareProperties = StaticHardwareProperties(
    marker_configuration=MarkerConfiguration(init=None, start=0b1111, end=0b0000),
    mixer_dc_offset_range=BoundedParameter(min_val=-2.5, max_val=2.5, units="V"),
    valid_ios=[f"complex_output_{i}" for i in [0, 1]]
    + [f"real_output_{i}" for i in range(4)],
qasm = QASMProgram(static_hw_properties, register_manager.RegisterManager())

with qasm.loop(label="repeat", repetitions=10):

[['', 'move', '10,R0', '# iterator for loop with label repeat'],
 ['repeat:', '', '', ''],
 ['', 'wait', '100', '# auto generated wait (100 ns)'],
 ['', 'loop', 'R0,@repeat', '']]
temp_registers(amount: int = 1) Iterator[List[str]][source]

Context manager for using a register temporarily. Frees up the register afterwards.


amount – The amount of registers to temporarily use.


Either a single register or a list of registers.