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) 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. Instantiates the QASMProgram. :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. .. 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: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 `PulsarInstructions` 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) -> None 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`. .. 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:: 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_path0: float, amplitude_path1: 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_path0: Voltage to set on path0. :param amplitude_path1: Voltage to set on path1. :param operation: The operation for which this is done. Used for the exception messages. .. py:method:: expand_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 a 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:: 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 import register_manager, constants from quantify_scheduler.backends.types.qblox import ( StaticHardwareProperties, BoundedParameter ) static_hw_properties: StaticHardwareProperties = StaticHardwareProperties( instrument_type="QCM", max_sequencers=constants.NUMBER_OF_SEQUENCERS_QCM, max_awg_output_voltage=2.5, 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): 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.