amaranth/examples/blinky.py
whitequark f417725b10 build.res: if not specified, request resource #0.
This markedly differs from oMigen system, which would request
consecutive resources. The difference is deliberate; most resources
are singular, so it does not matter for them, and for resources where
it does matter, which pins are requested should not depend on order
of execution of `platform.request`.
2019-06-03 02:54:17 +00:00

22 lines
596 B
Python

from nmigen import *
from nmigen.vendor.ice40_hx1k_blink_evn import *
class Blinky(Elaboratable):
def elaborate(self, platform):
clk3p3 = platform.request("clk3p3")
user_led = platform.request("user_led", 0)
counter = Signal(20)
m = Module()
m.domains.sync = ClockDomain()
m.d.comb += ClockSignal().eq(clk3p3.i)
m.d.sync += counter.eq(counter + 1)
m.d.comb += user_led.o.eq(counter[-1])
return m
if __name__ == "__main__":
platform = ICE40HX1KBlinkEVNPlatform()
platform.build(Blinky(), do_program=True)