From cd60803f21c5b004c373a10ce174353bef032bcd Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 22 Feb 2019 20:07:15 +0800 Subject: [PATCH] device_ddb_template: add Sampler, Zotino, Grabber and SFP LED support --- artiq/frontend/artiq_ddb_template.py | 97 +++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/artiq/frontend/artiq_ddb_template.py b/artiq/frontend/artiq_ddb_template.py index afe5e2924..f1c9c3af1 100755 --- a/artiq/frontend/artiq_ddb_template.py +++ b/artiq/frontend/artiq_ddb_template.py @@ -197,18 +197,106 @@ class PeripheralManager: return next(channel) def process_sampler(self, rtio_offset, peripheral): - return 0 + self.gen(""" + device_db["spi_{name}_adc"] = {{ + "type": "local", + "module": "artiq.coredevice.spi2", + "class": "SPIMaster", + "arguments": {{"channel": 0x{adc_channel:06x}}} + }} + device_db["spi_{name}_pgia"] = {{ + "type": "local", + "module": "artiq.coredevice.spi2", + "class": "SPIMaster", + "arguments": {{"channel": 0x{pgia_channel:06x}}} + }} + device_db["spi_{name}_cnv"] = {{ + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {{"channel": 0x{cnv_channel:06x}}}, + }} + device_db["{name}"] = {{ + "type": "local", + "module": "artiq.coredevice.sampler", + "class": "Sampler", + "arguments": {{ + "spi_adc_device": "spi_{name}_adc", + "spi_pgia_device": "spi_{name}_pgia", + "cnv_device": "spi_{name}_cnv" + }} + }}""", + name=self.get_name("sampler"), + adc_channel=rtio_offset, + pgia_channel=rtio_offset + 1, + cnv_channel=rtio_offset + 2) + return 3 def process_zotino(self, rtio_offset, peripheral): - return 0 + self.gen(""" + device_db["spi_{name}"] = {{ + "type": "local", + "module": "artiq.coredevice.spi2", + "class": "SPIMaster", + "arguments": {{"channel": 0x{spi_channel:06x}}} + }} + device_db["ttl_{name}_ldac"] = {{ + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {{"channel": 0x{ldac_channel:06x}}} + }} + device_db["ttl_{name}_clr"] = {{ + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {{"channel": 0x{clr_channel:06x}}} + }} + device_db["{name}"] = {{ + "type": "local", + "module": "artiq.coredevice.zotino", + "class": "Zotino", + "arguments": {{ + "spi_device": "spi_{name}", + "ldac_device": "ttl_{name}_ldac", + "clr_device": "ttl_{name}_clr" + }} + }}""", + name=self.get_name("zotino"), + spi_channel=rtio_offset, + ldac_channel=rtio_offset + 1, + clr_channel=rtio_offset + 2) + return 3 def process_grabber(self, rtio_offset, peripheral): - return 0 + self.gen(""" + device_db["{name}"] = {{ + "type": "local", + "module": "artiq.coredevice.grabber", + "class": "Grabber", + "arguments": {{"channel_base": 0x{channel:06x}}} + }}""", + name=self.get_name("grabber"), + channel=rtio_offset) + return 2 def process(self, rtio_offset, peripheral): processor = getattr(self, "process_"+str(peripheral["type"])) return processor(rtio_offset, peripheral) + def add_sfp_leds(self, rtio_offset): + for i in range(2): + self.gen(""" + device_db["{name}"] = {{ + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {{"channel": 0x{channel:06x}}} + }}""", + name=self.get_name("led"), + channel=rtio_offset+i) + return 2 + def process(output, master_description, satellites): base = master_description["base"] @@ -227,6 +315,9 @@ def process(output, master_description, satellites): for peripheral in master_description["peripherals"]: n_channels = pm.process(rtio_offset, peripheral) rtio_offset += n_channels + if base == "standalone": + n_channels = pm.add_sfp_leds(rtio_offset) + rtio_offset += n_channels for destination, description in satellites: if description["base"] != "satellite":