Skip to content

Commit

Permalink
Add support for Tang Nano.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Aug 4, 2023
1 parent 510c28e commit e7a034a
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions amaranth_boards/tang_nano.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import subprocess
from amaranth.vendor.gowin import GowinPlatform
from amaranth.build import *
from .resources import *


class TangNanoPlatform(GowinPlatform):
# GW1N-LV1QN48C6/I5
device = "GW1N-1"
series = "GW1N"
size = "1"
subseries = ""
voltage = "LV"
package = "QN48"
speed = "C6/I5"
default_clk = "clk24"
resources = [
Resource("clk24", 0, Pins("35", dir="i"), Clock(24_000_000),
Attrs(IO_TYPE="LVCMOS33")),

RGBLEDResource(0, r="18", g="16", b="17",
attrs=Attrs(IO_TYPE="LVCMOS33")),

*ButtonResources(pins="15 14", invert=True,
attrs=Attrs(IO_TYPE="LVCMOS33")),

UARTResource(0, tx="9", rx="8",
attrs=Attrs(IO_TYPE="LVCMOS33", PULL_MODE="UP")),

*SPIFlashResources(0,
cs_n="19", clk="20", copi="22", cipo="23", wp_n="24", hold_n="25",
attrs=Attrs(IO_TYPE="LVCMOS33")),

Resource("lcd", 0,
Subsignal("clk", Pins("11", dir="o")),
Subsignal("hs", Pins("10", dir="o")),
Subsignal("vs", Pins("46", dir="o")),
Subsignal("de", Pins("5", dir="o")),
Subsignal("r", Pins("27 28 29 30 31", dir="o")),
Subsignal("g", Pins("32 33 34 38 39 40", dir="o")),
Subsignal("b", Pins("41 42 43 44 45", dir="o")),
Attrs(IO_TYPE="LVCMOS33")),

Resource("lcd_backlight", 0, Pins("47", dir="o"),
Attrs(IO_TYPE="LVCMOS33")),
]
connectors = []

def toolchain_prepare(self, fragment, name, **kwargs):
overrides = {
"add_options":
"set_option -use_mspi_as_gpio 1 -use_sspi_as_gpio 1",
"gowin_pack_opts":
"--sspi_as_gpio --mspi_as_gpio"
}
return super().toolchain_prepare(fragment, name, **overrides, **kwargs)

def toolchain_program(self, products, name):
with products.extract("{}.fs".format(name)) as bitstream_filename:
subprocess.check_call(["openFPGALoader", "-b", "tangnano",
bitstream_filename])

0 comments on commit e7a034a

Please sign in to comment.