qasm_program ============ .. py:module:: quantify_scheduler.backends.qblox.qasm_program .. autoapi-nested-parse:: QASM program class for Qblox backend. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quantify_scheduler.backends.qblox.qasm_program.QASMProgram .. py:class:: QASMProgram(static_hw_properties: quantify_scheduler.backends.types.qblox.StaticHardwareProperties, register_manager: quantify_scheduler.backends.qblox.register_manager.RegisterManager, align_fields: bool, acq_metadata: Optional[quantify_scheduler.schedules.schedule.AcquisitionMetadata]) 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. :param static_hw_properties: Dataclass holding the properties of the hardware that this program is to be played on. :param register_manager: The register manager that keeps track of the occupied/available registers. :param align_fields: If True, make QASM program more human-readable by aligning its fields. .. py:attribute:: register_manager :type: quantify_scheduler.backends.qblox.register_manager.RegisterManager The register manager that keeps track of the occupied/available registers. .. py:attribute:: static_hw_properties :type: quantify_scheduler.backends.types.qblox.StaticHardwareProperties Dataclass holding the properties of the hardware that this program is to be played on. .. py:attribute:: elapsed_time :type: int :value: 0 The time elapsed after finishing the program in its current form. This is used to keep track of the overall timing and necessary waits. .. py:attribute:: integration_length_acq :type: Optional[int] Integration length to use for the square acquisition. .. py:attribute:: time_last_acquisition_triggered :type: Optional[int] Time on which the last acquisition was triggered. Is ``None`` if no previous acquisition was triggered. .. py:attribute:: instructions :type: List[list] A list containing the instructions added to the program. The instructions added are in turn a list of the instruction string with arguments. .. py:attribute:: align_fields :type: bool If true, all labels, instructions, arguments and comments in the string representation of the program are printed on the same indention level. This worsens performance. .. py:attribute:: conditional_manager :type: quantify_scheduler.backends.qblox.conditional.ConditionalManager The conditional manager that keeps track of the conditionals. .. py:attribute:: acq_metadata :type: Optional[quantify_scheduler.schedules.schedule.AcquisitionMetadata] Acquisition metadata. .. py:attribute:: _lock_conditional :type: bool :value: False A lock to prevent nested conditionals. .. py:method:: _find_qblox_acq_index(acq_channel: Hashable) -> int Finds the Qblox acq_index corresponding to acq_channel in the acq_metadata. .. py:method:: get_instruction_as_list(instruction: str, *args: Union[int, str], label: Optional[str] = None, comment: Optional[str] = None) -> List[Union[str, int]] :staticmethod: Takes an instruction with arguments, label and comment and turns it into the list required by the class. :param instruction: The instruction to use. This should be one specified in :mod:`~quantify_scheduler.backends.qblox.q1asm_instructions` or the assembler will raise an exception. :param args: Arguments to be passed. :param label: Adds a label to the line. Used for jumps and loops. :param comment: Optionally add a comment to the instruction. :returns: List that contains all the passed information in the valid format for the program. :raises SyntaxError: More arguments passed than the sequencer allows. .. py:method:: emit(*args, **kwargs) -> list[str, int] Wrapper around the ``get_instruction_as_list`` which adds it to this program. :param args: All arguments to pass to `get_instruction_as_list`. :param \*\*kwargs: All keyword arguments to pass to `get_instruction_as_list`. :returns: A list containing instructions. .. py:method:: set_marker(marker_setting: Union[str, int] = '0000') -> None 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. :param marker_setting: The string representing a binary number. .. py:method:: set_latch(pulses: Sequence[quantify_scheduler.backends.qblox.operation_handling.base.IOperationStrategy]) -> None Set the latch that is needed for conditional playback. This assumes that the latch address is present inside the pulses' `operation_info`. If no latch address is found, nothing is emitted. :param pulses: The pulses to search the latch address in. .. py:method:: auto_wait(wait_time: int, count_as_elapsed_time: bool = True, comment: Optional[str] = None) -> None 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. :param wait_time: Time to wait in ns. :param 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. :param comment: Allows to override the default comment. :raises ValueError: If ``wait_time <= 0``. .. py:method:: wait_till_start_operation(operation: quantify_scheduler.backends.types.qblox.OpInfo) -> None Waits until the start of a pulse or acquisition. :param operation: The pulse or acquisition that we want to wait for. :raises ValueError: If wait time < 0. .. py:method:: verify_square_acquisition_duration(acquisition: quantify_scheduler.backends.types.qblox.OpInfo, duration: float) Verifies if the square acquisition is valid by checking constraints on the duration. :param acquisition: The operation info of the acquisition to process. :param duration: The duration to verify. :raises ValueError: When attempting to perform an acquisition of a duration that is not a multiple of 4 ns. :raises ValueError: When using a different duration than previous acquisitions. .. py:method:: _acquire_looped(acquisition: quantify_scheduler.backends.types.qblox.OpInfo, bin_idx: Union[int, str]) -> None .. py:method:: set_gain_from_amplitude(amplitude_path_I: float, amplitude_path_Q: float, operation: Optional[quantify_scheduler.backends.types.qblox.OpInfo]) -> None Sets the gain such that a 1.0 in waveform memory corresponds to the full awg gain. :param amplitude_path_I: Voltage to set on path_I. :param amplitude_path_Q: Voltage to set on path_Q. :param operation: The operation for which this is done. Used for the exception messages. .. py:method:: expand_awg_from_normalised_range(val: float, immediate_size: int, param: Optional[str] = None, operation: Optional[quantify_scheduler.backends.types.qblox.OpInfo] = None) :staticmethod: Takes the value of an awg gain or offset parameter in normalized form (abs(param) <= 1.0), and expands it to an integer in the appropriate range required by the sequencer. :param val: The value of the parameter to expand. :param immediate_size: The size of the immediate. Used to find the max int value. :param param: The name of the parameter, to make a possible exception message more descriptive. :param operation: The operation this value is expanded for, to make a possible exception message more descriptive. :returns: The expanded value of the parameter. :raises ValueError: Parameter is not in the normalized range. .. py:method:: conditional(operation: quantify_scheduler.backends.qblox.operation_handling.virtual.ConditionalStrategy) -> None Defines a conditional block in the QASM program. When this context manager is entered/exited it will insert additional ``set_cond`` QASM instructions in the program that specify the conditionality of a set of instructions. For example, a conditional X gate would correspond to the QASM program: .. code-block:: set_cond 1, 0, 0, 20 play 1, 20 set_cond 0, 0, 0, 4 The exact values that need to be passed to the first ``set_cond`` instruction are determined while the qasm program is generated with the help of :class:`~quantify_scheduler.backends.qblox.conditional.FeedbackTriggerCondition` and :class:`~quantify_scheduler.backends.qblox.conditional.ConditionalManager`. :param operation: The conditional strategy that defines the start of a conditional block. :type operation: ConditionalStrategy .. py:method:: loop(label: str, repetitions: int = 1) Defines a context manager that can be used to generate a loop in the QASM program. :param label: The label to use for the jump. :param repetitions: The amount of iterations to perform. :Yields: The register used as loop counter. .. rubric:: Examples This adds a loop to the program that loops 10 times over a wait of 100 ns. .. jupyter-execute:: from quantify_scheduler.backends.qblox.qasm_program import QASMProgram from quantify_scheduler.backends.qblox.instrument_compilers import QcmModule from quantify_scheduler.backends.qblox import register_manager, constants from quantify_scheduler.backends.types.qblox import ( StaticHardwareProperties, BoundedParameter ) qasm = QASMProgram( static_hw_properties=QcmModule.static_hw_properties, register_manager=register_manager.RegisterManager(), align_fields=True, acq_metadata=None, ) with qasm.loop(label="repeat", repetitions=10): qasm.auto_wait(100) qasm.instructions .. py:method:: temp_registers(amount: int = 1) -> Iterator[List[str]] Context manager for using a register temporarily. Frees up the register afterwards. :param amount: The amount of registers to temporarily use. :Yields: Either a single register or a list of registers.