Skip to content

Commit cb18fc5

Browse files
phowhitequark
authored andcommitted
Add support for MuseLab iCESugar-nano board
1 parent b0a5dcb commit cb18fc5

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

nmigen_boards/icesugar_nano.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
import subprocess
3+
4+
from nmigen.build import *
5+
from nmigen.vendor.lattice_ice40 import *
6+
from .resources import *
7+
8+
9+
__all__ = ["ICESugarNanoPlatform"]
10+
11+
12+
class ICESugarNanoPlatform(LatticeICE40Platform):
13+
device = "iCE40LP1K"
14+
package = "CM36"
15+
default_clk = "clk12"
16+
17+
resources = [
18+
Resource("clk12", 0, Pins("D1", dir="i"),
19+
Clock(12e6), Attrs(GLOBAL=True, IO_STANDARD="LVCMOS33")),
20+
21+
*LEDResources(pins="B6", invert=False, attrs=Attrs(IO_STANDARD="LVCMOS33")),
22+
23+
UARTResource(0,
24+
tx="B3", rx="A3",
25+
attrs=Attrs(IO_STANDARD="LVTTL33", PULLUP=1)
26+
),
27+
28+
*SPIFlashResources(0,
29+
cs_n="D5", clk="E5", copi="E4", cipo="F5",
30+
attrs=Attrs(IO_STANDARD="LVCMOS33")
31+
),
32+
]
33+
34+
connectors = [
35+
Connector("pmod", 0, "E2 D1 B1 A1 - -"), # PMOD1
36+
Connector("pmod", 1, "B3 A3 B6 C5 - -"), # PMOD2
37+
Connector("pmod", 2, "B4 B5 E1 B1 - - C6 E3 C2 A1 - -"), # PMOD3
38+
]
39+
40+
def toolchain_program(self, products, name):
41+
icesprog = os.environ.get("ICESPROG", "icesprog")
42+
with products.extract("{}.bin".format(name)) as bitstream_filename:
43+
subprocess.check_call([icesprog, bitstream_filename])
44+
45+
46+
if __name__ == "__main__":
47+
from .test.blinky import *
48+
ICESugarNanoPlatform().build(Blinky(), do_program=True)

0 commit comments

Comments
 (0)