aboutsummaryrefslogtreecommitdiff
path: root/amaranth_boards
diff options
context:
space:
mode:
Diffstat (limited to 'amaranth_boards')
-rw-r--r--amaranth_boards/test/blinky.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/amaranth_boards/test/blinky.py b/amaranth_boards/test/blinky.py
index 9999246..60ca799 100644
--- a/amaranth_boards/test/blinky.py
+++ b/amaranth_boards/test/blinky.py
@@ -2,6 +2,7 @@ import itertools
from amaranth import *
from amaranth.build import ResourceError
+from amaranth.lib import io
__all__ = ["Blinky"]
@@ -15,32 +16,34 @@ class Blinky(Elaboratable):
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)