seqc_il_generator#

Module Contents#

Classes#

SeqcInstructions

The sequencer enum type.

SeqcILGenerator

The Intermediate Sequencer Language Generator.

Functions#

add_wait(→ int)

Add a wait instruction to the SeqcILGenerator with the specified delay.

add_play_wave(→ int)

Adds a playWave instruction to the

add_start_qa(→ int)

Adds a startQA instruction to the

add_execute_table_entry(→ int)

Adds an executeTableEntry instruction to

add_set_trigger(→ int)

Adds a setTrigger instruction to the seqc

declare_csv_waveform_variables(seqc_gen, device_name, ...)

Declares waveforms and links them to filenames of .csv files.

add_csv_waveform_variables(seqc_gen, device_serial, ...)

Adds wave variables in form of a

Attributes#

logger[source]#
class SeqcInstructions[source]#

Bases: enum.Enum

The sequencer enum type.

NONE = ''[source]#
PLAY_WAVE = 'playWave'[source]#
SET_TRIGGER = 'setTrigger'[source]#
WAIT = 'wait'[source]#
WAIT_WAVE = 'waitWave'[source]#
ARM_INTEGRATION = 'AWG_INTEGRATION_ARM + AWG_INTEGRATION_TRIGGER + AWG_MONITOR_TRIGGER'[source]#
EXECUTE_TABLE_ENTRY = 'executeTableEntry'[source]#
START_QA = 'startQA'[source]#
SEQC_INSTR_CLOCKS: Dict[quantify_scheduler.backends.types.zhinst.DeviceType, Dict[SeqcInstructions, int]][source]#
class SeqcILGenerator[source]#

Bases: 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).

_level: int[source]#
_variables: Dict[str, Tuple[str, str | None]][source]#
_program: List[Tuple[int, str]][source]#
_declare_local(type_def: str, name: str) None[source]#

Creates a new local variable.

Parameters:
  • type_def – The variable type definition.

  • name – The variable name.

Raises:

ValueError – Duplicate local variable error.

_assign_local(name: str, value: str) None[source]#

Assign a value to a local variable.

Parameters:
  • name – The variable name.

  • value – The new variable value.

Raises:

ValueError – Undefined reference error.

_emit(operation: str) None[source]#

Emits a new operation to the program.

Parameters:

operation – The operation to append.

_begin_scope() None[source]#

Indent a new scope level.

_end_scope() None[source]#

Dedent the scope level.

Raises:

ValueError – Scope level error.

declare_var(name: str, value: str | int | None = None) None[source]#

Creates a new variable of type var with a name and optionally its value.

Parameters:
  • name – The variable name.

  • value (Optional[str]) – The variable value. (optional)

declare_wave(name: str, value: str | None = None) None[source]#

Creates a new variable of type wave with a name and optionally its value.

Parameters:
  • name – The variable name.

  • value – The variable value. (optional)

assign_get_user_reg(name: str, index: int) None[source]#

Assign the getUserReg function to a variable by name with a specific index.

Parameters:
  • name – The variable name.

  • index – The register index.

assign_placeholder(name: str, size: int) None[source]#

Assign a placeholder to a variable by name with a specific size.

Parameters:
  • name – The variable name.

  • size – The size of the placeholder.

assign_var(name: str, value: str | int | List[Any]) None[source]#

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"; # <-- `

Parameters:
  • name – The variable name.

  • value – The new value.

emit_blankline() None[source]#

Emits a blank line to the program.

This is typically used to create a visual separation for readability.

emit_comment(text: str) None[source]#

Emit a comment to the program.

Parameters:

text – The comment text.

emit_assign_wave_index(*args: str, index: int) None[source]#

Emit assignWaveIndex to the program which assigns a wave variable to an index in the waveform table (just like a pointer).

Parameters:

index – The waveform table index.

emit_execute_table_entry(index: int, comment: str = '') None[source]#

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.

Parameters:

index – The wave index to execute.

emit_play_wave(*names: str, comment: str = '') None[source]#

Emit playWave to the program.

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

  • comment – The inline comment to be emitted in the seqc.

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

//Definition inline with playWave
playWave("wave_file");
//Assign first to a wave data type, then use
wave w = "wave_file";
playWave(w)
emit_wait_wave(comment: str = '') None[source]#

Emit waitWave to the program.

emit_start_qa(comment: str = '') None[source]#

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

emit_wait(cycles: int, comment: str = '') None[source]#

Emits a wait instruction to the sequencer program.

Parameters:
  • cycles – The number of cycles to wait.

  • comment – The inline comment to be emitted in the seqc.

emit_set_trigger(index: int | str, comment: str = '') None[source]#

Emit setTrigger to the program.

Parameters:

index – The number or string of a trigger to set.

emit_wait_dig_trigger(index: int = 0, comment: str = '', device_type: quantify_scheduler.backends.types.zhinst.DeviceType | None = None) None[source]#

Emit waitDigTrigger to the program.

Parameters:

index – The trigger to wait on, by default 0

emit_start_qa_monitor() None[source]#

Starts the Quantum Analysis Monitor unit by setting and clearing appropriate AWG trigger output signals.

emit_start_qa_result(bitmask: str | None = None, trigger: str | None = None) None[source]#

Starts the Quantum Analysis Result unit by setting and clearing appropriate AWG trigger output signals.

// Start Quantum Analysis Result unit for
// channel=1 on trigger=AWG_INTEGRATION_TRIGGER
startQAResult(0b0000000001, AWG_INTEGRATION_TRIGGER);

// Reset and clear triggers
startQAResult();
Parameters:
  • bitmask – The bitmake to select explicitly which of the ten possible qubit results should be read, by default “”

  • trigger – The trigger to start the Quantum Analysis Result unit. If no trigger is specified it will clear the triggers, by default “”

emit_begin_while(predicate: str = 'true') None[source]#

Emit while loop to the program.

Parameters:

predicate – The while condition, by default “true”

emit_end_while() None[source]#

Emit ending the while loop.

emit_begin_repeat(repetitions: int | str = 1) None[source]#

Emit repeat loop to the program.

Parameters:

repetitions – The repeat condition, by default 1

emit_end_repeat() None[source]#

Emit ending the repeat loop.

generate() str[source]#

Returns the generated seqc program.

This program can be run on ZI AWG(s).

Returns:

str

The seqc program.

add_wait(seqc_gen: SeqcILGenerator, delay: int, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') int[source]#

Add a wait instruction to the SeqcILGenerator with the specified delay.

Parameters:
  • seqc_gen – The SeqcILGenerator to add the wait instruction to.

  • delay – The delay in clocks.

  • device_type – The device type.

  • comment – An optional comment to the instruction, by default “”

Returns:

The number of clocks waited.

Return type:

int

Raises:

ValueError

add_play_wave(seqc_gen: SeqcILGenerator, *variable: str, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') int[source]#

Adds a playWave instruction to the seqc program.

Parameters:
  • seqc_gen – The SeqcILGenerator to add the playWave instruction to.

  • variable – The variable to play.

  • device_type – The device type.

  • comment – An optional comment to the instruction, by default “”.

Returns:

Elapsed number of clock cycles.

Return type:

int

add_start_qa(seqc_gen: SeqcILGenerator, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') int[source]#

Adds a startQA instruction to the seqc program. See emit_start_qa() for more details.

Parameters:
  • seqc_gen – The SeqcILGenerator to add the startQA instruction to.

  • device_type – The device type.

  • comment – An optional comment to the instruction, by default “”.

Returns:

Elapsed number of clock cycles.

Return type:

int

add_execute_table_entry(seqc_gen: SeqcILGenerator, index: int, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') int[source]#

Adds an executeTableEntry instruction to seqc program.

Parameters:
  • seqc_gen – The SeqcILGenerator to add the executeTableEntry instruction to.

  • index – The index of the table entry to execute.

  • device_type – The device type.

  • comment – An optional comment to the instruction, by default “”.

Returns:

Elapsed number of clock cycles.

Return type:

int

Raises:

AttributeError – Raised when the DeviceType not equals HDAWG.

add_set_trigger(seqc_gen: SeqcILGenerator, value: List[str] | int | str, device_type: quantify_scheduler.backends.types.zhinst.DeviceType, comment: str = '') int[source]#

Adds a setTrigger instruction to the seqc program.

Parameters:
  • seqc_gen – The SeqcILGenerator to add the setTrigger instruction to.

  • value – The trigger to set.

  • device_type – The device type.

  • comment – An optional comment to the instruction, by default “”.

Returns:

Elapsed number of clock cycles.

Return type:

int

declare_csv_waveform_variables(seqc_gen: SeqcILGenerator, device_name: str, waveform_indices: List[int], awg_index: int = 0)[source]#

Declares waveforms and links them to filenames of .csv files.

e.g. wave w0 = `uhfqa1234_awg0_wave0

add_csv_waveform_variables(seqc_gen: SeqcILGenerator, device_serial: str, awg_index: int, commandtable_map: Dict[int, int])[source]#

Adds wave variables in form of a CSV filename to the seqc file.

Parameters:
  • seqc_gen – The SeqcILGenerator to add the setTrigger instruction to.

  • device_serial – The device serial number.

  • awg_index – The AWG index.

  • commandtable_map – The commandtable map.