diff --git a/src/qibosoq/TIDAC80508.py b/src/qibosoq/TIDAC80508.py deleted file mode 100644 index 4411a45..0000000 --- a/src/qibosoq/TIDAC80508.py +++ /dev/null @@ -1,36 +0,0 @@ -import spidev - -class TIDAC80508: - def __init__(self): - self.spi = spidev.SpiDev() - self.spi.open(1, 0) - to_send = [0x04, 0x00, 0x0f] # All gains set x2 - self.spi.xfer(to_send) - to_send = [0x08, 0x80, 0x2b] # Initialize DAC0 - self.spi.xfer(to_send) - to_send = [0x09, 0x80, 0x44] # Initialize DAC1 - self.spi.xfer(to_send) - to_send = [0x0a, 0x80, 0x41] # Initialize DAC2 - self.spi.xfer(to_send) - to_send = [0x0b, 0x7f, 0xc9] # Initialize DAC3 - self.spi.xfer(to_send) - - def set_bias(self, dac, bias_value: float): - if abs(bias_value) > 1.: - raise ValueError("Bias values should be between -1 and 1") - if dac==0: - register_value = int(bias_value * (0xffff - 0x802b) / 2.4934) + 0x802b - dest = 0x08 - elif dac==1: - register_value = int(bias_value * (0xffff - 0x8044) / 2.4854) + 0x8044 - dest = 0x09 - elif dac==2: - register_value = int(bias_value * (0xffff - 0x8041) / 2.4857) + 0x8041 - dest = 0x0a - elif dac==3: - register_value = int(bias_value * (0xffff - 0x7fc9) / 2.5002) + 0x7fc9 - dest = 0x0b - high_byte = (register_value & 0xff00) >> 8 - low_byte = (register_value & 0x00ff) - to_send = [dest, high_byte, low_byte] - self.spi.xfer(to_send) diff --git a/src/qibosoq/drivers/AD_HMC7044.py b/src/qibosoq/drivers/AD_HMC7044.py new file mode 100755 index 0000000..0b4c9c2 --- /dev/null +++ b/src/qibosoq/drivers/AD_HMC7044.py @@ -0,0 +1,11 @@ +import spidev + +class HMC7044: + def __init__(self): + # self.spi = spidev.SpiDev() + # self.spi.open(2, 0) + # self.spi.mode = 0 + # self.spi.max_speed_hz = 500000 + # to_send = [0x04, 0x00, 0xff] # All gains set x2 + # self.spi.xfer(to_send) + pass \ No newline at end of file diff --git a/src/qibosoq/drivers/LMK04828_245.25.txt b/src/qibosoq/drivers/LMK04828_245.25.txt new file mode 100755 index 0000000..1347503 --- /dev/null +++ b/src/qibosoq/drivers/LMK04828_245.25.txt @@ -0,0 +1,136 @@ +R0 (INIT) 0x000090 +R0 0x000000 +R2 0x000200 +R3 0x000306 +R4 0x0004D0 +R5 0x00055B +R6 0x000600 +R12 0x000C51 +R13 0x000D04 +R256 0x010014 +R257 0x010155 +R258 0x010255 +R259 0x010301 +R260 0x010420 +R261 0x010500 +R262 0x01067A +R263 0x010766 +R264 0x010801 +R265 0x010955 +R266 0x010A55 +R267 0x010B01 +R268 0x010C20 +R269 0x010D00 +R270 0x010E70 +R271 0x010F66 +R272 0x01100B +R273 0x011155 +R274 0x011255 +R275 0x011302 +R276 0x011420 +R277 0x011500 +R278 0x0116F8 +R279 0x011711 +R280 0x01180B +R281 0x011955 +R282 0x011A55 +R283 0x011B02 +R284 0x011C20 +R285 0x011D00 +R286 0x011EF0 +R287 0x011F66 +R288 0x01200B +R289 0x012155 +R290 0x012255 +R291 0x012302 +R292 0x012420 +R293 0x012500 +R294 0x0126F0 +R295 0x012766 +R296 0x01280B +R297 0x012955 +R298 0x012A55 +R299 0x012B02 +R300 0x012C20 +R301 0x012D00 +R302 0x012EF0 +R303 0x012F66 +R304 0x013001 +R305 0x013155 +R306 0x013255 +R307 0x013301 +R308 0x013420 +R309 0x013500 +R310 0x013670 +R311 0x013766 +R312 0x013850 +R313 0x013900 +R314 0x013A00 +R315 0x013B20 +R316 0x013C00 +R317 0x013D08 +R318 0x013E03 +R319 0x013F04 +R320 0x0140F8 +R321 0x014100 +R322 0x014208 +R323 0x014350 +R324 0x014400 +R325 0x014500 +R326 0x01461B +R327 0x014700 +R328 0x014802 +R329 0x014902 +R330 0x014A06 +R331 0x014B02 +R332 0x014C00 +R333 0x014D00 +R334 0x014E00 +R335 0x014F7F +R336 0x015001 +R337 0x015102 +R338 0x015200 +R339 0x015300 +R340 0x015478 +R341 0x015500 +R342 0x015678 +R343 0x015700 +R344 0x015878 +R345 0x015909 +R346 0x015AC4 +R347 0x015BF4 +R348 0x015C20 +R349 0x015D00 +R350 0x015E00 +R351 0x015F0B +R352 0x016000 +R353 0x016101 +R354 0x016244 +R355 0x016300 +R356 0x016400 +R357 0x01652C +R369 0x0171AA +R370 0x017202 +R380 0x017C15 +R381 0x017D33 +R358 0x016600 +R359 0x016700 +R360 0x01680C +R361 0x016958 +R362 0x016A20 +R363 0x016B00 +R364 0x016C00 +R365 0x016D00 +R366 0x016E13 +R371 0x017320 +R386 0x018200 +R387 0x018300 +R388 0x018400 +R389 0x018500 +R392 0x018800 +R393 0x018900 +R394 0x018A00 +R395 0x018B00 +R8189 0x1FFD00 +R8190 0x1FFE00 +R8191 0x1FFF53 diff --git a/src/qibosoq/drivers/LMK04828_245.76.txt b/src/qibosoq/drivers/LMK04828_245.76.txt new file mode 100755 index 0000000..16f245a --- /dev/null +++ b/src/qibosoq/drivers/LMK04828_245.76.txt @@ -0,0 +1,128 @@ +R0 (INIT) 0x000090 +R0 0x000010 +R2 0x000200 +R3 0x000306 +R4 0x0004D0 +R5 0x00055B +R6 0x000600 +R12 0x000C51 +R13 0x000D04 +R256 0x01006A +R257 0x010155 +R258 0x010255 +R259 0x010301 +R260 0x010422 +R261 0x010500 +R262 0x010673 +R263 0x010703 +R264 0x01086A +R265 0x010955 +R266 0x010A55 +R267 0x010B00 +R268 0x010C22 +R269 0x010D00 +R270 0x010EF0 +R271 0x010F30 +R272 0x01106A +R273 0x011155 +R274 0x011255 +R275 0x011301 +R276 0x011422 +R277 0x011500 +R278 0x011673 +R279 0x011703 +R280 0x01186A +R281 0x011955 +R282 0x011A55 +R283 0x011B01 +R284 0x011C22 +R285 0x011D00 +R286 0x011E72 +R287 0x011F03 +R288 0x012074 +R289 0x012155 +R290 0x012255 +R291 0x012301 +R292 0x012422 +R293 0x012500 +R294 0x012670 +R295 0x012733 +R296 0x01286A +R297 0x012955 +R298 0x012A55 +R299 0x012B00 +R300 0x012C22 +R301 0x012D00 +R302 0x012EF0 +R303 0x012F30 +R304 0x01306A +R305 0x013155 +R306 0x013255 +R307 0x013301 +R308 0x013422 +R309 0x013500 +R310 0x013673 +R311 0x013703 +R312 0x013800 +R313 0x013903 +R314 0x013A01 +R315 0x013B40 +R316 0x013C00 +R317 0x013D01 +R318 0x013E03 +R319 0x013F02 +R320 0x014009 +R321 0x014100 +R322 0x014200 +R323 0x014331 +R324 0x0144FF +R325 0x01457F +R326 0x014618 +R327 0x01471A +R328 0x014806 +R329 0x014946 +R330 0x014A06 +R331 0x014B06 +R332 0x014C00 +R333 0x014D00 +R334 0x014EC0 +R335 0x014F7F +R336 0x015013 +R337 0x015102 +R338 0x015200 +R339 0x015300 +R340 0x01547D +R341 0x015500 +R342 0x01567D +R343 0x015703 +R344 0x0158C0 +R345 0x015907 +R346 0x015AD0 +R347 0x015BDA +R348 0x015C20 +R349 0x015D00 +R350 0x015E00 +R351 0x015F3E +R352 0x016000 +R353 0x016119 +R354 0x016244 +R355 0x016300 +R356 0x016400 +R357 0x0165A0 +R369 0x0171AA +R370 0x017202 +R380 0x017C15 +R381 0x017D33 +R358 0x016600 +R359 0x016700 +R360 0x0168C0 +R361 0x016959 +R362 0x016A20 +R363 0x016B00 +R364 0x016C00 +R365 0x016D00 +R366 0x016E1B +R371 0x017300 +R8189 0x1FFD00 +R8190 0x1FFE00 +R8191 0x1FFF53 diff --git a/src/qibosoq/drivers/TI_DAC80508.py b/src/qibosoq/drivers/TI_DAC80508.py new file mode 100755 index 0000000..ea9687e --- /dev/null +++ b/src/qibosoq/drivers/TI_DAC80508.py @@ -0,0 +1,32 @@ +import spidev + + +DACS = [0, 1, 2, 3, 4, 5, 6, 7] +MAX_VOLTAGE = 1.5 # V + +class DAC80508: + def __init__(self): + self.spi = spidev.SpiDev() + self.spi.open(1, 0) + self.spi.mode = 0 + self.spi.max_speed_hz = 500000 + + to_send = [0x04, 0x00, 0xff] # All gains set x2 + self.spi.xfer(to_send) + + # Set all dacs to 0V + for dac in DACS: + to_send = [0x08+dac, 0x80, 0x00] + self.spi.xfer(to_send) + + def set_bias(self, dac:int, bias: float): + if not dac in DACS: + raise ValueError(f"dac should be any of {DACS}") + if abs(bias) > MAX_VOLTAGE: + raise ValueError(f"Bias values should be between -{MAX_VOLTAGE} and {MAX_VOLTAGE} V") + + register_value = int(bias * (0xffff - 0x8000) / 2.5000) + 0x8000 + high_byte = (register_value & 0xff00) >> 8 + low_byte = (register_value & 0x00ff) + to_send = [0x08+dac, high_byte, low_byte] + self.spi.xfer(to_send) \ No newline at end of file diff --git a/src/qibosoq/drivers/hello_GPIO.elf b/src/qibosoq/drivers/hello_GPIO.elf new file mode 100755 index 0000000..0da5717 Binary files /dev/null and b/src/qibosoq/drivers/hello_GPIO.elf differ diff --git a/src/qibosoq/programs/flux.py b/src/qibosoq/programs/flux.py index 9e30e36..fba024f 100644 --- a/src/qibosoq/programs/flux.py +++ b/src/qibosoq/programs/flux.py @@ -17,7 +17,7 @@ Rectangular, ) from qibosoq.programs.base import BaseProgram -from ..TIDAC80508 import TIDAC80508 +from ..drivers.TI_DAC80508 import DAC80508 logger = logging.getLogger(qibosoq_cfg.MAIN_LOGGER_NAME) @@ -26,11 +26,11 @@ class FluxProgram(BaseProgram): """Abstract class for flux-tunable qubits programs.""" def __init__( - self, soc: QickSoc, tidac: TIDAC80508, qpcfg: Config, sequence: List[Element], qubits: List[Qubit] + self, soc: QickSoc, ti_dac: DAC80508, qpcfg: Config, sequence: List[Element], qubits: List[Qubit] ): """Define an empty dictionary for bias sweepers and call super().__init__.""" self.bias_sweep_registers: Dict[int, Tuple[QickRegister, QickRegister]] = {} - self.tidac = tidac + self.ti_dac = ti_dac super().__init__(soc, qpcfg, sequence, qubits) def set_bias(self, mode: str = "sweetspot"): @@ -41,12 +41,12 @@ def set_bias(self, mode: str = "sweetspot"): mode (str): can be 'sweetspot' or 'zero' """ - # if mode == "sweetspot": - # for qubit in self.qubits: - # self.tidac.set_bias(qubit.dac, bias_value=qubit.bias) - # elif mode == "zero": - # for qubit in self.qubits: - # self.tidac.set_bias(qubit.dac, bias_value=0) + if mode == "sweetspot": + for qubit in self.qubits: + self.ti_dac.set_bias(qubit.dac, bias=qubit.bias) + elif mode == "zero": + for qubit in self.qubits: + self.ti_dac.set_bias(qubit.dac, bias=0) # duration = 48 # minimum len # for qubit in self.qubits: @@ -97,11 +97,11 @@ def find_qubit_sweetspot(self, pulse: Pulse) -> float: return 0.0 def execute_flux_pulse(self, pulse: Pulse): - """Fire a fast flux pulse the starts and ends in sweetspot.""" + """Fire a fast flux pulse.""" gen_ch = pulse.dac max_gain = int(self.soccfg["gens"][gen_ch]["maxv"]) - bias = self.find_qubit_sweetspot(pulse) - sweetspot = np.trunc(bias * max_gain).astype(int) + # bias = self.find_qubit_sweetspot(pulse) + # sweetspot = np.trunc(bias * max_gain).astype(int) duration = self.soc.us2cycles(pulse.duration, gen_ch=gen_ch) samples_per_clk = self._gen_mgrs[gen_ch].samps_per_clk @@ -120,8 +120,8 @@ def execute_flux_pulse(self, pulse: Pulse): "Only Rectangular, FluxExponential and Arbitrary are supported for flux pulses" ) - # add a clock cycle of sweetspot values - i_vals = np.append(i_vals + sweetspot, np.full(samples_per_clk, sweetspot)) + # # add a clock cycle of sweetspot values + # i_vals = np.append(i_vals + sweetspot, np.full(samples_per_clk, sweetspot)) q_vals = np.zeros(len(i_vals)) if (abs(i_vals) > max_gain).any(): @@ -133,7 +133,7 @@ def execute_flux_pulse(self, pulse: Pulse): waveform=pulse.name, style="arb", outsel="input", - stdysel="last", + stdysel="zero", freq=0, phase=0, gain=max_gain, diff --git a/src/qibosoq/programs/pulse_sequence.py b/src/qibosoq/programs/pulse_sequence.py index 3d681b6..bac1fe6 100644 --- a/src/qibosoq/programs/pulse_sequence.py +++ b/src/qibosoq/programs/pulse_sequence.py @@ -9,7 +9,7 @@ from qibosoq.components.base import Config, Qubit from qibosoq.components.pulses import Element from qibosoq.programs.flux import FluxProgram -from ..TIDAC80508 import TIDAC80508 +from ..drivers.TI_DAC80508 import DAC80508 logger = logging.getLogger(qibosoq_cfg.MAIN_LOGGER_NAME) @@ -19,7 +19,7 @@ class ExecutePulseSequence(FluxProgram, AveragerProgram): def __init__( self, soc: QickSoc, - tidac: TIDAC80508, + tidac: DAC80508, qpcfg: Config, sequence: List[Element], qubits: List[Qubit], diff --git a/src/qibosoq/programs/sweepers.py b/src/qibosoq/programs/sweepers.py index 72982c2..dfef22b 100644 --- a/src/qibosoq/programs/sweepers.py +++ b/src/qibosoq/programs/sweepers.py @@ -10,7 +10,7 @@ from qibosoq.components.base import Config, Parameter, Qubit, Sweeper from qibosoq.components.pulses import Element from qibosoq.programs.flux import FluxProgram -from ..TIDAC80508 import TIDAC80508 +from ..drivers.TI_DAC80508 import DAC80508 logger = logging.getLogger(qibosoq_cfg.MAIN_LOGGER_NAME) @@ -30,7 +30,7 @@ class ExecuteSweeps(FluxProgram, NDAveragerProgram): def __init__( self, soc: QickSoc, - tidac: TIDAC80508, + tidac: DAC80508, qpcfg: Config, sequence: List[Element], qubits: List[Qubit], diff --git a/src/qibosoq/server.py b/src/qibosoq/server.py index 6cc6dfd..613bd13 100644 --- a/src/qibosoq/server.py +++ b/src/qibosoq/server.py @@ -22,7 +22,8 @@ # import sys # sys.path.append('/home/xilinx/jupyter_notebooks/qick/qick_demos/custom/drivers') -from .TIDAC80508 import TIDAC80508 +from .drivers.TI_DAC80508 import DAC80508 +from .drivers.AD_HMC7044 import HMC7044 def load_elements(list_sequence: List[Dict]) -> List[Element]: @@ -53,7 +54,7 @@ def load_sweeps(list_sweepers: List[Dict]) -> List[Sweeper]: return sweepers -def execute_program(data: dict, qick_soc: QickSoc, tidac: TIDAC80508) -> dict: +def execute_program(data: dict, qick_soc: QickSoc, ti_dac: DAC80508) -> dict: """Create and execute qick programs. Returns: @@ -77,15 +78,15 @@ def execute_program(data: dict, qick_soc: QickSoc, tidac: TIDAC80508) -> dict: program = programcls( qick_soc, - tidac, + ti_dac, Config(**data["cfg"]), load_elements(data["sequence"]), [Qubit(**qubit) for qubit in data["qubits"]], *args, ) - # program.set_bias("sweetspot") - for qubit in program.qubits: - tidac.set_bias(qubit.dac, bias_value=qubit.bias) + program.set_bias("sweetspot") + # for qubit in program.qubits: + # ti_dac.set_bias(qubit.dac, bias_value=qubit.bias) asm_prog = program.asm() qick_logger.handlers[0].doRollover() # type: ignore @@ -112,9 +113,9 @@ def execute_program(data: dict, qick_soc: QickSoc, tidac: TIDAC80508) -> dict: qick_soc, average=data["cfg"]["average"], ) - # program.set_bias("zero") - for qubit in program.qubits: - tidac.set_bias(qubit.dac, bias_value=0) + program.set_bias("zero") + # for qubit in program.qubits: + # ti_dac.set_bias(qubit.dac, bias_value=0) # return {"i": (np.array(toti)+0.5).tolist(), "q": (np.array(totq)+0.5).tolist()} # ZCU111? return {"i": toti, "q": totq} @@ -148,8 +149,7 @@ def handle(self): try: data = self.receive_command() - - results = execute_program(data, self.server.qick_soc, self.server.tidac) + results = execute_program(data, self.server.qick_soc, self.server.ti_dac) except Exception: # pylint: disable=W0612,W0718 logger.exception("") @@ -172,7 +172,28 @@ def serve(host, port): # initialize QickSoc object (firmware and clocks) TCPServer.allow_reuse_address = True with TCPServer((host, port), ConnectionHandler) as server: - server.qick_soc = QickSoc(bitfile=cfg.QICKSOC_LOCATION) - server.tidac = TIDAC80508() + server.ad_clock = HMC7044() + server.ti_dac = DAC80508() + qick_soc = QickSoc(bitfile=cfg.QICKSOC_LOCATION) + + ### SET POWER FOR DACs ### + + dac_2280 = qick_soc.usp_rf_data_converter_0.dac_tiles[0].blocks[0] + dac_2290 = qick_soc.usp_rf_data_converter_0.dac_tiles[1].blocks[0] + dac_2300 = qick_soc.usp_rf_data_converter_0.dac_tiles[2].blocks[0] + dac_2280.SetDACVOP(20000) # POWER FOR RF FLUX DAC (muA) + dac_2290.SetDACVOP(40000) # POWER FOR DRIVE DAC (muA) + dac_2300.SetDACVOP(30000) # HIGH POWER FOR READOUT DAC (muA) + + ### ENABLE MULTI TILE SYNCHRONIZATION ### + + qick_soc.usp_rf_data_converter_0.mts_dac_config.RefTile = 2 + qick_soc.usp_rf_data_converter_0.mts_dac_config.Tiles = 0b0011 + qick_soc.usp_rf_data_converter_0.mts_dac_config.SysRef_Enable = 1 + qick_soc.usp_rf_data_converter_0.mts_dac_config.Target_Latency = -1 + qick_soc.usp_rf_data_converter_0.mts_dac() + + server.qick_soc = qick_soc + log_initial_info() server.serve_forever()