From 9a086982c0fe87fd09ed74ab08a95e892a192886 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 1 Jun 2019 16:47:47 +0000 Subject: [PATCH] vendor.ice40_hx1k_blink_evn: implement. --- examples/blinky.py | 21 +++++++++++++++++++++ nmigen/vendor/ice40_hx1k_blink_evn.py | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 examples/blinky.py create mode 100644 nmigen/vendor/ice40_hx1k_blink_evn.py diff --git a/examples/blinky.py b/examples/blinky.py new file mode 100644 index 0000000..a41bab3 --- /dev/null +++ b/examples/blinky.py @@ -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 index 0000000..ee7c5f6 --- /dev/null +++ b/nmigen/vendor/ice40_hx1k_blink_evn.py @@ -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"]), + ] -- 2.30.2