Skip to content

Commit

Permalink
artiq_ddb_template: add support for user LEDs
Browse files Browse the repository at this point in the history
Add support for additional user LEDs.
  • Loading branch information
SimonRenblad committed Oct 24, 2023
1 parent 06eca3b commit f65da63
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions artiq/frontend/artiq_ddb_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ def get_cpu_target(description):
else:
raise NotImplementedError


def get_num_leds(description):
drtio_role = description["drtio_role"]
target = description["target"]
hw_rev = description["hw_rev"]
kasli_board_leds = {
"v1.0": 4,
"v1.1": 6,
"v2.0": 3
}
if target == "kasli_soc":
return 2
if target == "kasli":
if hw_rev in ("v1.0", "v1.1") and drtio_role != "standalone":
# LEDs are used for DRTIO status on v1.0 and v1.1
return kasli_board_leds[hw_rev] - 3
return kasli_board_leds[hw_rev]


def process_header(output, description):
print(textwrap.dedent("""
# Autogenerated for the {variant} variant
Expand Down Expand Up @@ -703,8 +722,8 @@ def process(self, rtio_offset, peripheral):
processor = getattr(self, "process_"+str(peripheral["type"]))
return processor(rtio_offset, peripheral)

def add_board_leds(self, rtio_offset, board_name=None):
for i in range(2):
def add_board_leds(self, rtio_offset, board_name=None, num_leds=2):
for i in range(num_leds):
if board_name is None:
led_name = self.get_name("led")
else:
Expand All @@ -718,7 +737,7 @@ def add_board_leds(self, rtio_offset, board_name=None):
}}""",
name=led_name,
channel=rtio_offset+i)
return 2
return num_leds


def split_drtio_eem(peripherals):
Expand Down Expand Up @@ -747,9 +766,10 @@ def process(output, primary_description, satellites):
for peripheral in local_peripherals:
n_channels = pm.process(rtio_offset, peripheral)
rtio_offset += n_channels
if drtio_role == "standalone":
n_channels = pm.add_board_leds(rtio_offset)
rtio_offset += n_channels

num_leds = get_num_leds(primary_description)
pm.add_board_leds(rtio_offset, num_leds=num_leds)
rtio_offset += num_leds

for destination, description in satellites:
if description["drtio_role"] != "satellite":
Expand All @@ -768,7 +788,11 @@ def process(output, primary_description, satellites):
for peripheral in peripherals:
n_channels = pm.process(rtio_offset, peripheral)
rtio_offset += n_channels


num_leds = get_num_leds(description)
pm.add_board_leds(rtio_offset, num_leds=num_leds)
rtio_offset += num_leds

for peripheral in drtio_peripherals:
print(textwrap.dedent("""
# DEST#{dest} peripherals
Expand Down

0 comments on commit f65da63

Please sign in to comment.