4 from nmigen
.build
import *
5 from nmigen
.vendor
.lattice_ice40
import *
9 __all__
= ["FomuHackerPlatform"]
12 class FomuHackerPlatform(LatticeICE40Platform
):
17 Resource("clk48", 0, Pins("F5", dir="i"),
18 Clock(48e6
), Attrs(GLOBAL
=True, IO_STANDARD
="SB_LVCMOS")),
20 Resource("user_led", 0, PinsN("A5", dir="o"), Attrs(IO_STANDARD
="SB_LVCMOS")),
21 Resource("rgb_led", 0,
22 Subsignal("r", PinsN("C5")),
23 Subsignal("g", PinsN("B5")),
24 Subsignal("b", PinsN("A5")),
25 Attrs(IO_STANDARD
="SB_LVCMOS"),
29 Subsignal("d_p", Pins("A4")),
30 Subsignal("d_n", Pins("A2")),
31 Subsignal("pullup", Pins("D5")),
32 Attrs(IO_STANDARD
="SB_LVCMOS"),
36 cs
="C1", clk
="D1", mosi
="F1", miso
="E1",
37 attrs
=Attrs(IO_STANDARD
="SB_LVCMOS"),
42 Connector("pin", 0, "F4"),
43 Connector("pin", 1, "E5"),
44 Connector("pin", 2, "E4"),
45 Connector("pin", 3, "F2"),
48 def toolchain_program(self
, products
, name
):
49 dfu_util
= os
.environ
.get("DFU_UTIL", "dfu-util")
50 with products
.extract("{}.bin".format(name
)) as bitstream_filename
:
51 subprocess
.check_call([dfu_util
, "-D", bitstream_filename
])
54 if __name__
== "__main__":
55 from ._blinky
import Blinky
56 FomuHackerPlatform().build(Blinky(), do_program
=True)