Skip to content

Commit

Permalink
improve .ports method, remove name dependence in .ports
Browse files Browse the repository at this point in the history
  • Loading branch information
PiergiorgioButtarini committed Dec 7, 2023
1 parent 52d081e commit f3cc1d3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 47 deletions.
6 changes: 0 additions & 6 deletions src/qibolab/instruments/qblox/cluster_qcm_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json

from qblox_instruments.qcodes_drivers.qcm_qrm import QcmQrm as QbloxQrmQcm
from qibo.config import log

from qibolab.instruments.qblox.cluster import Cluster
from qibolab.instruments.qblox.module import ClusterModule
Expand Down Expand Up @@ -300,11 +299,6 @@ def setup(self, **settings):
using the numerically controlled oscillator within the fpga. It only requires the upload of the pulse envelope waveform.
At the moment this param is not loaded but is always set to True.
"""
# for port_num, port in enumerate(settings):
# self.ports[port] = QbloxOutputPort(
# self, self.DEFAULT_SEQUENCERS[port], port_number=port_num, port_name=port
# )
# self._sequencers[port] = []
self.settings = settings if settings else self.settings

def _get_next_sequencer(self, port, frequency, qubit: None):
Expand Down
13 changes: 0 additions & 13 deletions src/qibolab/instruments/qblox/cluster_qrm_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,6 @@ def setup(self, **settings):
the amount of memory available in the fpga to store i q samples.
"""
if "o1" in settings:
self.ports["o1"] = QbloxOutputPort(
module=self, sequencer_number=self.DEFAULT_SEQUENCERS["o1"], port_number=0, port_name="o1"
)
if "i1" in settings:
self.ports["i1"] = QbloxInputPort(
module=self,
output_sequencer_number=self.DEFAULT_SEQUENCERS["o1"],
input_sequencer_number=self.DEFAULT_SEQUENCERS["i1"],
port_number=0,
port_name="i1",
)

self.settings = settings if settings else self.settings

def _get_next_sequencer(self, port: str, frequency: int, qubits: dict, qubit: None):
Expand Down
37 changes: 18 additions & 19 deletions src/qibolab/instruments/qblox/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,30 @@ class ClusterModule(Instrument):
DEFAULT_SEQUENCERS = {}

def __init__(self, name: str, address: str):
""" """
"""
This class defines common features shared by all Qblox modules (QCM-BB, QCM-RF, QRM-RF).
It serves as a foundational class, unifying the behavior of the three distinct modules.
All module-specific classes are intended to inherit from this base class.
"""

super().__init__(name, address)
self.ports: dict = {}

def port(self, name: str, out: bool = True):
def count(cls):
return len(list(filter(lambda x: isinstance(x, cls), self.ports)))
return len(list(filter(lambda x: isinstance(x, cls), self.ports.values())))

if hasattr(self, "acquire"):
print(type(self))
if out:
self.ports[name] = QbloxOutputPort(
self, self.DEFAULT_SEQUENCERS["o1"], port_number=count(QbloxOutputPort), port_name=name
)
else:
self.ports[name] = QbloxInputPort(
self,
output_sequencer_number=self.DEFAULT_SEQUENCERS["o1"],
input_sequencer_number=self.DEFAULT_SEQUENCERS["i1"],
port_number=count(QbloxOutputPort),
port_name=name,
)
else:
print(type(self))
if out:
self.ports[name] = QbloxOutputPort(
self, self.DEFAULT_SEQUENCERS[name], port_number=len(self.ports), port_name=name
self,
self.DEFAULT_SEQUENCERS[f"o{count(QbloxOutputPort)+1}"],
port_number=count(QbloxOutputPort),
port_name=name,

This comment has been minimized.

Copy link
@PiergiorgioButtarini

PiergiorgioButtarini Dec 7, 2023

Author Contributor

@alecandido Here I removed the explicit dependence from the name of the ports used in the create methods. Unfortunately the price I think is the dependence on the order in which the ports are declared in the create, since the default sequencer is assigned thanks to the count() function.

)
else:
self.ports[name] = QbloxInputPort(
self,
port_number=0,
port_name=name,
)
return self.ports[name]
10 changes: 3 additions & 7 deletions src/qibolab/instruments/qblox/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,12 @@ def lo_frequency(self, value):


class QbloxInputPort:
def __init__(
self, module, output_sequencer_number: int, input_sequencer_number: int, port_number: int, port_name: str = None
):
def __init__(self, module, port_number: int, port_name: str = None):
self.name = port_name
self.module = module
self.output_sequencer_number: int = output_sequencer_number
self.input_sequencer_number: int = input_sequencer_number
self.output_sequencer_number: int = 0 # output_sequencer_number
self.input_sequencer_number: int = 0 # input_sequencer_number
self.port_number: int = port_number
self.channel = None # To be discontinued
self.qubit = None # To be discontinued

self.acquisition_hold_off = 4 # To be discontinued

Expand Down
4 changes: 2 additions & 2 deletions tests/dummy_qrc/qblox.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def create(runcard_path=RUNCARD):
channels |= Channel(name="L3-25_a", port=modules["qrm_rf_a"].port("o1"))
channels |= Channel(name="L3-25_b", port=modules["qrm_rf_b"].port("o1"))
# Feedback
channels |= Channel(name="L2-5_a", port=modules["qrm_rf_a"].port("i1"))
channels |= Channel(name="L2-5_b", port=modules["qrm_rf_b"].port("i1"))
channels |= Channel(name="L2-5_a", port=modules["qrm_rf_a"].port("i1", out=False))
channels |= Channel(name="L2-5_b", port=modules["qrm_rf_b"].port("i1", out=False))
# Drive
channels |= Channel(name="L3-15", port=modules["qcm_rf0"].port("o1"))
channels |= Channel(name="L3-11", port=modules["qcm_rf0"].port("o2"))
Expand Down

0 comments on commit f3cc1d3

Please sign in to comment.