Skip to content

Commit

Permalink
Default output channel to last one, polish prompts
Browse files Browse the repository at this point in the history
If output channel is last, then there is one ports movement less

Signed-off-by: Egor Savkin <[email protected]>
  • Loading branch information
thomasfire committed Aug 22, 2024
1 parent 3cc5837 commit 6365287
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion artiq/frontend/artiq_ddb_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def process_dio(self, rtio_offset, peripheral, num_channels=8):
class_names[peripheral["bank_direction_high"]]
]
channel = count(0)
board = peripheral["board"].lower() if "board" in peripheral else ""
board = peripheral["board"] if "board" in peripheral else ""
name = [self.get_name("ttl") for _ in range(num_channels)]
for i in range(num_channels):
self.gen("""
Expand Down
34 changes: 18 additions & 16 deletions artiq/frontend/artiq_sinara_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def build(self):
self.leds = dict()
self.ttl_outs = dict()
self.ttl_ins = dict()
self.ttl_lvds_outs = dict()
self.ttl_lvds = dict()
self.ttl_lvds_ins = dict()
self.urukul_cplds = dict()
self.urukuls = dict()
Expand All @@ -75,12 +75,12 @@ def build(self):
dev = self.get_device(name)
if "led" in name: # guess
self.leds[name] = dev
elif "board" in desc and desc["board"] == "dio_lvds":
self.ttl_lvds_outs[name] = self.get_device(name)
elif "board" in desc and desc["board"].lower() == "dio_lvds":
self.ttl_lvds[name] = self.get_device(name)
else:
self.ttl_outs[name] = dev
elif (module, cls) == ("artiq.coredevice.ttl", "TTLInOut"):
if "board" in desc and desc["board"] == "dio_lvds":
if "board" in desc and desc["board"].lower() == "dio_lvds":
self.ttl_lvds_ins[name] = self.get_device(name)
else:
self.ttl_ins[name] = self.get_device(name)
Expand Down Expand Up @@ -163,7 +163,7 @@ def build(self):
self.ttl_outs = sorted(self.ttl_outs.items(), key=lambda x: x[1].channel)
self.ttl_ins = sorted(self.ttl_ins.items(), key=lambda x: x[1].channel)
self.ttl_lvds_ins = sorted(self.ttl_lvds_ins.items(), key=lambda x: x[1].channel)
self.ttl_lvds_outs = sorted(self.ttl_lvds_outs.items(), key=lambda x: x[1].channel)
self.ttl_lvds = sorted(self.ttl_lvds.items(), key=lambda x: x[1].channel)
self.urukuls = sorted(self.urukuls.items(), key=lambda x: (x[1].cpld.bus.channel, x[1].chip_select))
self.samplers = sorted(self.samplers.items(), key=lambda x: x[1].cnv.channel)
self.zotinos = sorted(self.zotinos.items(), key=lambda x: x[1].bus.channel)
Expand Down Expand Up @@ -268,21 +268,23 @@ def devices_to_string(chunk):
else:
print("FAILED")

def test_ttl_lvds_outs(self):
def test_ttl_lvds(self):
def lower_bound_of_device_chunk(dev_list, dev_name, N):
dev_index = next(i for i, v in enumerate(dev_list) if v[0] == dev_name)
return dev_index - (dev_index % N)

print(f"*** Testing LVDS TTL")

if len(self.ttl_lvds_ins) == 0:
if not self.ttl_lvds_ins:
print(f"No available input channels for testing. Skipping...")
return

ttl_in_index, ttl_out_index = 0, 0
ttl_in_index, ttl_out_index = 0, -1
default_ttl_in_name, _ = self.ttl_lvds_ins[ttl_in_index]
default_ttl_out_name, _ = self.ttl_lvds_outs[ttl_out_index]
default_ttl_out_name, _ = self.ttl_lvds[ttl_out_index]

print("LVDS TTL channels are tested in groups of 4.")
print("You can choose any channel within the group.")
ttl_in_name = input(f"TTL device to use as an input (default: {default_ttl_in_name}): ")
ttl_out_name = input(f"TTL device to use as an output (default: {default_ttl_out_name}): ")

Expand All @@ -292,18 +294,18 @@ def lower_bound_of_device_chunk(dev_list, dev_name, N):
ttl_out_name = default_ttl_out_name

ttl_in_index = lower_bound_of_device_chunk(self.ttl_lvds_ins, ttl_in_name, 4)
ttl_out_index = lower_bound_of_device_chunk(self.ttl_lvds_outs, ttl_out_name, 4)
ttl_out_index = lower_bound_of_device_chunk(self.ttl_lvds, ttl_out_name, 4)
ttl_in_static_chunk = self.ttl_lvds_ins[ttl_in_index: ttl_in_index + 4]
ttl_out_static_chunk = self.ttl_lvds_outs[ttl_out_index: ttl_out_index + 4]

print("LVDS TTL channels are tested in groups of 4.")
print("\nTesting output channels. Keep input group connected in the same slot, and cycle through all outputs.")
ttl_out_static_chunk = self.ttl_lvds[ttl_out_index: ttl_out_index + 4]

for ttl_out_moving_chunk in chunker(self.ttl_lvds_outs, 4):
print("\nTesting output channels. Keep input group connected in the same port, and cycle through all outputs.")
for ttl_out_moving_chunk in chunker(self.ttl_lvds, 4):
self.test_lvds_group(ttl_out_moving_chunk, ttl_in_static_chunk)

print("\nTesting input channels. Keep output group connected in the same slot, and cycle through all inputs.")
if len(self.ttl_lvds_ins) == 4:
return

print("\nTesting input channels. Keep output group connected in the same port, and cycle through all inputs.")
for ttl_in_moving_chunk in chunker(self.ttl_lvds_ins, 4):
if not ttl_in_moving_chunk == ttl_in_static_chunk:
self.test_lvds_group(ttl_out_static_chunk, ttl_in_moving_chunk)
Expand Down

0 comments on commit 6365287

Please sign in to comment.