__version__ = "2026.5.6"
from inspect import isclass
import artiq
from artiq.compiler.builtins import TException
from artiq.coredevice import ad9910, urukul, suservo
from artiq.language.environment import EnvExperiment, Experiment
from .atomiq import AtomiqBlock, AtomiqExperiment
# Add our atomiq experiment/block class to the ignored classes to avoid clutter in, among other, the dashboard
def is_experiment(o):
"""Checks if a Python object is a top-level experiment class.
Monkey patch of the artiq_master function
'artiq.language.environment.is_experiment()' to include Atomiq
experiments and blocks in the ignore list
"""
experiment_bases = [Experiment, EnvExperiment, AtomiqExperiment, AtomiqBlock]
return isclass(o) and issubclass(o, Experiment) and (o not in experiment_bases) and not issubclass(o, AtomiqBlock)
artiq.language.environment.is_experiment = is_experiment
# Add NotImplementedError to the compiler capabilities as it is extensively used throughout atomiq.
try:
old_globals = artiq.compiler.prelude.globals
def new_globals():
from artiq.compiler.types import TExceptionConstructor
return old_globals() | {"NotImplementedError": TExceptionConstructor(TException("NotImplementedError"))}
artiq.compiler.prelude.globals = new_globals
except AttributeError:
# Under some circumstances (import test of nix) artiq does not get fully initialized and the import above fails
pass
# workaround for https://forum.m-labs.hk/d/273-using-su-servo-mode-and-freestanding-urukul-in-the-same-experiment/3
# this should not be necessary anymore once we run nac3
urukul.CPLD_Suservo = type("CPLD_Suservo", (urukul.CPLD,), {})
ad9910.AD9910_Suservo = type("AD9910_Suservo", (ad9910.AD9910,), {})
if hasattr(suservo, "SharedDDS"):
[docs]
class SharedDDS(suservo.SharedDDS):
def __init__(
self,
dmgr,
cpld_device,
pll_cp=7,
pll_vco=5,
sync_delay_seeds=[-1, -1, -1, -1],
io_update_delay=0,
pll_en=1,
core_device="core",
):
super().__init__(
dmgr,
cpld_device,
pll_cp=pll_cp,
pll_vco=pll_vco,
sync_delay_seeds=sync_delay_seeds,
io_update_delay=io_update_delay,
pll_en=pll_en,
core_device=core_device,
)
from artiq.coredevice import ad9910, suservo
self._inner_dds = ad9910.AD9910_Suservo(dmgr, 3, cpld_device, pll_cp=pll_cp, pll_vco=pll_vco, pll_en=pll_en)
self._inner_dds.io_update = suservo._MaskedIOUpdate(
self.core, self._inner_dds.cpld, self, self._inner_dds.io_update
)
suservo.SharedDDS = SharedDDS
# delete atomiq.artiq and atomiq.is_experiment namespace to rule out side effects
del artiq
del is_experiment
del urukul
del ad9910
del suservo