class Blinky(Elaboratable):
- def __init__(self, clk_name, clk_freq):
+ def __init__(self, clk_name):
self.clk_name = clk_name
- self.clk_freq = clk_freq
def elaborate(self, platform):
m = Module()
clk = platform.request(self.clk_name)
+ clk_freq = platform.get_clock_constraint(clk)
m.domains.sync = ClockDomain()
m.d.comb += ClockSignal().eq(clk.i)
break
leds = Cat(led.o for led in leds)
- ctr = Signal(max=int(self.clk_freq//2), reset=int(self.clk_freq//2) - 1)
+ ctr = Signal(max=int(clk_freq//2), reset=int(clk_freq//2) - 1)
with m.If(ctr == 0):
m.d.sync += ctr.eq(ctr.reset)
m.d.sync += leds.eq(~leds)
return m
-def build_and_program(platform_cls, clk_name, clk_freq, **kwargs):
- platform_cls().build(Blinky(clk_name, clk_freq), do_program=True, **kwargs)
+def build_and_program(platform_cls, clk_name, **kwargs):
+ platform_cls().build(Blinky(clk_name), do_program=True, **kwargs)
if __name__ == "__main__":
from ._blinky import build_and_program
- build_and_program(ICE40HX1KBlinkEVNPlatform, "clk3p3", 3.3e6)
+ build_and_program(ICE40HX1KBlinkEVNPlatform, "clk3p3")
if __name__ == "__main__":
from ._blinky import build_and_program
- build_and_program(ICEStickPlatform, "clk12", 12e6)
+ build_and_program(ICEStickPlatform, "clk12")
if __name__ == "__main__":
from ._blinky import build_and_program
- build_and_program(TinyFPGABXPlatform, "clk16", 16e6)
+ build_and_program(TinyFPGABXPlatform, "clk16")