From c8ad5bca25740d6cb103802229584bde8e00b2e4 Mon Sep 17 00:00:00 2001 From: Serwan Asaad Date: Wed, 26 Jun 2024 16:07:46 +0200 Subject: [PATCH] generalized ports --- quam/components/channels.py | 13 +++++++------ quam/components/ports.py | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/quam/components/channels.py b/quam/components/channels.py index 1a54fbe2..76cb4df8 100644 --- a/quam/components/channels.py +++ b/quam/components/channels.py @@ -4,6 +4,7 @@ from quam.components.hardware import BaseFrequencyConverter, Mixer, LocalOscillator from quam.components.pulses import Pulse, BaseReadoutPulse +from quam.components.ports import LFAnalogOutputPort, LFAnalogInputPort from quam.core import QuamComponent, quam_dataclass from quam.core.quam_classes import QuamDict from quam.utils import string_reference as str_ref @@ -485,7 +486,7 @@ class SingleChannel(Channel): is None. """ - opx_output: Union[Tuple[str, int], Tuple[str, int, int]] + opx_output: Union[Tuple[str, int], Tuple[str, int, int], LFAnalogOutputPort] filter_fir_taps: List[float] = None filter_iir_taps: List[float] = None @@ -560,7 +561,7 @@ class InSingleChannel(Channel): Used to account for signal smearing. """ - opx_input: Union[Tuple[str, int], Tuple[str, int, int]] + opx_input: Union[Tuple[str, int], Tuple[str, int, int], LFAnalogInputPort] opx_input_offset: float = None time_of_flight: int = 24 @@ -831,8 +832,8 @@ class IQChannel(Channel): for the IQ output. """ - opx_output_I: Union[Tuple[str, int], Tuple[str, int, int]] - opx_output_Q: Union[Tuple[str, int], Tuple[str, int, int]] + opx_output_I: Union[Tuple[str, int], Tuple[str, int, int], LFAnalogOutputPort] + opx_output_Q: Union[Tuple[str, int], Tuple[str, int, int], LFAnalogOutputPort] opx_output_offset_I: float = None opx_output_offset_Q: float = None @@ -1026,8 +1027,8 @@ class InIQChannel(Channel): input_gain (float): The gain of the input channel. Default is None. """ - opx_input_I: Union[Tuple[str, int], Tuple[str, int, int]] - opx_input_Q: Union[Tuple[str, int], Tuple[str, int, int]] + opx_input_I: Union[Tuple[str, int], Tuple[str, int, int], LFAnalogInputPort] + opx_input_Q: Union[Tuple[str, int], Tuple[str, int, int], LFAnalogInputPort] time_of_flight: int = 24 smearing: int = 0 diff --git a/quam/components/ports.py b/quam/components/ports.py index 6b2bae37..8be1a84c 100644 --- a/quam/components/ports.py +++ b/quam/components/ports.py @@ -1,10 +1,24 @@ from dataclasses import field -from typing import Dict, List, Literal, Optional, Tuple +from typing import ClassVar, Dict, List, Literal, Optional, Tuple from quam.core import QuamComponent, quam_dataclass @quam_dataclass -class OPXPlusAnalogOutputPort(QuamComponent): +class Port(QuamComponent): + port_type: ClassVar[str] + + +@quam_dataclass +class LFAnalogOutputPort(QuamComponent): + port_type: ClassVar[str] = "analog_output" + + +class LFAnalogInputPort(QuamComponent): + port_type: ClassVar[str] = "analog_input" + + +@quam_dataclass +class OPXPlusAnalogOutputPort(LFAnalogOutputPort): port: Tuple[str, int] offset: float = 0.0 delay: int = 0 @@ -13,9 +27,20 @@ class OPXPlusAnalogOutputPort(QuamComponent): feedback_filter: List[float] = field(default_factory=list) shareable: bool = False + def get_port_config(self): + return { + "port": self.port, + "offset": self.offset, + "delay": self.delay, + "crosstalk": self.crosstalk, + "feedforward_filter": self.feedforward_filter, + "feedback_filter": self.feedback_filter, + "shareable": self.shareable, + } + @quam_dataclass -class OPXPlusAnalogInputPort(QuamComponent): +class OPXPlusAnalogInputPort(LFAnalogInputPort): port: Tuple[str, int] offset: float = 0.0 gain_db: int = 0 @@ -39,7 +64,7 @@ class OPXPlusDigitalInputPort(QuamComponent): @quam_dataclass -class LFFEMAnalogOutputPort(QuamComponent): +class LFFEMAnalogOutputPort(LFAnalogOutputPort): port: Tuple[str, int] offset: float = 0.0 delay: int = 0 @@ -53,7 +78,7 @@ class LFFEMAnalogOutputPort(QuamComponent): @quam_dataclass -class LFFEMAnalogInputPort(QuamComponent): +class LFFEMAnalogInputPort(LFAnalogInputPort): port: Tuple[str, int] offset: float = 0.0 gain_db: int = 0