_blinky→test.blinky
authorwhitequark <whitequark@whitequark.org>
Mon, 23 Sep 2019 08:16:07 +0000 (08:16 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 23 Sep 2019 08:16:07 +0000 (08:16 +0000)
Expose blinky as a stable component, to make writing out-of-tree
board files a bit nicer.

17 files changed:
nmigen_boards/_blinky.py [deleted file]
nmigen_boards/arty_a7.py
nmigen_boards/atlys.py
nmigen_boards/blackice.py
nmigen_boards/blackice_ii.py
nmigen_boards/fomu_hacker.py
nmigen_boards/ice40_hx1k_blink_evn.py
nmigen_boards/ice40_hx8k_b_evn.py
nmigen_boards/icebreaker.py
nmigen_boards/icestick.py
nmigen_boards/kc705.py
nmigen_boards/mercury.py
nmigen_boards/numato_mimas.py
nmigen_boards/test/blinky.py [new file with mode: 0644]
nmigen_boards/tinyfpga_bx.py
nmigen_boards/versa_ecp5.py
nmigen_boards/versa_ecp5_5g.py

diff --git a/nmigen_boards/_blinky.py b/nmigen_boards/_blinky.py
deleted file mode 100644 (file)
index 4a173d4..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-import itertools
-
-from nmigen import *
-from nmigen.build import ResourceError
-
-
-class Blinky(Elaboratable):
-    def elaborate(self, platform):
-        m = Module()
-
-        leds = []
-        for n in itertools.count():
-            try:
-                leds.append(platform.request("led", n))
-            except ResourceError:
-                break
-        leds = Cat(led.o for led in leds)
-
-        clk_freq = platform.default_clk_frequency
-        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)
-        with m.Else():
-            m.d.sync += ctr.eq(ctr - 1)
-
-        return m
index 53869a38c9cacca9289d6410210635969d7f7a99..57fe765cfc5be5f19a534801068aa4fa869b0d0a 100644 (file)
@@ -215,5 +215,5 @@ class ArtyA7Platform(Xilinx7SeriesPlatform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     ArtyA7Platform().build(Blinky(), do_program=True)
index d01030765298c38b643b70e67d67a8c074f07489..d70c6d03b4712c7b91fbf6313af8e9885c1568bb 100644 (file)
@@ -226,5 +226,5 @@ class AtlysPlatform(XilinxSpartan6Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     AtlysPlatform().build(Blinky(), do_program=True)
index ec67def5ae9d01ac3d7418045c483e5dc89217f4..385401d369d4e63b3f970e384e5e30af20625e44 100644 (file)
@@ -56,5 +56,5 @@ class BlackIcePlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     BlackIcePlatform().build(Blinky(), do_program=True)
index baa135ca8f1460c12c7065507a1d91d72ec5de87..86e381d70a198f8b7abdc39a4377eb75d0d734e1 100644 (file)
@@ -58,5 +58,5 @@ class BlackIceIIPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     BlackIceIIPlatform().build(Blinky(), do_program=True)
index 2ff00387bb63af55c3ffcbe883687f4e597f7199..0ddfe490b5ac66690fa9feacfc553fc64a594b57 100644 (file)
@@ -50,5 +50,5 @@ class FomuHackerPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     FomuHackerPlatform().build(Blinky(), do_program=True)
index 2a766030f58b3e0fab1a5cc8dc58ad9630e10028..ae46f248390b2a88734cfd23054d8b1c5237a0a2 100644 (file)
@@ -44,5 +44,5 @@ class ICE40HX1KBlinkEVNPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     ICE40HX1KBlinkEVNPlatform().build(Blinky(), do_program=True)
index e27218ab5b8c7ad3e939b049fe0d5054a75282af..ce55e81df805d3261bde27ed4339f57fa176a14b 100644 (file)
@@ -63,5 +63,5 @@ class ICE40HX8KBEVNPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     ICE40HX8KBEVNPlatform().build(Blinky(), do_program=True)
index 9971ee0e31fb94af1d3b0d125a23960b52e4d5d0..2f3034cff3d0d9dc33d46c35e656c45258dcb4eb 100644 (file)
@@ -82,7 +82,7 @@ class ICEBreakerPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     p = ICEBreakerPlatform()
     p.add_resources(p.break_off_pmod)
     p.build(Blinky(), do_program=True)
index 99302e7654d1a2556c5b39b020bd280b2be4fc0d..763eaee4d57df2bb8f78c958ace104547063609c 100644 (file)
@@ -49,5 +49,5 @@ class ICEStickPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     ICEStickPlatform().build(Blinky(), do_program=True)
index f179d10936c5952dce1bbf3390869b25d6ea3a61..bc889deaa92067cac7d37d6887f021833794b47f 100644 (file)
@@ -38,5 +38,5 @@ class KC705Platform(Xilinx7SeriesPlatform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     KC705Platform().build(Blinky(), do_program=True)
index 5ad6254bdca1126c5fc50a9a7114ec1fd44284d3..c14e85cb8272acfe08b4d1e9dcae473e9f71bbd0 100644 (file)
@@ -218,7 +218,7 @@ class MercuryPlatform(XilinxSpartan3APlatform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     plat = MercuryPlatform()
     plat.add_resources(plat.leds)
     plat.build(Blinky(), do_program=True)
index d484fa28d1175dade6687b3f0c720851d1a93f7f..c0945286d085a70d6b28c1e5d06886436c7a9cf5 100644 (file)
@@ -47,5 +47,5 @@ class NumatoMimasPlatform(XilinxSpartan6Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     NumatoMimasPlatform().build(Blinky())
diff --git a/nmigen_boards/test/blinky.py b/nmigen_boards/test/blinky.py
new file mode 100644 (file)
index 0000000..5e20191
--- /dev/null
@@ -0,0 +1,30 @@
+import itertools
+
+from nmigen import *
+from nmigen.build import ResourceError
+
+
+__all__ = ["Blinky"]
+
+
+class Blinky(Elaboratable):
+    def elaborate(self, platform):
+        m = Module()
+
+        leds = []
+        for n in itertools.count():
+            try:
+                leds.append(platform.request("led", n))
+            except ResourceError:
+                break
+        leds = Cat(led.o for led in leds)
+
+        clk_freq = platform.default_clk_frequency
+        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)
+        with m.Else():
+            m.d.sync += ctr.eq(ctr - 1)
+
+        return m
index c563565a9e2ef5143b6b5e7ef8b381d29fe8a70c..537d0fe9f7909ae75687277b529f29537d5aebc2 100644 (file)
@@ -52,5 +52,5 @@ class TinyFPGABXPlatform(LatticeICE40Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     TinyFPGABXPlatform().build(Blinky(), do_program=True)
index 6b26d4f1bf6ad6e5a4400c5f589a55687dd1b6c7..a3890ac13404cfd873cead6404461e12a97b232f 100644 (file)
@@ -172,5 +172,5 @@ class VersaECP5Platform(LatticeECP5Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     VersaECP5Platform().build(Blinky(), do_program=True)
index 02fa8b1844d4a68f5cc31971164012d60eb48865..36e6997c55b40f734df1feb32338a658e892197a 100644 (file)
@@ -10,5 +10,5 @@ class VersaECP55GPlatform(VersaECP5Platform):
 
 
 if __name__ == "__main__":
-    from ._blinky import Blinky
+    from .test.blinky import *
     VersaECP55GPlatform().build(Blinky(), do_program=True)