From 23c66d68045831de0a372c8c237274d74c71ef4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Nguyen?= Date: Fri, 18 Oct 2024 11:48:34 +0200 Subject: [PATCH] Drop compatibility with Amaranth 0.4. --- .github/workflows/main.yml | 3 +-- amaranth_boards/test/blinky.py | 27 +++++++++++++++------------ pyproject.toml | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b43fbbab..eb396bff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,14 +21,13 @@ jobs: - 'pypy-3.10' # this version range needs to be synchronized with the one in pyproject.toml amaranth-version: - - '0.4' - '0.5' - 'git' allow-failure: - true - false exclude: # all of these are inverted (this is unfortunately the best way to do this) - - amaranth-version: '0.4' + - amaranth-version: '0.5' allow-failure: false - amaranth-version: 'git' allow-failure: true diff --git a/amaranth_boards/test/blinky.py b/amaranth_boards/test/blinky.py index 99992466..60ca799d 100644 --- a/amaranth_boards/test/blinky.py +++ b/amaranth_boards/test/blinky.py @@ -2,6 +2,7 @@ from amaranth import * from amaranth.build import ResourceError +from amaranth.lib import io __all__ = ["Blinky"] @@ -15,32 +16,34 @@ def get_all_resources(name): resources = [] for number in itertools.count(): try: - resources.append(platform.request(name, number)) + resources.append(platform.request(name, number, dir="-")) except ResourceError: break return resources rgb_leds = [res for res in get_all_resources("rgb_led")] - leds = [res.o for res in get_all_resources("led")] - leds.extend([led.r.o for led in rgb_leds]) - leds.extend([led.g.o for led in rgb_leds]) - leds.extend([led.b.o for led in rgb_leds]) - buttons = [res.i for res in get_all_resources("button")] - switches = [res.i for res in get_all_resources("switch")] + leds = [io.Buffer("o", res) for res in get_all_resources("led")] + leds.extend([io.Buffer("o", led.r) for led in rgb_leds]) + leds.extend([io.Buffer("o", led.g) for led in rgb_leds]) + leds.extend([io.Buffer("o", led.b) for led in rgb_leds]) + buttons = [io.Buffer("i", res) for res in get_all_resources("button")] + switches = [io.Buffer("i", res) for res in get_all_resources("switch")] + + m.submodules += leds + buttons + switches inverts = [0 for _ in leds] for index, button in zip(itertools.cycle(range(len(inverts))), buttons): - inverts[index] ^= button + inverts[index] ^= button.i for index, switch in zip(itertools.cycle(range(len(inverts))), switches): - inverts[index] ^= switch + inverts[index] ^= switch.i clk_freq = platform.default_clk_frequency - timer = Signal(range(int(clk_freq//2)), reset=int(clk_freq//2) - 1) + timer = Signal(range(int(clk_freq//2)), init=int(clk_freq//2) - 1) flops = Signal(len(leds)) - m.d.comb += Cat(leds).eq(flops ^ Cat(inverts)) + m.d.comb += Cat(led.o for led in leds).eq(flops ^ Cat(inverts)) with m.If(timer == 0): - m.d.sync += timer.eq(timer.reset) + m.d.sync += timer.eq(timer.init) m.d.sync += flops.eq(~flops) with m.Else(): m.d.sync += timer.eq(timer - 1) diff --git a/pyproject.toml b/pyproject.toml index 1882d756..46a389db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ license = {file = "LICENSE.txt"} requires-python = "~=3.9" dependencies = [ # this version requirement needs to be synchronized with the one in .github/workflows/main.yml - "amaranth>=0.4,<0.7", + "amaranth>=0.5,<0.7", ] [project.urls]