forked from M-Labs/artiq
1
0
Fork 0

Shuttler: pdq, efc->shuttler pdq_words->coef_words

This commit is contained in:
linuswck 2023-09-26 15:09:29 +08:00 committed by Sébastien Bourdeauducq
parent 6eb81494c5
commit ab0d4c41c3
9 changed files with 87 additions and 86 deletions

View File

@ -142,7 +142,7 @@
"properties": { "properties": {
"type": { "type": {
"type": "string", "type": "string",
"enum": ["dio", "dio_spi", "urukul", "novogorny", "sampler", "suservo", "zotino", "grabber", "mirny", "fastino", "phaser", "hvamp", "efc"] "enum": ["dio", "dio_spi", "urukul", "novogorny", "sampler", "suservo", "zotino", "grabber", "mirny", "fastino", "phaser", "hvamp", "shuttler"]
}, },
"board": { "board": {
"type": "string" "type": "string"
@ -611,11 +611,11 @@
"required": ["ports"] "required": ["ports"]
} }
},{ },{
"title": "EFC", "title": "Shuttler",
"if": { "if": {
"properties": { "properties": {
"type": { "type": {
"const": "efc" "const": "shuttler"
} }
} }
}, },

View File

@ -164,7 +164,7 @@ class Volt:
:param a2: The :math:`a_2` coefficient in machine unit. :param a2: The :math:`a_2` coefficient in machine unit.
:param a3: The :math:`a_3` coefficient in machine unit. :param a3: The :math:`a_3` coefficient in machine unit.
""" """
pdq_words = [ coef_words = [
a0, a0,
a1, a1,
a1 >> 16, a1 >> 16,
@ -176,8 +176,8 @@ class Volt:
(a3 >> 32) & 0xFFFF, (a3 >> 32) & 0xFFFF,
] ]
for i in range(len(pdq_words)): for i in range(len(coef_words)):
rtio_output(self.target_o | i, pdq_words[i]) rtio_output(self.target_o | i, coef_words[i])
delay_mu(int64(self.core.ref_multiplier)) delay_mu(int64(self.core.ref_multiplier))
@ -254,7 +254,7 @@ class Dds:
:param c1: The :math:`c_1` coefficient in machine unit. :param c1: The :math:`c_1` coefficient in machine unit.
:param c2: The :math:`c_2` coefficient in machine unit. :param c2: The :math:`c_2` coefficient in machine unit.
""" """
pdq_words = [ coef_words = [
b0, b0,
b1, b1,
b1 >> 16, b1 >> 16,
@ -271,8 +271,8 @@ class Dds:
c2 >> 16, c2 >> 16,
] ]
for i in range(len(pdq_words)): for i in range(len(coef_words)):
rtio_output(self.target_o | i, pdq_words[i]) rtio_output(self.target_o | i, coef_words[i])
delay_mu(int64(self.core.ref_multiplier)) delay_mu(int64(self.core.ref_multiplier))

View File

@ -5,7 +5,7 @@
"base": "master", "base": "master",
"peripherals": [ "peripherals": [
{ {
"type": "efc", "type": "shuttler",
"ports": [0] "ports": [0]
}, },
{ {

View File

@ -5,59 +5,59 @@ DAC_Fs_MHZ = 125
CORDIC_GAIN = 1.64676 CORDIC_GAIN = 1.64676
@portable @portable
def pdq_phase_offset(offset_degree): def shuttler_phase_offset(offset_degree):
return round(offset_degree / 360 * (2 ** 16)) return round(offset_degree / 360 * (2 ** 16))
@portable @portable
def pdq_freq_mu(freq_mhz): def shuttler_freq_mu(freq_mhz):
return round(float(2) ** 32 / DAC_Fs_MHZ * freq_mhz) return round(float(2) ** 32 / DAC_Fs_MHZ * freq_mhz)
@portable @portable
def pdq_chirp_rate_mu(freq_mhz_per_us): def shuttler_chirp_rate_mu(freq_mhz_per_us):
return round(float(2) ** 32 * freq_mhz_per_us / (DAC_Fs_MHZ ** 2)) return round(float(2) ** 32 * freq_mhz_per_us / (DAC_Fs_MHZ ** 2))
@portable @portable
def pdq_freq_sweep(start_f_MHz, end_f_MHz, time_us): def shuttler_freq_sweep(start_f_MHz, end_f_MHz, time_us):
return pdq_chirp_rate_mu((end_f_MHz - start_f_MHz)/(time_us)) return shuttler_chirp_rate_mu((end_f_MHz - start_f_MHz)/(time_us))
@portable @portable
def pdq_volt_amp_mu(volt): def shuttler_volt_amp_mu(volt):
return shuttler_volt_to_mu(volt) return shuttler_volt_to_mu(volt)
@portable @portable
def pdq_volt_damp_mu(volt_per_us): def shuttler_volt_damp_mu(volt_per_us):
return round(float(2) ** 30 * (volt_per_us / 20) / DAC_Fs_MHZ) return round(float(2) ** 30 * (volt_per_us / 20) / DAC_Fs_MHZ)
@portable @portable
def pdq_volt_ddamp_mu(volt_per_us_square): def shuttler_volt_ddamp_mu(volt_per_us_square):
return round(float(2) ** 46 * (volt_per_us_square / 20) * 2 / (DAC_Fs_MHZ ** 2)) return round(float(2) ** 46 * (volt_per_us_square / 20) * 2 / (DAC_Fs_MHZ ** 2))
@portable @portable
def pdq_volt_dddamp_mu(volt_per_us_cube): def shuttler_volt_dddamp_mu(volt_per_us_cube):
return round(float(2) ** 46 * (volt_per_us_cube / 20) * 6 / (DAC_Fs_MHZ ** 3)) return round(float(2) ** 46 * (volt_per_us_cube / 20) * 6 / (DAC_Fs_MHZ ** 3))
@portable @portable
def pdq_dds_amp_mu(volt): def shuttler_dds_amp_mu(volt):
return pdq_volt_amp_mu(volt / CORDIC_GAIN) return shuttler_volt_amp_mu(volt / CORDIC_GAIN)
@portable @portable
def pdq_dds_damp_mu(volt_per_us): def shuttler_dds_damp_mu(volt_per_us):
return pdq_volt_damp_mu(volt_per_us / CORDIC_GAIN) return shuttler_volt_damp_mu(volt_per_us / CORDIC_GAIN)
@portable @portable
def pdq_dds_ddamp_mu(volt_per_us_square): def shuttler_dds_ddamp_mu(volt_per_us_square):
return pdq_volt_ddamp_mu(volt_per_us_square / CORDIC_GAIN) return shuttler_volt_ddamp_mu(volt_per_us_square / CORDIC_GAIN)
@portable @portable
def pdq_dds_dddamp_mu(volt_per_us_cube): def shuttler_dds_dddamp_mu(volt_per_us_cube):
return pdq_volt_dddamp_mu(volt_per_us_cube / CORDIC_GAIN) return shuttler_volt_dddamp_mu(volt_per_us_cube / CORDIC_GAIN)
class Shuttler(EnvExperiment): class Shuttler(EnvExperiment):
def build(self): def build(self):
self.setattr_device("core") self.setattr_device("core")
self.setattr_device("core_dma") self.setattr_device("core_dma")
self.setattr_device("scheduler") self.setattr_device("scheduler")
self.efc0_leds = [ self.get_device("efc0_led{}".format(i)) for i in range(2) ] self.shuttler0_leds = [ self.get_device("shuttler0_led{}".format(i)) for i in range(2) ]
self.setattr_device("shuttler0_config") self.setattr_device("shuttler0_config")
self.setattr_device("shuttler0_trigger") self.setattr_device("shuttler0_trigger")
self.shuttler0_volt = [ self.get_device("shuttler0_volt{}".format(i)) for i in range(16) ] self.shuttler0_volt = [ self.get_device("shuttler0_volt{}".format(i)) for i in range(16) ]
@ -76,7 +76,7 @@ class Shuttler(EnvExperiment):
self.led() self.led()
self.relay_init() self.relay_init()
self.adc_init() self.adc_init()
self.pdq_reset() self.shuttler_reset()
@kernel @kernel
def run(self): def run(self):
@ -94,14 +94,14 @@ class Shuttler(EnvExperiment):
self.core_dma.playback_handle(example_waveform_handle) self.core_dma.playback_handle(example_waveform_handle)
@kernel @kernel
def pdq_reset(self): def shuttler_reset(self):
for i in range(16): for i in range(16):
self.pdq_channel_reset(i) self.shuttler_channel_reset(i)
# To avoid RTIO Underflow # To avoid RTIO Underflow
delay(50*us) delay(50*us)
@kernel @kernel
def pdq_channel_reset(self, ch): def shuttler_channel_reset(self, ch):
self.shuttler0_volt[ch].set_waveform( self.shuttler0_volt[ch].set_waveform(
a0=0, a0=0,
a1=0, a1=0,
@ -166,21 +166,21 @@ class Shuttler(EnvExperiment):
duration_us = 500 duration_us = 500
# OUT0 and OUT1 have their frequency and phase aligned at 500us # OUT0 and OUT1 have their frequency and phase aligned at 500us
self.shuttler0_dds[0].set_waveform( self.shuttler0_dds[0].set_waveform(
b0=pdq_dds_amp_mu(1.0), b0=shuttler_dds_amp_mu(1.0),
b1=0, b1=0,
b2=0, b2=0,
b3=0, b3=0,
c0=0, c0=0,
c1=pdq_freq_mu(start_f_MHz), c1=shuttler_freq_mu(start_f_MHz),
c2=pdq_freq_sweep(start_f_MHz, end_f_MHz, duration_us), c2=shuttler_freq_sweep(start_f_MHz, end_f_MHz, duration_us),
) )
self.shuttler0_dds[1].set_waveform( self.shuttler0_dds[1].set_waveform(
b0=pdq_dds_amp_mu(1.0), b0=shuttler_dds_amp_mu(1.0),
b1=0, b1=0,
b2=0, b2=0,
b3=0, b3=0,
c0=0, c0=0,
c1=pdq_freq_mu(end_f_MHz), c1=shuttler_freq_mu(end_f_MHz),
c2=0, c2=0,
) )
self.shuttler0_trigger.trigger(0b11) self.shuttler0_trigger.trigger(0b11)
@ -189,12 +189,12 @@ class Shuttler(EnvExperiment):
## Step 3 ## ## Step 3 ##
# OUT0 and OUT1 has 180 degree phase difference # OUT0 and OUT1 has 180 degree phase difference
self.shuttler0_dds[0].set_waveform( self.shuttler0_dds[0].set_waveform(
b0=pdq_dds_amp_mu(1.0), b0=shuttler_dds_amp_mu(1.0),
b1=0, b1=0,
b2=0, b2=0,
b3=0, b3=0,
c0=pdq_phase_offset(180.0), c0=shuttler_phase_offset(180.0),
c1=pdq_freq_mu(end_f_MHz), c1=shuttler_freq_mu(end_f_MHz),
c2=0, c2=0,
) )
# Phase and Output Setting of OUT1 is retained # Phase and Output Setting of OUT1 is retained
@ -206,17 +206,17 @@ class Shuttler(EnvExperiment):
# b(0) = 0, b(250) = 8.545, b(500) = 0 # b(0) = 0, b(250) = 8.545, b(500) = 0
self.shuttler0_dds[0].set_waveform( self.shuttler0_dds[0].set_waveform(
b0=0, b0=0,
b1=pdq_dds_damp_mu(0.06835937), b1=shuttler_dds_damp_mu(0.06835937),
b2=pdq_dds_ddamp_mu(-0.0001367187), b2=shuttler_dds_ddamp_mu(-0.0001367187),
b3=0, b3=0,
c0=0, c0=0,
c1=pdq_freq_mu(end_f_MHz), c1=shuttler_freq_mu(end_f_MHz),
c2=0, c2=0,
) )
self.shuttler0_dds[1].set_waveform( self.shuttler0_dds[1].set_waveform(
b0=0, b0=0,
b1=pdq_dds_damp_mu(0.06835937), b1=shuttler_dds_damp_mu(0.06835937),
b2=pdq_dds_ddamp_mu(-0.0001367187), b2=shuttler_dds_ddamp_mu(-0.0001367187),
b3=0, b3=0,
c0=0, c0=0,
c1=0, c1=0,
@ -227,23 +227,23 @@ class Shuttler(EnvExperiment):
## Step 5 ## ## Step 5 ##
self.shuttler0_volt[0].set_waveform( self.shuttler0_volt[0].set_waveform(
a0=pdq_volt_amp_mu(-5.0), a0=shuttler_volt_amp_mu(-5.0),
a1=int32(pdq_volt_damp_mu(0.01)), a1=int32(shuttler_volt_damp_mu(0.01)),
a2=0, a2=0,
a3=0, a3=0,
) )
self.shuttler0_dds[0].set_waveform( self.shuttler0_dds[0].set_waveform(
b0=pdq_dds_amp_mu(1.0), b0=shuttler_dds_amp_mu(1.0),
b1=0, b1=0,
b2=0, b2=0,
b3=0, b3=0,
c0=0, c0=0,
c1=pdq_freq_mu(end_f_MHz), c1=shuttler_freq_mu(end_f_MHz),
c2=0, c2=0,
) )
self.shuttler0_volt[1].set_waveform( self.shuttler0_volt[1].set_waveform(
a0=pdq_volt_amp_mu(-5.0), a0=shuttler_volt_amp_mu(-5.0),
a1=int32(pdq_volt_damp_mu(0.01)), a1=int32(shuttler_volt_damp_mu(0.01)),
a2=0, a2=0,
a3=0, a3=0,
) )
@ -261,53 +261,53 @@ class Shuttler(EnvExperiment):
## Step 6 ## ## Step 6 ##
self.shuttler0_volt[0].set_waveform( self.shuttler0_volt[0].set_waveform(
a0=pdq_volt_amp_mu(-2.5), a0=shuttler_volt_amp_mu(-2.5),
a1=int32(pdq_volt_damp_mu(0.01)), a1=int32(shuttler_volt_damp_mu(0.01)),
a2=0, a2=0,
a3=0, a3=0,
) )
self.shuttler0_dds[0].set_waveform( self.shuttler0_dds[0].set_waveform(
b0=0, b0=0,
b1=pdq_dds_damp_mu(0.06835937), b1=shuttler_dds_damp_mu(0.06835937),
b2=pdq_dds_ddamp_mu(-0.0001367187), b2=shuttler_dds_ddamp_mu(-0.0001367187),
b3=0, b3=0,
c0=0, c0=0,
c1=pdq_freq_mu(start_f_MHz), c1=shuttler_freq_mu(start_f_MHz),
c2=pdq_freq_sweep(start_f_MHz, end_f_MHz, duration_us), c2=shuttler_freq_sweep(start_f_MHz, end_f_MHz, duration_us),
) )
self.shuttler0_trigger.trigger(0b1) self.shuttler0_trigger.trigger(0b1)
self.pdq_channel_reset(1) self.shuttler_channel_reset(1)
delay(500*us) delay(500*us)
## Step 7 ## ## Step 7 ##
self.shuttler0_volt[0].set_waveform( self.shuttler0_volt[0].set_waveform(
a0=pdq_volt_amp_mu(2.5), a0=shuttler_volt_amp_mu(2.5),
a1=int32(pdq_volt_damp_mu(-0.01)), a1=int32(shuttler_volt_damp_mu(-0.01)),
a2=0, a2=0,
a3=0, a3=0,
) )
self.shuttler0_dds[0].set_waveform( self.shuttler0_dds[0].set_waveform(
b0=0, b0=0,
b1=pdq_dds_damp_mu(-0.06835937), b1=shuttler_dds_damp_mu(-0.06835937),
b2=pdq_dds_ddamp_mu(0.0001367187), b2=shuttler_dds_ddamp_mu(0.0001367187),
b3=0, b3=0,
c0=pdq_phase_offset(180.0), c0=shuttler_phase_offset(180.0),
c1=pdq_freq_mu(end_f_MHz), c1=shuttler_freq_mu(end_f_MHz),
c2=pdq_freq_sweep(end_f_MHz, start_f_MHz, duration_us), c2=shuttler_freq_sweep(end_f_MHz, start_f_MHz, duration_us),
) )
self.shuttler0_trigger.trigger(0b1) self.shuttler0_trigger.trigger(0b1)
delay(500*us) delay(500*us)
## Step 8 ## ## Step 8 ##
self.shuttler0_relay.enable(0) self.shuttler0_relay.enable(0)
self.pdq_channel_reset(0) self.shuttler_channel_reset(0)
self.pdq_channel_reset(1) self.shuttler_channel_reset(1)
@kernel @kernel
def led(self): def led(self):
for i in range(2): for i in range(2):
for j in range(3): for j in range(3):
self.efc0_leds[i].pulse(.1*s) self.shuttler0_leds[i].pulse(.1*s)
delay(.1*s) delay(.1*s)
@kernel @kernel

View File

@ -621,12 +621,11 @@ class PeripheralManager:
channel=rtio_offset+i) channel=rtio_offset+i)
return 8 return 8
def process_efc(self, efc_peripheral): def process_shuttler(self, shuttler_peripheral):
efc_name = self.get_name("efc")
rtio_offset = efc_peripheral["drtio_destination"] << 16
rtio_offset += self.add_board_leds(rtio_offset, board_name=efc_name)
shuttler_name = self.get_name("shuttler") shuttler_name = self.get_name("shuttler")
rtio_offset = shuttler_peripheral["drtio_destination"] << 16
rtio_offset += self.add_board_leds(rtio_offset, board_name=shuttler_name)
channel = count(0) channel = count(0)
self.gen(""" self.gen("""
device_db["{name}_config"] = {{ device_db["{name}_config"] = {{
@ -718,8 +717,8 @@ class PeripheralManager:
def split_drtio_eem(peripherals): def split_drtio_eem(peripherals):
# EFC is the only peripheral that uses DRTIO-over-EEM at this moment # Shuttler is the only peripheral that uses DRTIO-over-EEM at this moment
drtio_eem_filter = lambda peripheral: peripheral["type"] == "efc" drtio_eem_filter = lambda peripheral: peripheral["type"] == "shuttler"
return filterfalse(drtio_eem_filter, peripherals), \ return filterfalse(drtio_eem_filter, peripherals), \
list(filter(drtio_eem_filter, peripherals)) list(filter(drtio_eem_filter, peripherals))

View File

@ -763,11 +763,11 @@ class HVAmp(_EEM):
target.rtio_channels.append(rtio.Channel.from_phy(phy)) target.rtio_channels.append(rtio.Channel.from_phy(phy))
class EFC(_EEM): class Shuttler(_EEM):
@staticmethod @staticmethod
def io(eem, iostandard=default_iostandard): def io(eem, iostandard=default_iostandard):
# Master: Pair 0~3 data IN, 4~7 OUT # Master: Pair 0~3 data IN, 4~7 OUT
data_in = ("efc{}_drtio_rx".format(eem), 0, data_in = ("shuttler{}_drtio_rx".format(eem), 0,
Subsignal("p", Pins("{} {} {} {}".format(*[ Subsignal("p", Pins("{} {} {} {}".format(*[
_eem_pin(eem, i, "p") for i in range(4) _eem_pin(eem, i, "p") for i in range(4)
]))), ]))),
@ -778,7 +778,7 @@ class EFC(_EEM):
Misc("DIFF_TERM=TRUE"), Misc("DIFF_TERM=TRUE"),
) )
data_out = ("efc{}_drtio_tx".format(eem), 0, data_out = ("shuttler{}_drtio_tx".format(eem), 0,
Subsignal("p", Pins("{} {} {} {}".format(*[ Subsignal("p", Pins("{} {} {} {}".format(*[
_eem_pin(eem, i, "p") for i in range(4, 8) _eem_pin(eem, i, "p") for i in range(4, 8)
]))), ]))),
@ -793,4 +793,4 @@ class EFC(_EEM):
@classmethod @classmethod
def add_std(cls, target, eem, eem_aux, iostandard=default_iostandard): def add_std(cls, target, eem, eem_aux, iostandard=default_iostandard):
cls.add_extension(target, eem, is_drtio_over_eem=True, iostandard=iostandard) cls.add_extension(target, eem, is_drtio_over_eem=True, iostandard=iostandard)
target.eem_drtio_channels.append((target.platform.request("efc{}_drtio_rx".format(eem), 0), target.platform.request("efc{}_drtio_tx".format(eem), 0))) target.eem_drtio_channels.append((target.platform.request("shuttler{}_drtio_rx".format(eem), 0), target.platform.request("shuttler{}_drtio_tx".format(eem), 0)))

View File

@ -133,7 +133,7 @@ def peripheral_hvamp(module, peripheral, **kwargs):
eem.HVAmp.add_std(module, peripheral["ports"][0], eem.HVAmp.add_std(module, peripheral["ports"][0],
ttl_simple.Output, **kwargs) ttl_simple.Output, **kwargs)
def peripheral_efc(module, peripheral, **kwargs): def peripheral_shuttler(module, peripheral, **kwargs):
if len(peripheral["ports"]) == 1: if len(peripheral["ports"]) == 1:
port = peripheral["ports"][0] port = peripheral["ports"][0]
port_aux = None port_aux = None
@ -141,7 +141,7 @@ def peripheral_efc(module, peripheral, **kwargs):
port, port_aux = peripheral["ports"] port, port_aux = peripheral["ports"]
else: else:
raise ValueError("wrong number of ports") raise ValueError("wrong number of ports")
eem.EFC.add_std(module, port, port_aux) eem.Shuttler.add_std(module, port, port_aux)
peripheral_processors = { peripheral_processors = {
"dio": peripheral_dio, "dio": peripheral_dio,
@ -156,7 +156,7 @@ peripheral_processors = {
"fastino": peripheral_fastino, "fastino": peripheral_fastino,
"phaser": peripheral_phaser, "phaser": peripheral_phaser,
"hvamp": peripheral_hvamp, "hvamp": peripheral_hvamp,
"efc": peripheral_efc, "shuttler": peripheral_shuttler,
} }

View File

@ -1,5 +1,7 @@
# Copyright 2013-2017 Robert Jordens <jordens@gmail.com> # Copyright 2013-2017 Robert Jordens <jordens@gmail.com>
# #
# shuttler is developed based on pdq.
#
# pdq is free software: you can redistribute it and/or modify # pdq is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or

View File

@ -70,7 +70,7 @@ class GenericMaster(MasterBase):
if hw_rev is None: if hw_rev is None:
hw_rev = description["hw_rev"] hw_rev = description["hw_rev"]
self.class_name_override = description["variant"] self.class_name_override = description["variant"]
has_drtio_over_eem = any(peripheral["type"] == "efc" for peripheral in description["peripherals"]) has_drtio_over_eem = any(peripheral["type"] == "shuttler" for peripheral in description["peripherals"])
MasterBase.__init__(self, MasterBase.__init__(self,
hw_rev=hw_rev, hw_rev=hw_rev,
rtio_clk_freq=description["rtio_frequency"], rtio_clk_freq=description["rtio_frequency"],
@ -174,9 +174,9 @@ def main():
else: else:
raise ValueError("Invalid DRTIO role") raise ValueError("Invalid DRTIO role")
has_efc = any(peripheral["type"] == "efc" for peripheral in description["peripherals"]) has_shuttler = any(peripheral["type"] == "shuttler" for peripheral in description["peripherals"])
if has_efc and (description["drtio_role"] == "standalone"): if has_shuttler and (description["drtio_role"] == "standalone"):
raise ValueError("EFC requires DRTIO, please switch role to master") raise ValueError("Shuttler requires DRTIO, please switch role to master")
soc = cls(description, gateware_identifier_str=args.gateware_identifier_str, **soc_kasli_argdict(args)) soc = cls(description, gateware_identifier_str=args.gateware_identifier_str, **soc_kasli_argdict(args))
args.variant = description["variant"] args.variant = description["variant"]