2022-01-21 22:45:49 -05:00
|
|
|
#
|
|
|
|
# This file is part of LiteX-Boards.
|
|
|
|
#
|
2022-01-22 09:55:36 -05:00
|
|
|
# Copyright (c) 2022 Icenowy Zheng <icenowy@aosc.io>
|
2022-01-21 22:45:49 -05:00
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
|
|
|
from migen import *
|
|
|
|
|
|
|
|
from litex.build.generic_platform import *
|
|
|
|
from litex.build.gowin.platform import GowinPlatform
|
2022-03-08 00:24:56 -05:00
|
|
|
from litex.build.gowin.programmer import GowinProgrammer
|
2022-01-21 22:45:49 -05:00
|
|
|
from litex.build.openfpgaloader import OpenFPGALoader
|
|
|
|
|
2022-03-08 00:24:56 -05:00
|
|
|
|
2022-01-21 22:45:49 -05:00
|
|
|
# IOs ----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_io = [
|
|
|
|
# Clk / Rst
|
|
|
|
("clk27", 0, Pins("52"), IOStandard("LVCMOS33")),
|
|
|
|
|
|
|
|
# Leds
|
|
|
|
("user_led", 0, Pins("10"), IOStandard("LVCMOS18")),
|
|
|
|
("user_led", 1, Pins("11"), IOStandard("LVCMOS18")),
|
|
|
|
("user_led", 2, Pins("13"), IOStandard("LVCMOS18")),
|
|
|
|
("user_led", 3, Pins("14"), IOStandard("LVCMOS18")),
|
|
|
|
("user_led", 4, Pins("15"), IOStandard("LVCMOS18")),
|
|
|
|
("user_led", 5, Pins("16"), IOStandard("LVCMOS18")),
|
|
|
|
|
|
|
|
# Buttons.
|
|
|
|
("user_btn", 0, Pins("3"), IOStandard("LVCMOS18")),
|
|
|
|
("user_btn", 1, Pins("4"), IOStandard("LVCMOS18")),
|
|
|
|
|
|
|
|
# Serial
|
|
|
|
("serial", 0,
|
|
|
|
Subsignal("rx", Pins("18")),
|
|
|
|
Subsignal("tx", Pins("17")),
|
|
|
|
IOStandard("LVCMOS33")
|
|
|
|
),
|
|
|
|
|
|
|
|
# SPIFlash
|
|
|
|
("spiflash", 0,
|
|
|
|
Subsignal("cs_n", Pins("60"), IOStandard("LVCMOS33")),
|
|
|
|
Subsignal("clk", Pins("59"), IOStandard("LVCMOS33")),
|
|
|
|
Subsignal("miso", Pins("62"), IOStandard("LVCMOS33")),
|
|
|
|
Subsignal("mosi", Pins("61"), IOStandard("LVCMOS33")),
|
|
|
|
),
|
|
|
|
|
|
|
|
("spisdcard", 0,
|
|
|
|
Subsignal("clk", Pins("36")),
|
|
|
|
Subsignal("mosi", Pins("37")),
|
|
|
|
Subsignal("cs_n", Pins("38")),
|
|
|
|
Subsignal("miso", Pins("39")),
|
|
|
|
IOStandard("LVCMOS33"),
|
|
|
|
),
|
|
|
|
|
2022-01-22 14:17:57 -05:00
|
|
|
# PSRAM
|
|
|
|
("O_psram_ck", 0, Pins(2)),
|
|
|
|
("O_psram_ck_n", 0, Pins(2)),
|
|
|
|
("O_psram_cs_n", 0, Pins(2)),
|
|
|
|
("O_psram_reset_n", 0, Pins(2)),
|
|
|
|
("IO_psram_dq", 0, Pins(16)),
|
|
|
|
("IO_psram_rwds", 0, Pins(2)),
|
|
|
|
|
2022-05-14 22:53:09 -04:00
|
|
|
# HDMI.
|
|
|
|
("hdmi", 0,
|
2022-09-23 05:18:30 -04:00
|
|
|
Subsignal("clk_p", Pins("69")),
|
2022-05-14 22:53:09 -04:00
|
|
|
Subsignal("clk_n", Pins("68")),
|
2022-09-23 05:18:30 -04:00
|
|
|
Subsignal("data0_p", Pins("71")),
|
2022-05-14 22:53:09 -04:00
|
|
|
Subsignal("data0_n", Pins("70")),
|
2022-09-23 05:18:30 -04:00
|
|
|
Subsignal("data1_p", Pins("73")),
|
2022-05-14 22:53:09 -04:00
|
|
|
Subsignal("data1_n", Pins("72")),
|
2022-09-23 05:18:30 -04:00
|
|
|
Subsignal("data2_p", Pins("75")),
|
2022-05-14 22:53:09 -04:00
|
|
|
Subsignal("data2_n", Pins("74")),
|
|
|
|
Misc("PULL_MODE=NONE"),
|
|
|
|
),
|
|
|
|
|
2022-01-22 14:17:57 -05:00
|
|
|
# TODO: SPI/RGB LCD
|
2023-03-04 09:25:59 -05:00
|
|
|
("spilcd", 0,
|
|
|
|
Subsignal("clk", Pins("79")),
|
|
|
|
Subsignal("mosi", Pins("77")),
|
|
|
|
Subsignal("cs", Pins("48")),
|
|
|
|
Subsignal("reset", Pins("47")),
|
|
|
|
Subsignal("rs", Pins("47")),
|
|
|
|
IOStandard("LVCMOS33"),
|
|
|
|
),
|
2022-01-21 22:45:49 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
# Connectors ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_connectors = [
|
|
|
|
# TODO
|
|
|
|
]
|
|
|
|
|
|
|
|
# Platform -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Platform(GowinPlatform):
|
|
|
|
default_clk_name = "clk27"
|
|
|
|
default_clk_period = 1e9/27e6
|
|
|
|
|
2022-02-14 05:35:08 -05:00
|
|
|
def __init__(self, toolchain="gowin"):
|
|
|
|
GowinPlatform.__init__(self, "GW1NR-LV9QN88PC6/I5", _io, _connectors, toolchain=toolchain, devicename="GW1NR-9C")
|
2022-01-21 22:45:49 -05:00
|
|
|
self.toolchain.options["use_mspi_as_gpio"] = 1
|
|
|
|
|
2022-03-08 00:24:56 -05:00
|
|
|
def create_programmer(self, kit="openfpgaloader"):
|
|
|
|
if kit == "gowin":
|
|
|
|
return GowinProgrammer(self.devicename)
|
|
|
|
else:
|
|
|
|
return OpenFPGALoader(cable="ft2232")
|
2022-01-21 22:45:49 -05:00
|
|
|
|
|
|
|
def do_finalize(self, fragment):
|
|
|
|
GowinPlatform.do_finalize(self, fragment)
|
|
|
|
self.add_period_constraint(self.lookup_request("clk27", loose=True), 1e9/27e6)
|