from amaranth import Elaboratable, Module, Signal from amaranth.lib.io import Buffer from groovylight.platforms.colorlight_5a75b_v8_2 import Colorlight_5A75B_R82Platform class Blinky(Elaboratable): def elaborate(self, platform): m = Module() m.submodules.led = led = Buffer("o", platform.request("led", dir="-")) state = Signal() counter = Signal(24) with m.If(counter == 0): m.d.sync += [counter.eq(~0), state.eq(~state)] with m.Else(): m.d.sync += counter.eq(counter - 1) m.d.comb += led.o.eq(state) return m def test_platform(): plat = Colorlight_5A75B_R82Platform() plat.build(Blinky())