Skip to content
This repository was archived by the owner on Jan 18, 2026. It is now read-only.

add suservo CPLD#2862

Open
DonovanWebb wants to merge 1 commit into
m-labs:masterfrom
DonovanWebb:protorev_polymorph_compat
Open

add suservo CPLD#2862
DonovanWebb wants to merge 1 commit into
m-labs:masterfrom
DonovanWebb:protorev_polymorph_compat

Conversation

@DonovanWebb

Copy link
Copy Markdown

With introduction of support for ProtoRev9 in coredevice.urukul, workaround for using both SUServo and normal Urukul devices in the same experiment no longer working due to polymorphism issues.
Introducing a suservo specific CPLD and providing class attributes for both ProtoRev8 and ProtoRev9 in coredevice.suservo allows for using both SUServo and normal Urukul devices again.

"""
Needed to avoid polymorphic issues when using SUServo and regular Urukuls in the same experiment.
"""
rb_len = 8

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems related to phase-coherent suservo support and probably shouldn't be in this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, this PR shouldn't exist at all. @DonovanWebb Can you just try on the nac3 branch? https://git.m-labs.hk/M-Labs/nac3/issues/664 appears to be fixed, which in theory was the last hurdle to get this to work properly. Though I have not tested it nor updated the Urukul driver yet.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nac3 isn't anything close to a drop-in replacement, and in any case this driver is for the legacy compiler only. This PR is just cleaning up after the recent ProtoRev9 changes, which were merged onto the non-nac3 branch, but broke a common use case (mixing SUServo and non-SUServo Urukuls; cf. various forum discussions).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnadlinger Your PR to fix the bug in the legacy compiler would be appreciated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And adding hacks/workarounds is never "cleaning up".

@dnadlinger dnadlinger Sep 28, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a bug per-se, it's a long-standing limitation. It would be possible to change to "monomorphising" types per instance with some sort of merging of identical shapes, but every Python class corresponding to an ARTIQ Python type is a pretty central part of the current design. The SUServo driver does not take into account this facet of the design (at least not while keeping compatibility with the non-SUServo Urukul driver in the same kernel). This is a real-world issue, as evidenced not just by the Oxford group's, but several other labs' reports here or on the forum, so it obviously needs to be fixed.

If you want to play games about the "proper fix", I'd argue that this points to reverting the ProtoRev9 refactor instead, as it broke an important use case. Of course, the sensible solution is just to tweak the refactored driver to once again allow running the two variants side-by-side.

Comment on lines +590 to +629
def __init__(
self,
dmgr,
spi_device,
io_update_device=None,
dds_reset_device=None,
sync_device=None,
sync_sel=0,
clk_sel=0,
clk_div=0,
rf_sw=0,
refclk=125e6,
att=0x00000000,
sync_div=None,
proto_rev=0x08,
core_device="core",
):
# Separate IO_UPDATE TTL output device used by SUServo core,
# if active, else by artiq.coredevice.suservo.AD9910
# :meth:`measure_io_update_alignment`.
# The urukul.CPLD driver utilises the CPLD CFG register
# option instead for pulsing IO_UPDATE of masked DDSs.
self.io_update_ttl = dmgr.get(io_update_device)
urukul.CPLD.__init__(
self,
dmgr,
spi_device,
io_update_device,
dds_reset_device,
sync_device,
sync_sel,
clk_sel,
clk_div,
rf_sw,
refclk,
att,
sync_div,
proto_rev,
core_device,
) No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part of this is actually necessary for this PR? It seems like this might again all be related to phase-coherent SUServo support, so it doesn't make sense to upstream at this point.

@dnadlinger

Copy link
Copy Markdown
Collaborator

For context, see #2112 and several similar issues/forum threrads. Our usual out-of-tree workaround doesn't easily translate, because the constructor now creates ProtoRev instances of a fixed type.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants