seqc_il_generator ================= .. py:module:: quantify_scheduler.backends.zhinst.seqc_il_generator Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quantify_scheduler.backends.zhinst.seqc_il_generator.SeqcInstructions quantify_scheduler.backends.zhinst.seqc_il_generator.SeqcILGenerator Functions ~~~~~~~~~ .. autoapisummary:: quantify_scheduler.backends.zhinst.seqc_il_generator.add_wait quantify_scheduler.backends.zhinst.seqc_il_generator.add_play_wave quantify_scheduler.backends.zhinst.seqc_il_generator.add_start_qa quantify_scheduler.backends.zhinst.seqc_il_generator.add_execute_table_entry quantify_scheduler.backends.zhinst.seqc_il_generator.add_set_trigger quantify_scheduler.backends.zhinst.seqc_il_generator.declare_csv_waveform_variables quantify_scheduler.backends.zhinst.seqc_il_generator.add_csv_waveform_variables Attributes ~~~~~~~~~~ .. autoapisummary:: quantify_scheduler.backends.zhinst.seqc_il_generator.logger quantify_scheduler.backends.zhinst.seqc_il_generator.SEQC_INSTR_CLOCKS .. py:data:: logger .. py:class:: SeqcInstructions Bases: :py:obj:`enum.Enum` The sequencer enum type. .. py:attribute:: NONE :value: '' .. py:attribute:: PLAY_WAVE :value: 'playWave' .. py:attribute:: SET_TRIGGER :value: 'setTrigger' .. py:attribute:: WAIT :value: 'wait' .. py:attribute:: WAIT_WAVE :value: 'waitWave' .. py:attribute:: ARM_INTEGRATION :value: 'AWG_INTEGRATION_ARM + AWG_INTEGRATION_TRIGGER + AWG_MONITOR_TRIGGER' .. py:attribute:: EXECUTE_TABLE_ENTRY :value: 'executeTableEntry' .. py:attribute:: START_QA :value: 'startQA' .. py:data:: SEQC_INSTR_CLOCKS :type: Dict[quantify_scheduler.backends.types.zhinst.DeviceType, Dict[SeqcInstructions, int]] .. py:class:: SeqcILGenerator Bases: :py:obj:`object` The Intermediate Sequencer Language Generator. This class acts a an assembler for the seqc programs which can be executed on the ZI AWG(s). .. py:attribute:: _level :type: int .. py:attribute:: _variables :type: Dict[str, Tuple[str, Optional[str]]] .. py:attribute:: _program :type: List[Tuple[int, str]] .. py:method:: _declare_local(type_def: str, name: str) -> None Creates a new local variable. :param type_def: The variable type definition. :param name: The variable name. :raises ValueError: Duplicate local variable error. .. py:method:: _assign_local(name: str, value: str) -> None Assign a value to a local variable. :param name: The variable name. :param value: The new variable value. :raises ValueError: Undefined reference error. .. py:method:: _emit(operation: str) -> None Emits a new operation to the program. :param operation: The operation to append. .. py:method:: _begin_scope() -> None Indent a new scope level. .. py:method:: _end_scope() -> None Dedent the scope level. :raises ValueError: Scope level error. .. py:method:: declare_var(name: str, value: Optional[Union[str, int]] = None) -> None Creates a new variable of type ``var`` with a name and optionally its value. :param name: The variable name. :param value: The variable value. (optional) :type value: Optional[str] .. py:method:: declare_wave(name: str, value: Optional[str] = None) -> None Creates a new variable of type ``wave`` with a name and optionally its value. :param name: The variable name. :param value: The variable value. (optional) .. py:method:: assign_get_user_reg(name: str, index: int) -> None Assign the getUserReg function to a variable by name with a specific index. :param name: The variable name. :param index: The register index. .. py:method:: assign_placeholder(name: str, size: int) -> None Assign a placeholder to a variable by name with a specific size. :param name: The variable name. :param size: The size of the placeholder. .. py:method:: assign_var(name: str, value: Union[str, int, List[Any]]) -> None Assign a value to a variable by name. This method requires the variable to be declared before allowing a new value to be assigned to it. Translates to: ``` wave w0; wave w0 = "dev1234_awg0_0"; # <-- ``` :param name: The variable name. :param value: The new value. .. py:method:: emit_blankline() -> None Emits a blank line to the program. This is typically used to create a visual separation for readability. .. py:method:: emit_comment(text: str) -> None Emit a comment to the program. :param text: The comment text. .. py:method:: emit_assign_wave_index(*args: str, index: int) -> None Emit assignWaveIndex to the program which assigns a wave variable to an index in the waveform table (just like a pointer). :param index: The waveform table index. .. py:method:: emit_execute_table_entry(index: int, comment: str = '') -> None Emit executeTableEntry to the program. Executes a command table waveform. ::note ``executeTableEntry`` is not blocking so if you want to await the wave use `waitWave` directly after it. :param index: The wave index to execute. .. py:method:: emit_play_wave(*names: str, comment: str = '') -> None Emit playWave to the program. :param names: The wave names to be played. This should refer to the wave variable name as defined in the seqc, or the wave index in the commandtable to be played. :param comment: The inline comment to be emitted in the seqc. .. rubric:: Examples An example for the use of the playWave instruction from the LabOne Programming Manual. Ensure that the "wave_file" variable (the name argument) corresponds to a filename that was declared using the declareWave .. code-block:: //Definition inline with playWave playWave("wave_file"); //Assign first to a wave data type, then use wave w = "wave_file"; playWave(w) .. py:method:: emit_wait_wave(comment: str = '') -> None Emit waitWave to the program. .. py:method:: emit_start_qa(comment: str = '') -> None Starts the Quantum Analysis Result and Input units by setting and clearing appropriate AWG trigger output signals. The choice of whether to start one or the other or both units can be controlled using the command argument. An bitmask may be used to select explicitly which of the ten possible qubit results should be read. If no qubit results are enabled, then the Quantum Analysis Result unit will not be triggered. An optional value may be used to set the normal trigger outputs of the AWG together with starting the Quantum Analysis Result and input units. If the value is not used, then the trigger signals will be cleared. Parameter - monitor: Enable for QA monitor, default: false - result_address: Set address associated with result, default: 0x0 - trigger: Trigger value, default: 0x0 - weighted_integrator_mask: Integration unit enable mask, default: QA_INT_ALL .. py:method:: emit_wait(cycles: int, comment: str = '') -> None Emits a wait instruction to the sequencer program. :param cycles: The number of cycles to wait. :param comment: The inline comment to be emitted in the seqc. .. py:method:: emit_set_trigger(index: Union[int, str], comment: str = '') -> None Emit setTrigger to the program. :param index: The number or string of a trigger to set. .. py:method:: emit_wait_dig_trigger(index: int = 0, comment: str = '', device_type: Optional[quantify_scheduler.backends.types.zhinst.DeviceType] = None) -> None Emit waitDigTrigger to the program. :param index: The trigger to wait on, by default 0 .. py:method:: emit_start_qa_monitor() -> None Starts the Quantum Analysis Monitor unit by setting and clearing appropriate AWG trigger output signals. .. py:method:: emit_start_qa_result(bitmask: Optional[str] = None, trigger: Optional[str] = None) -> None Starts the Quantum Analysis Result unit by setting and clearing appropriate AWG trigger output signals. .. code-block:: python // Start Quantum Analysis Result unit for // channel=1 on trigger=AWG_INTEGRATION_TRIGGER startQAResult(0b0000000001, AWG_INTEGRATION_TRIGGER); // Reset and clear triggers startQAResult(); :param bitmask: The bitmake to select explicitly which of the ten possible qubit results should be read, by default "" :param trigger: The trigger to start the Quantum Analysis Result unit. If no trigger is specified it will clear the triggers, by default "" .. py:method:: emit_begin_while(predicate: str = 'true') -> None Emit while loop to the program. :param predicate: The while condition, by default "true" .. py:method:: emit_end_while() -> None Emit ending the while loop. .. py:method:: emit_begin_repeat(repetitions: Union[int, str] = 1) -> None Emit repeat loop to the program. :param repetitions: The repeat condition, by default 1 .. py:method:: emit_end_repeat() -> None Emit ending the repeat loop. .. py:method:: generate() -> str Returns the generated seqc program. This program can be run on ZI AWG(s). :returns: str The seqc program. .. py:function:: add_wait(seqc_gen: SeqcILGenerator, delay: int, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') -> int Add a wait instruction to the SeqcILGenerator with the specified delay. :param seqc_gen: The SeqcILGenerator to add the wait instruction to. :param delay: The delay in clocks. :param device_type: The device type. :param comment: An optional comment to the instruction, by default "" :returns: The number of clocks waited. :rtype: int :raises ValueError: .. py:function:: add_play_wave(seqc_gen: SeqcILGenerator, *variable: str, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') -> int Adds a playWave instruction to the seqc program. :param seqc_gen: The SeqcILGenerator to add the playWave instruction to. :param variable: The variable to play. :param device_type: The device type. :param comment: An optional comment to the instruction, by default "". :returns: Elapsed number of clock cycles. :rtype: int .. py:function:: add_start_qa(seqc_gen: SeqcILGenerator, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') -> int Adds a startQA instruction to the seqc program. See :func:`~quantify_scheduler.backends.zhinst.seqc_il_generator.SeqcILGenerator.emit_start_qa` for more details. :param seqc_gen: The SeqcILGenerator to add the startQA instruction to. :param device_type: The device type. :param comment: An optional comment to the instruction, by default "". :returns: Elapsed number of clock cycles. :rtype: int .. py:function:: add_execute_table_entry(seqc_gen: SeqcILGenerator, index: int, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') -> int Adds an executeTableEntry instruction to seqc program. :param seqc_gen: The SeqcILGenerator to add the executeTableEntry instruction to. :param index: The index of the table entry to execute. :param device_type: The device type. :param comment: An optional comment to the instruction, by default "". :returns: Elapsed number of clock cycles. :rtype: int :raises AttributeError: Raised when the DeviceType not equals HDAWG. .. py:function:: add_set_trigger(seqc_gen: SeqcILGenerator, value: Union[List[str], int, str], device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') -> int Adds a setTrigger instruction to the seqc program. :param seqc_gen: The SeqcILGenerator to add the setTrigger instruction to. :param value: The trigger to set. :param device_type: The device type. :param comment: An optional comment to the instruction, by default "". :returns: Elapsed number of clock cycles. :rtype: int .. py:function:: declare_csv_waveform_variables(seqc_gen: SeqcILGenerator, device_name: str, waveform_indices: List[int], awg_index: int = 0) Declares waveforms and links them to filenames of .csv files. e.g. `wave w0 = `uhfqa1234_awg0_wave0` .. py:function:: add_csv_waveform_variables(seqc_gen: SeqcILGenerator, device_serial: str, awg_index: int, commandtable_map: Dict[int, int]) Adds wave variables in form of a CSV filename to the seqc file. :param seqc_gen: The SeqcILGenerator to add the setTrigger instruction to. :param device_serial: The device serial number. :param awg_index: The AWG index. :param commandtable_map: The commandtable map.