ddb_template: edge counter keys correspond with according ttl keys

previously ttl_counter_0 and ttl_0 could be on completely different physical ttl output channels
with this change, ttl_0_counter (note the changed key format) is always on the same channel as ttl_0

Signed-off-by: Leon Riesebos <leon.riesebos@duke.edu>
This commit is contained in:
Leon Riesebos 2021-09-03 18:03:52 -04:00 committed by Sébastien Bourdeauducq
parent e7a46ec767
commit 2cf144a60c
2 changed files with 13 additions and 10 deletions

View File

@ -22,6 +22,8 @@ Highlights:
* ``get()``, ``get_mu()``, ``get_att()``, and ``get_att_mu()`` functions added for AD9910 and AD9912 * ``get()``, ``get_mu()``, ``get_att()``, and ``get_att_mu()`` functions added for AD9910 and AD9912
* New hardware support: * New hardware support:
- HVAMP_8CH 8 channel HV amplifier for Fastino / Zotino - HVAMP_8CH 8 channel HV amplifier for Fastino / Zotino
* ``artiq_ddb_template`` generates edge-counter keys that start with the key of the corresponding
TTL device (e.g. ``"ttl_0_counter"`` for the edge counter on TTL device``"ttl_0"``)
Breaking changes: Breaking changes:

View File

@ -82,7 +82,7 @@ class PeripheralManager:
def gen(self, string, **kwargs): def gen(self, string, **kwargs):
print(textwrap.dedent(string).format(**kwargs), file=self.output) print(textwrap.dedent(string).format(**kwargs), file=self.output)
def process_dio(self, rtio_offset, peripheral): def process_dio(self, rtio_offset, peripheral, num_channels=8):
class_names = { class_names = {
"input": "TTLInOut", "input": "TTLInOut",
"output": "TTLOut" "output": "TTLOut"
@ -92,7 +92,8 @@ class PeripheralManager:
class_names[peripheral["bank_direction_high"]] class_names[peripheral["bank_direction_high"]]
] ]
channel = count(0) channel = count(0)
for i in range(8): name = [self.get_name("ttl") for _ in range(num_channels)]
for i in range(num_channels):
self.gen(""" self.gen("""
device_db["{name}"] = {{ device_db["{name}"] = {{
"type": "local", "type": "local",
@ -101,23 +102,23 @@ class PeripheralManager:
"arguments": {{"channel": 0x{channel:06x}}}, "arguments": {{"channel": 0x{channel:06x}}},
}} }}
""", """,
name=self.get_name("ttl"), name=name[i],
class_name=classes[i//4], class_name=classes[i // 4],
channel=rtio_offset+next(channel)) channel=rtio_offset + next(channel))
if peripheral.get("edge_counter", False): if peripheral.get("edge_counter", False):
for i in range(8): for i in range(num_channels):
class_name = classes[i//4] class_name = classes[i // 4]
if class_name == "TTLInOut": if class_name == "TTLInOut":
self.gen(""" self.gen("""
device_db["{name}"] = {{ device_db["{name}_counter"] = {{
"type": "local", "type": "local",
"module": "artiq.coredevice.edge_counter", "module": "artiq.coredevice.edge_counter",
"class": "EdgeCounter", "class": "EdgeCounter",
"arguments": {{"channel": 0x{channel:06x}}}, "arguments": {{"channel": 0x{channel:06x}}},
}} }}
""", """,
name=self.get_name("ttl_counter"), name=name[i],
channel=rtio_offset+next(channel)) channel=rtio_offset + next(channel))
return next(channel) return next(channel)
def process_urukul(self, rtio_offset, peripheral): def process_urukul(self, rtio_offset, peripheral):