Skip to content

Commit 56074cf

Browse files
committed
suservo: support operating with one urukul
implemented by wiring up the second Urukul to dummy pins Signed-off-by: Robert Jördens <[email protected]>
1 parent 86e1924 commit 56074cf

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

artiq/gateware/eem.py

+28-33
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,15 @@ def add_std(cls, target, eem, eem_aux=None, eem_aux2=None, ttl_out_cls=None, ios
470470
class SUServo(_EEM):
471471
@staticmethod
472472
def io(*eems, iostandard="LVDS_25"):
473-
assert len(eems) == 6
474-
return (Sampler.io(*eems[0:2], iostandard=iostandard)
475-
+ Urukul.io_qspi(*eems[2:4], iostandard=iostandard)
476-
+ Urukul.io_qspi(*eems[4:6], iostandard=iostandard))
473+
assert len(eems) in (4, 6)
474+
io = (Sampler.io(*eems[0:2], iostandard=iostandard)
475+
+ Urukul.io_qspi(*eems[2:4], iostandard=iostandard))
476+
if len(eems) == 6: # two Urukuls
477+
io += Urukul.io_qspi(*eems[4:6], iostandard=iostandard),
478+
return io
477479

478480
@classmethod
479-
def add_std(cls, target, eems_sampler, eems_urukul0, eems_urukul1,
481+
def add_std(cls, target, eems_sampler, eems_urukul,
480482
t_rtt=4, clk=1, shift=11, profile=5,
481483
iostandard="LVDS_25"):
482484
"""Add a 8-channel Sampler-Urukul Servo
@@ -496,15 +498,14 @@ def add_std(cls, target, eems_sampler, eems_urukul0, eems_urukul1,
496498
(default: 5)
497499
"""
498500
cls.add_extension(
499-
target, *(eems_sampler + eems_urukul0 + eems_urukul1),
501+
target, *(eems_sampler + sum(eems_urukul, [])),
500502
iostandard=iostandard)
501503
eem_sampler = "sampler{}".format(eems_sampler[0])
502-
eem_urukul0 = "urukul{}".format(eems_urukul0[0])
503-
eem_urukul1 = "urukul{}".format(eems_urukul1[0])
504+
eem_urukul = ["urukul{}".format(i[0]) for i in eems_urukul]
504505

505506
sampler_pads = servo_pads.SamplerPads(target.platform, eem_sampler)
506507
urukul_pads = servo_pads.UrukulPads(
507-
target.platform, eem_urukul0, eem_urukul1)
508+
target.platform, *eem_urukul)
508509
target.submodules += sampler_pads, urukul_pads
509510
# timings in units of RTIO coarse period
510511
adc_p = servo.ADCParams(width=16, channels=8, lanes=4, t_cnvh=4,
@@ -536,30 +537,24 @@ def add_std(cls, target, eems_sampler, eems_urukul0, eems_urukul1,
536537
target.submodules += phy
537538
target.rtio_channels.append(rtio.Channel.from_phy(phy, ififo_depth=4))
538539

539-
phy = spi2.SPIMaster(
540-
target.platform.request("{}_spi_p".format(eem_urukul0)),
541-
target.platform.request("{}_spi_n".format(eem_urukul0)))
542-
target.submodules += phy
543-
target.rtio_channels.append(rtio.Channel.from_phy(phy, ififo_depth=4))
544-
545-
pads = target.platform.request("{}_dds_reset_sync_in".format(eem_urukul0))
546-
target.specials += DifferentialOutput(0, pads.p, pads.n)
547-
548-
for i, signal in enumerate("sw0 sw1 sw2 sw3".split()):
549-
pads = target.platform.request("{}_{}".format(eem_urukul0, signal))
550-
target.specials += DifferentialOutput(
551-
su.iir.ctrl[i].en_out, pads.p, pads.n)
540+
for i in range(2):
541+
if len(eem_urukul) > i:
542+
spi_p, spi_n = (
543+
target.platform.request("{}_spi_p".format(eem_urukul[i])),
544+
target.platform.request("{}_spi_n".format(eem_urukul[i])))
545+
else: # create a dummy bus
546+
spi_p = Record([("clk", 1), ("cs_n", 1)]) # mosi, cs_n
547+
spi_n = None
552548

553-
phy = spi2.SPIMaster(
554-
target.platform.request("{}_spi_p".format(eem_urukul1)),
555-
target.platform.request("{}_spi_n".format(eem_urukul1)))
556-
target.submodules += phy
557-
target.rtio_channels.append(rtio.Channel.from_phy(phy, ififo_depth=4))
549+
phy = spi2.SPIMaster(spi_p, spi_n)
550+
target.submodules += phy
551+
target.rtio_channels.append(rtio.Channel.from_phy(phy, ififo_depth=4))
558552

559-
pads = target.platform.request("{}_dds_reset_sync_in".format(eem_urukul1))
560-
target.specials += DifferentialOutput(0, pads.p, pads.n)
553+
for j, eem_urukuli in enumerate(eem_urukul):
554+
pads = target.platform.request("{}_dds_reset_sync_in".format(eem_urukuli))
555+
target.specials += DifferentialOutput(0, pads.p, pads.n)
561556

562-
for i, signal in enumerate("sw0 sw1 sw2 sw3".split()):
563-
pads = target.platform.request("{}_{}".format(eem_urukul1, signal))
564-
target.specials += DifferentialOutput(
565-
su.iir.ctrl[i + 4].en_out, pads.p, pads.n)
557+
for i, signal in enumerate("sw0 sw1 sw2 sw3".split()):
558+
pads = target.platform.request("{}_{}".format(eem_urukuli, signal))
559+
target.specials += DifferentialOutput(
560+
su.iir.ctrl[j*4 + i].en_out, pads.p, pads.n)

artiq/gateware/suservo/pads.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,26 @@ def __init__(self, platform, eem):
5858

5959

6060
class UrukulPads(Module):
61-
def __init__(self, platform, eem0, eem1):
61+
def __init__(self, platform, *eems):
6262
spip, spin = [[
6363
platform.request("{}_qspi_{}".format(eem, pol), 0)
64-
for eem in (eem0, eem1)] for pol in "pn"]
64+
for eem in eems] for pol in "pn"]
6565
ioup = [platform.request("{}_io_update".format(eem), 0)
66-
for eem in (eem0, eem1)]
66+
for eem in eems]
6767
self.cs_n = Signal()
6868
self.clk = Signal()
6969
self.io_update = Signal()
7070
self.specials += [(
7171
DifferentialOutput(~self.cs_n, spip[i].cs, spin[i].cs),
7272
DifferentialOutput(self.clk, spip[i].clk, spin[i].clk),
7373
DifferentialOutput(self.io_update, ioup[i].p, ioup[i].n))
74-
for i in range(2)]
74+
for i in range(len(eems))]
7575
for i in range(8):
7676
mosi = Signal()
7777
setattr(self, "mosi{}".format(i), mosi)
78+
for i in range(4*len(eems)):
7879
self.specials += [
79-
DifferentialOutput(mosi,
80+
DifferentialOutput(getattr(self, "mosi{}".format(i)),
8081
getattr(spip[i // 4], "mosi{}".format(i % 4)),
8182
getattr(spin[i // 4], "mosi{}".format(i % 4)))
8283
]

artiq/gateware/targets/kasli_generic.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ def peripheral_sampler(module, peripheral):
6464
def peripheral_suservo(module, peripheral):
6565
if len(peripheral["sampler_ports"]) != 2:
6666
raise ValueError("wrong number of Sampler ports")
67+
urukul_ports = []
6768
if len(peripheral["urukul0_ports"]) != 2:
6869
raise ValueError("wrong number of Urukul #0 ports")
69-
if len(peripheral["urukul1_ports"]) != 2:
70-
raise ValueError("wrong number of Urukul #1 ports")
70+
urukul_ports.append(peripheral["urukul0_ports"])
71+
if "urukul1_ports" in peripheral:
72+
if len(peripheral["urukul1_ports"]) != 2:
73+
raise ValueError("wrong number of Urukul #1 ports")
74+
urukul_ports.append(peripheral["urukul1_ports"])
7175
eem.SUServo.add_std(module,
7276
peripheral["sampler_ports"],
73-
peripheral["urukul0_ports"], peripheral["urukul1_ports"])
77+
urukul_ports)
7478

7579

7680
def peripheral_zotino(module, peripheral):

0 commit comments

Comments
 (0)