cc2ddf9374fc39b70790cf0c7baf84436f98eceb
4 from nmigen
.build
import *
5 from nmigen
.vendor
.lattice_ice40
import *
6 from .resources
import *
9 __all__
= ["ICEBreakerPlatform"]
12 class ICEBreakerPlatform(LatticeICE40Platform
):
17 Resource("clk12", 0, Pins("35", dir="i"),
18 Clock(12e6
), Attrs(GLOBAL
=True, IO_STANDARD
="SB_LVCMOS")),
20 *LEDResources(pins
="11 37", invert
=True, attrs
=Attrs(IO_STANDARD
="SB_LVCMOS")),
22 Resource("led_r", 0, PinsN("11", dir="o"), Attrs(IO_STANDARD
="SB_LVCMOS")),
23 Resource("led_g", 0, PinsN("37", dir="o"), Attrs(IO_STANDARD
="SB_LVCMOS")),
25 *ButtonResources(pins
="10", invert
=True, attrs
=Attrs(IO_STANDARD
="SB_LVCMOS")),
29 attrs
=Attrs(IO_STANDARD
="SB_LVTTL", PULLUP
=1)
33 cs
="16", clk
="15", mosi
="14", miso
="17", wp
="12", hold
="13",
34 attrs
=Attrs(IO_STANDARD
="SB_LVCMOS")
38 Connector("pmod", 0, " 4 2 47 45 - - 3 48 46 44 - -"), # PMOD1A
39 Connector("pmod", 1, "43 38 34 31 - - 42 36 32 28 - -"), # PMOD1B
40 Connector("pmod", 2, "27 25 21 19 - - 26 23 20 18 - -"), # PMOD2
42 # The attached LED/button section can be either used standalone or as a PMOD.
43 # Attach to platform using:
44 # p.add_resources(p.break_off_pmod)
45 # pmod_btn = plat.request("user_btn")
47 Resource("user_btn", 1, Pins("9", dir="i", conn
=("pmod", 2)),
48 Attrs(IO_STANDARD
="SB_LVCMOS")),
49 Resource("user_btn", 2, Pins("4", dir="i", conn
=("pmod", 2)),
50 Attrs(IO_STANDARD
="SB_LVCMOS")),
51 Resource("user_btn", 3, Pins("10", dir="i", conn
=("pmod", 2)),
52 Attrs(IO_STANDARD
="SB_LVCMOS")),
54 Resource("user_led", 2, Pins("7", dir="o", conn
=("pmod", 2)),
55 Attrs(IO_STANDARD
="SB_LVCMOS")),
56 Resource("user_led", 3, Pins("1", dir="o", conn
=("pmod", 2)),
57 Attrs(IO_STANDARD
="SB_LVCMOS")),
58 Resource("user_led", 4, Pins("2", dir="o", conn
=("pmod", 2)),
59 Attrs(IO_STANDARD
="SB_LVCMOS")),
60 Resource("user_led", 5, Pins("8", dir="o", conn
=("pmod", 2)),
61 Attrs(IO_STANDARD
="SB_LVCMOS")),
62 Resource("user_led", 6, Pins("3", dir="o", conn
=("pmod", 2)),
63 Attrs(IO_STANDARD
="SB_LVCMOS")),
65 # Color-specific aliases
66 Resource("user_ledr", 1, Pins("7", dir="o", conn
=("pmod", 2)),
67 Attrs(IO_STANDARD
="SB_LVCMOS")),
68 Resource("user_ledg", 1, Pins("1", dir="o", conn
=("pmod", 2)),
69 Attrs(IO_STANDARD
="SB_LVCMOS")),
70 Resource("user_ledg", 2, Pins("2", dir="o", conn
=("pmod", 2)),
71 Attrs(IO_STANDARD
="SB_LVCMOS")),
72 Resource("user_ledg", 3, Pins("8", dir="o", conn
=("pmod", 2)),
73 Attrs(IO_STANDARD
="SB_LVCMOS")),
74 Resource("user_ledg", 4, Pins("3", dir="o", conn
=("pmod", 2)),
75 Attrs(IO_STANDARD
="SB_LVCMOS"))
78 def toolchain_program(self
, products
, name
):
79 iceprog
= os
.environ
.get("ICEPROG", "iceprog")
80 with products
.extract("{}.bin".format(name
)) as bitstream_filename
:
81 subprocess
.check_call([iceprog
, bitstream_filename
])
84 if __name__
== "__main__":
85 from .test
.blinky
import *
86 p
= ICEBreakerPlatform()
87 p
.add_resources(p
.break_off_pmod
)
88 p
.build(Blinky(), do_program
=True)