Commit e9dbee1c authored by Kelvin Loh's avatar Kelvin Loh 🖖
Browse files

Merge branch 'feat/zhinst-control-stack' into 'develop'

feat(zhinst): Zurich Instruments ControlStack

Closes #106 and #109

See merge request quantify-os/quantify-scheduler!99
parents fd74defd a6a4727e
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ ENV/

# IDE settings
*.sublime-*
.vscode

# System files
*.DS_Store
+6 −0
Original line number Diff line number Diff line
@@ -222,6 +222,12 @@ base
.. automodule:: quantify.scheduler.controlstack.components.base
    :members:

zhinst
~~~~~~

.. automodule:: quantify.scheduler.controlstack.components.zhinst
    :members:


miscellaneous
-------------
+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class Output(DataClassJsonMixin):
    modulation :
        The modulation settings.
    local_oscillator :
        The LocalOscillator settings.
        The LocalOscillator name.
    gain1 :
        The output1 IQ modulation gain (value between -1 and + 1). default is 0.
    gain2 :
@@ -59,7 +59,7 @@ class Output(DataClassJsonMixin):
    clock: str
    mode: enums.SignalModeType
    modulation: common.Modulation
    local_oscillator: common.LocalOscillator
    local_oscillator: str
    gain1: int = 0
    gain2: int = 0
    line_trigger_delay: float = -1
+57 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ from typing import Any, Dict, List, Union

from zhinst.qcodes import base
from zhinst import qcodes

from quantify.scheduler.helpers import time

logger = logging.getLogger()

@@ -100,7 +100,7 @@ def set_awg_value(
        The awg to configure.
    node :
        The node path.
    vector :
    value :
        The new node vector value.
    """
    logger.debug(node)
@@ -109,6 +109,61 @@ def set_awg_value(
    awgs[awg_index]._awg._module.set(node, value)


def set_and_compile_awg_seqc(
    instrument: base.ZIBaseInstrument,
    awg_index: int,
    node: str,
    value: str,
):
    """
    Uploads and compiles the AWG sequencer program.

    Parameters
    ----------
    instrument :
        The instrument.
    awg_index :
        The awg to configure.
    node :
        The node path.
    value :
        The seqc program.
    """
    set_awg_value(instrument, awg_index, node, value)

    awgs = [instrument.awg] if not hasattr(instrument, "awgs") else instrument.awgs
    awg = awgs[awg_index]
    awg_module = awg._awg._module
    status: int = -1
    while status == -1:
        time.sleep(0.1)
        status = awg_module.get_int("compiler/status")

    if status == 1:
        status_str = awg_module.get_string("compiler/statusstring")
        raise Exception(f"Upload failed: \n{status_str}")

    if status == 2:
        status_str = awg_module.get_string("compiler/statusstring")
        raise Warning(f"Compiled with warning: \n{status_str}")

    if status == 0:
        print("Compilation successful")

    tik = time.get_time()
    progress: float = awg_module.get_double("progress")
    status: int = awg_module.get_int("/elf/status")
    while (progress < 1.0) and (status != 1):
        time.sleep(0.1)
        if time.get_time() - tik >= 100:  # 100s timeout
            raise Exception("Program upload timed out!")
        progress: float = awg_module.get_double("progress")
        status: int = awg_module.get_int("/elf/status")

    sequencer_status = "ELF file uploaded" if status == 0 else "FAILED!!"
    print(f"{awg.name}: Sequencer status: {sequencer_status}")


def set_wave_vector(
    instrument: base.ZIBaseInstrument,
    awg_index: int,
+7 −3
Original line number Diff line number Diff line
@@ -660,7 +660,7 @@ def add_wait(

def add_play_wave(
    seqc_gen: SeqcILGenerator,
    variable: str,
    *variable: str,
    device_type: zhinst.DeviceType,
    comment: str = "",
) -> int:
@@ -682,7 +682,7 @@ def add_play_wave(
    """
    n_assembly_instructions = SEQC_INSTR_CLOCKS[device_type][SeqcInstructions.PLAY_WAVE]
    seqc_gen.emit_play_wave(
        variable,
        *variable,
        comment=f"\t// {comment} n_instr={n_assembly_instructions}",
    )
    return n_assembly_instructions
@@ -816,6 +816,7 @@ def add_seqc_info(seqc_gen: SeqcILGenerator, seqc_info: SeqcInfo):
def add_csv_waveform_variables(
    seqc_gen: SeqcILGenerator,
    device_serial: str,
    awg_index: int,
    commandtable_map: Dict[int, int],
):
    """
@@ -826,9 +827,12 @@ def add_csv_waveform_variables(
    ----------
    seqc_gen :
    device_serial :
    awg_index :
    commandtable_map :
    """
    for waveform_index in commandtable_map.values():
        # Declare new placeholder and assign wave index
        name: str = f"w{waveform_index:d}"
        seqc_gen.declare_wave(name, f"{device_serial}_wave{waveform_index:d}")
        seqc_gen.declare_wave(
            name, f"{device_serial}_awg{awg_index}_wave{waveform_index:d}"
        )
Loading