From b350aa8566f7fe7fa28867d6746ddd4883133fe8 Mon Sep 17 00:00:00 2001 From: Fischer Moseley <42497969+fischermoseley@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:12:53 -0600 Subject: [PATCH] examples: fix #37, use proper indexing in Amaranth examples --- examples/amaranth/ethernet_io_core.py | 2 +- examples/amaranth/uart_io_core.py | 2 +- examples/amaranth/uart_logic_analyzer.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/amaranth/ethernet_io_core.py b/examples/amaranth/ethernet_io_core.py index 9e2ab2f..0f65cea 100644 --- a/examples/amaranth/ethernet_io_core.py +++ b/examples/amaranth/ethernet_io_core.py @@ -29,7 +29,7 @@ class EthernetIOCoreExample(Elaboratable): # Autodetect the number of LEDs on the platform resources = platform.resources.keys() - self.n_leds = max([i for name, i in resources if name == "led"]) + self.n_leds = len([name for name, _ in resources if name == "led"]) # Add IOCore to Manta instance self.leds = Signal(self.n_leds) diff --git a/examples/amaranth/uart_io_core.py b/examples/amaranth/uart_io_core.py index 53c3a7c..cf051a3 100644 --- a/examples/amaranth/uart_io_core.py +++ b/examples/amaranth/uart_io_core.py @@ -22,7 +22,7 @@ class UARTIOCoreExample(Elaboratable): # Autodetect the number of LEDs on the platform resources = platform.resources.keys() - self.n_leds = max([i for name, i in resources if name == "led"]) + self.n_leds = len([name for name, _ in resources if name == "led"]) # Add IOCore to Manta instance self.leds = Signal(self.n_leds) diff --git a/examples/amaranth/uart_logic_analyzer.py b/examples/amaranth/uart_logic_analyzer.py index 0d6b539..f9f9dd1 100644 --- a/examples/amaranth/uart_logic_analyzer.py +++ b/examples/amaranth/uart_logic_analyzer.py @@ -38,9 +38,9 @@ class UARTLogicAnalyzerExample(Elaboratable): counter = Signal(10) m.d.sync += counter.eq(counter + 1) - m.d.comb += self.probe0.eq(counter[0]) - m.d.comb += self.probe1.eq(counter[1:2]) - m.d.comb += self.probe2.eq(counter[3:5]) + m.d.comb += self.probe0.eq(counter[0:1]) + m.d.comb += self.probe1.eq(counter[1:3]) + m.d.comb += self.probe2.eq(counter[3:6]) m.d.comb += self.probe3.eq(counter[6:]) # Wire UART pins to the Manta instance