_blinky→test.blinky
[nmigen-boards.git] / nmigen_boards / ice40_hx1k_blink_evn.py
1 import os
2 import subprocess
3
4 from nmigen.build import *
5 from nmigen.vendor.lattice_ice40 import *
6 from .dev import *
7
8
9 __all__ = ["ICE40HX1KBlinkEVNPlatform"]
10
11
12 class ICE40HX1KBlinkEVNPlatform(LatticeICE40Platform):
13 device = "iCE40HX1K"
14 package = "VQ100"
15 default_clk = "clk3p3"
16 resources = [
17 Resource("clk3p3", 0, Pins("13", dir="i"), Clock(3.3e6),
18 Attrs(GLOBAL=True, IO_STANDARD="SB_LVCMOS")),
19
20 *LEDResources(pins="59 56 53 51", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
21
22 Resource("touch", 0, Pins("60"), Attrs(IO_STANDARD="SB_LVCMOS")),
23 Resource("touch", 1, Pins("57"), Attrs(IO_STANDARD="SB_LVCMOS")),
24 Resource("touch", 2, Pins("54"), Attrs(IO_STANDARD="SB_LVCMOS")),
25 Resource("touch", 3, Pins("52"), Attrs(IO_STANDARD="SB_LVCMOS")),
26
27 *SPIFlashResources(0,
28 cs="49", clk="48", mosi="45", miso="46",
29 attrs=Attrs(IO_STANDARD="SB_LVCMOS")
30 ),
31 ]
32 connectors = [
33 Connector("pmod", 1, "10 9 8 7 - - 4 3 2 1 - -"), # J1
34 Connector("pmod", 5, "40 42 62 64 - - 37 41 63 45 - -"), # J5
35 Connector("pmod", 6, "25 24 21 20 - - 26 27 28 33 - -"), # J6
36 Connector("pmod", 11, "49 45 46 48 - -"), # J11
37 Connector("pmod", 12, "59 56 53 51 - -"), # J12
38 ]
39
40 def toolchain_program(self, products, name):
41 iceburn = os.environ.get("ICEBURN", "iCEburn")
42 with products.extract("{}.bin".format(name)) as bitstream_filename:
43 subprocess.check_call([iceburn, "-evw", bitstream_filename])
44
45
46 if __name__ == "__main__":
47 from .test.blinky import *
48 ICE40HX1KBlinkEVNPlatform().build(Blinky(), do_program=True)