From c6e28e8cd43bf6c6e674541785402dfe5d8833cf Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 5 Jun 2019 14:05:02 +0000 Subject: [PATCH] Simplify after changes in nmigen. --- nmigen_boards/_blinky.py | 10 +++++----- nmigen_boards/ice40_hx1k_blink_evn.py | 2 +- nmigen_boards/icestick.py | 2 +- nmigen_boards/tinyfpga_bx.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nmigen_boards/_blinky.py b/nmigen_boards/_blinky.py index 4fc0cc8..b0a190e 100644 --- a/nmigen_boards/_blinky.py +++ b/nmigen_boards/_blinky.py @@ -5,14 +5,14 @@ from nmigen.build import ResourceError 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) @@ -24,7 +24,7 @@ class Blinky(Elaboratable): 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) @@ -34,5 +34,5 @@ class Blinky(Elaboratable): 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) diff --git a/nmigen_boards/ice40_hx1k_blink_evn.py b/nmigen_boards/ice40_hx1k_blink_evn.py index 976091f..1acac2d 100644 --- a/nmigen_boards/ice40_hx1k_blink_evn.py +++ b/nmigen_boards/ice40_hx1k_blink_evn.py @@ -49,4 +49,4 @@ class ICE40HX1KBlinkEVNPlatform(LatticeICE40Platform): if __name__ == "__main__": from ._blinky import build_and_program - build_and_program(ICE40HX1KBlinkEVNPlatform, "clk3p3", 3.3e6) + build_and_program(ICE40HX1KBlinkEVNPlatform, "clk3p3") diff --git a/nmigen_boards/icestick.py b/nmigen_boards/icestick.py index b90573b..a60f8c9 100644 --- a/nmigen_boards/icestick.py +++ b/nmigen_boards/icestick.py @@ -62,4 +62,4 @@ class ICEStickPlatform(LatticeICE40Platform): if __name__ == "__main__": from ._blinky import build_and_program - build_and_program(ICEStickPlatform, "clk12", 12e6) + build_and_program(ICEStickPlatform, "clk12") diff --git a/nmigen_boards/tinyfpga_bx.py b/nmigen_boards/tinyfpga_bx.py index 0ad94b9..d9b0116 100644 --- a/nmigen_boards/tinyfpga_bx.py +++ b/nmigen_boards/tinyfpga_bx.py @@ -62,4 +62,4 @@ class TinyFPGABXPlatform(LatticeICE40Platform): if __name__ == "__main__": from ._blinky import build_and_program - build_and_program(TinyFPGABXPlatform, "clk16", 16e6) + build_and_program(TinyFPGABXPlatform, "clk16") -- 2.30.2