Skip to content

Commit 23c66d6

Browse files
jfngwhitequark
authored andcommitted
Drop compatibility with Amaranth 0.4.
1 parent d2caa61 commit 23c66d6

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

.github/workflows/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ jobs:
2121
- 'pypy-3.10'
2222
# this version range needs to be synchronized with the one in pyproject.toml
2323
amaranth-version:
24-
- '0.4'
2524
- '0.5'
2625
- 'git'
2726
allow-failure:
2827
- true
2928
- false
3029
exclude: # all of these are inverted (this is unfortunately the best way to do this)
31-
- amaranth-version: '0.4'
30+
- amaranth-version: '0.5'
3231
allow-failure: false
3332
- amaranth-version: 'git'
3433
allow-failure: true

amaranth_boards/test/blinky.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from amaranth import *
44
from amaranth.build import ResourceError
5+
from amaranth.lib import io
56

67

78
__all__ = ["Blinky"]
@@ -15,32 +16,34 @@ def get_all_resources(name):
1516
resources = []
1617
for number in itertools.count():
1718
try:
18-
resources.append(platform.request(name, number))
19+
resources.append(platform.request(name, number, dir="-"))
1920
except ResourceError:
2021
break
2122
return resources
2223

2324
rgb_leds = [res for res in get_all_resources("rgb_led")]
24-
leds = [res.o for res in get_all_resources("led")]
25-
leds.extend([led.r.o for led in rgb_leds])
26-
leds.extend([led.g.o for led in rgb_leds])
27-
leds.extend([led.b.o for led in rgb_leds])
28-
buttons = [res.i for res in get_all_resources("button")]
29-
switches = [res.i for res in get_all_resources("switch")]
25+
leds = [io.Buffer("o", res) for res in get_all_resources("led")]
26+
leds.extend([io.Buffer("o", led.r) for led in rgb_leds])
27+
leds.extend([io.Buffer("o", led.g) for led in rgb_leds])
28+
leds.extend([io.Buffer("o", led.b) for led in rgb_leds])
29+
buttons = [io.Buffer("i", res) for res in get_all_resources("button")]
30+
switches = [io.Buffer("i", res) for res in get_all_resources("switch")]
31+
32+
m.submodules += leds + buttons + switches
3033

3134
inverts = [0 for _ in leds]
3235
for index, button in zip(itertools.cycle(range(len(inverts))), buttons):
33-
inverts[index] ^= button
36+
inverts[index] ^= button.i
3437
for index, switch in zip(itertools.cycle(range(len(inverts))), switches):
35-
inverts[index] ^= switch
38+
inverts[index] ^= switch.i
3639

3740
clk_freq = platform.default_clk_frequency
38-
timer = Signal(range(int(clk_freq//2)), reset=int(clk_freq//2) - 1)
41+
timer = Signal(range(int(clk_freq//2)), init=int(clk_freq//2) - 1)
3942
flops = Signal(len(leds))
4043

41-
m.d.comb += Cat(leds).eq(flops ^ Cat(inverts))
44+
m.d.comb += Cat(led.o for led in leds).eq(flops ^ Cat(inverts))
4245
with m.If(timer == 0):
43-
m.d.sync += timer.eq(timer.reset)
46+
m.d.sync += timer.eq(timer.init)
4447
m.d.sync += flops.eq(~flops)
4548
with m.Else():
4649
m.d.sync += timer.eq(timer - 1)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ license = {file = "LICENSE.txt"}
1414
requires-python = "~=3.9"
1515
dependencies = [
1616
# this version requirement needs to be synchronized with the one in .github/workflows/main.yml
17-
"amaranth>=0.4,<0.7",
17+
"amaranth>=0.5,<0.7",
1818
]
1919

2020
[project.urls]

0 commit comments

Comments
 (0)