Skip to content

Commit 4823971

Browse files
whitequarkbl0x
andcommitted
Add support for Tang Nano 9k.
Co-authored-by: Bastian Löher <b.loeher@gsi.de>
1 parent 54000b0 commit 4823971

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

amaranth_boards/tang_nano_9k.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import os
2+
import subprocess
3+
4+
from amaranth.build import *
5+
from amaranth.vendor.gowin import *
6+
7+
from .resources import *
8+
9+
10+
__all__ = ["TangNano9kPlatform"]
11+
12+
13+
class TangNano9kPlatform(GowinPlatform):
14+
part = "GW1NR-LV9QN88PC6/I5"
15+
family = "GW1NR-9C"
16+
default_clk = "clk27"
17+
resources = [
18+
Resource("clk27", 0, Pins("52", dir="i"),
19+
Clock(27e6), Attrs(IO_TYPE="LVCMOS33")),
20+
21+
*ButtonResources(pins="3 4", invert=True,
22+
attrs=Attrs(IO_TYPE="LVCMOS33")),
23+
24+
*LEDResources(pins="10 11 13 14 15 16", invert=True,
25+
attrs=Attrs(IO_TYPE="LVCMOS33")),
26+
27+
UARTResource(0, rx="18", tx="17",
28+
attrs=Attrs(PULL_MODE="UP", IO_TYPE="LVCMOS33")),
29+
30+
*SPIFlashResources(0,
31+
cs_n="60", clk="59", copi="61", cipo="62",
32+
attrs=Attrs(IO_TYPE="LVCMOS33")),
33+
34+
*SDCardResources(0,
35+
clk="36", cmd="37", dat0="39", dat3="38", wp_n="-",
36+
attrs=Attrs(IO_TYPE="LVCMOS33")),
37+
38+
Resource("lcd", 0,
39+
Subsignal("clk", Pins("35", dir="o")),
40+
Subsignal("hs", Pins("40", dir="o")),
41+
Subsignal("vs", Pins("34", dir="o")),
42+
Subsignal("de", Pins("33", dir="o")),
43+
Subsignal("r", Pins("75 74 73 72 71", dir="o")),
44+
Subsignal("g", Pins("70 69 68 57 56 55", dir="o")),
45+
Subsignal("b", Pins("54 53 51 42 41", dir="o")),
46+
Attrs(IO_TYPE="LVCMOS33", DRIVE=24)),
47+
48+
Resource("lcd_backlight", 0, Pins("86", dir="o"),
49+
Attrs(IO_TYPE="LVCMOS33")),
50+
51+
Resource("hdmi", 0,
52+
Subsignal("clk", DiffPairs(p="69", n="68", dir="o")),
53+
Subsignal("d", DiffPairs(p="71 73 75", n="70 72 74", dir="o")),
54+
Attrs(IO_TYPE="LVCMOS33")),
55+
]
56+
connectors = []
57+
58+
def toolchain_prepare(self, fragment, name, **kwargs):
59+
overrides = {
60+
"add_options":
61+
"set_option -use_mspi_as_gpio 1 -use_sspi_as_gpio 1",
62+
"gowin_pack_opts":
63+
"--sspi_as_gpio --mspi_as_gpio"
64+
}
65+
return super().toolchain_prepare(fragment, name, **overrides, **kwargs)
66+
67+
def toolchain_program(self, products, name):
68+
with products.extract("{}.fs".format(name)) as bitstream_filename:
69+
subprocess.check_call(["openFPGALoader", "-b", "tangnano9k", bitstream_filename])
70+
71+
72+
if __name__ == "__main__":
73+
from .test.blinky import *
74+
TangNano9kPlatform().build(Blinky(), do_program=True)

0 commit comments

Comments
 (0)