vendor.ice40_hx1k_blink_evn: implement.
authorwhitequark <cz@m-labs.hk>
Sat, 1 Jun 2019 16:47:47 +0000 (16:47 +0000)
committerwhitequark <cz@m-labs.hk>
Sat, 1 Jun 2019 16:48:07 +0000 (16:48 +0000)
examples/blinky.py [new file with mode: 0644]
nmigen/vendor/ice40_hx1k_blink_evn.py [new file with mode: 0644]

diff --git a/examples/blinky.py b/examples/blinky.py
new file mode 100644 (file)
index 0000000..a41bab3
--- /dev/null
@@ -0,0 +1,21 @@
+from nmigen import *
+from nmigen.vendor.ice40_hx1k_blink_evn import *
+
+
+class Blinky(Elaboratable):
+    def elaborate(self, platform):
+        clk3p3   = platform.request("clk3p3", 0)
+        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)
diff --git a/nmigen/vendor/ice40_hx1k_blink_evn.py b/nmigen/vendor/ice40_hx1k_blink_evn.py
new file mode 100644 (file)
index 0000000..ee7c5f6
--- /dev/null
@@ -0,0 +1,26 @@
+from ..build import *
+from .fpga.lattice_ice40 import LatticeICE40Platform, IceBurnProgrammerMixin
+
+
+__all__ = ["ICE40HX1KBlinkEVNPlatform"]
+
+
+class ICE40HX1KBlinkEVNPlatform(IceBurnProgrammerMixin, LatticeICE40Platform):
+    device    = "hx1k"
+    package   = "vq100"
+    clocks    = [
+        ("clk3p3", 3.3e6),
+    ]
+    resources = [
+        Resource("clk3p3", 0, Pins("13", dir="i"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+
+        Resource("user_led", 0, Pins("59", dir="o"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+        Resource("user_led", 1, Pins("56", dir="o"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+        Resource("user_led", 2, Pins("53", dir="o"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+        Resource("user_led", 3, Pins("51", dir="o"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+
+        Resource("user_btn", 0, Pins("60"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+        Resource("user_btn", 1, Pins("57"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+        Resource("user_btn", 2, Pins("54"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+        Resource("user_btn", 3, Pins("52"), extras=["IO_STANDARD=SB_LVCMOS33"]),
+    ]