4 from nmigen
.build
import *
5 from nmigen
.vendor
.lattice_ice40
import *
6 from .resources
import *
9 __all__
= ["ICE40HX8KBEVNPlatform"]
12 class ICE40HX8KBEVNPlatform(LatticeICE40Platform
):
17 Resource("clk12", 0, Pins("J3", dir="i"),
18 Clock(12e6
), Attrs(GLOBAL
=True, IO_STANDARD
="SB_LVCMOS")),
21 pins
="C3 B3 C4 C5 A1 A2 B4 B5",
22 attrs
=Attrs(IO_STANDARD
="SB_LVCMOS")
26 rx
="B10", tx
="B12", rts
="A15", cts
="B13", dtr
="B14", dsr
="A16", dcd
="B15",
27 attrs
=Attrs(IO_STANDARD
="SB_LVCMOS", PULLUP
=1)
31 cs
="R12", clk
="R11", mosi
="P12", miso
="P11",
32 attrs
=Attrs(IO_STANDARD
="SB_LVCMOS")
36 Connector("j", 1, # J1
37 "A16 - A15 B15 B13 B14 - - B12 B11 "
38 "A11 B10 A10 C9 - - A9 B9 B8 A7 "
39 "B7 C7 - - A6 C6 B6 C5 A5 C4 "
40 "- - B5 C3 B4 B3 A2 A1 - - "),
41 Connector("j", 2, # J2
42 "- - - R15 P16 P15 - - N16 M15 "
43 "M16 L16 K15 K16 - - K14 J14 G14 F14 "
44 "J15 H14 - - H16 G15 G16 F15 F16 E14 "
45 "- - E16 D15 D16 D14 C16 B16 - - "),
46 Connector("j", 3, # J3
47 "R16 - T15 T16 T13 T14 - - N12 P13 "
48 "N10 M11 T11 P10 - - T10 R10 P8 P9 "
49 "T9 R9 - - T7 T8 T6 R6 T5 R5 "
50 "- - R3 R4 R2 T3 T1 T2 - - "),
51 Connector("j", 4, # J4
52 "- - - R1 P1 P2 - - N3 N2 "
53 "M2 M1 L3 L1 - - K3 K1 J2 J1 "
54 "H2 J3 - - G2 H1 F2 G1 E2 F1 "
55 "- - D1 D2 C1 C2 B1 B2 - - "),
58 def toolchain_program(self
, products
, name
):
59 iceprog
= os
.environ
.get("ICEPROG", "iceprog")
60 with products
.extract("{}.bin".format(name
)) as bitstream_filename
:
61 # TODO: this should be factored out and made customizable
62 subprocess
.check_call([iceprog
, "-S", bitstream_filename
])
65 if __name__
== "__main__":
66 from .test
.blinky
import *
67 ICE40HX8KBEVNPlatform().build(Blinky(), do_program
=True)