Skip to content

Commit

Permalink
Drop compatibility with Amaranth 0.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfng authored and whitequark committed Oct 18, 2024
1 parent d2caa61 commit 23c66d6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions amaranth_boards/test/blinky.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from amaranth import *
from amaranth.build import ResourceError
from amaranth.lib import io


__all__ = ["Blinky"]
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 23c66d6

Please sign in to comment.