|
| 1 | +# |
| 2 | +# This file is part of LiteX-Boards. |
| 3 | +# |
| 4 | +# Copyright (c) 2026 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com> |
| 5 | +# SPDX-License-Identifier: BSD-2-Clause |
| 6 | + |
| 7 | +from migen import * |
| 8 | + |
| 9 | +from litex.build.generic_platform import * |
| 10 | +from litex.build.gowin.platform import GowinPlatform |
| 11 | +from litex.build.openfpgaloader import OpenFPGALoader |
| 12 | + |
| 13 | + |
| 14 | +# IOs ---------------------------------------------------------------------------------------------- |
| 15 | + |
| 16 | +_io = [ |
| 17 | + # Clk / Rst |
| 18 | + ("clk27", 0, Pins("52"), IOStandard("LVCMOS33"), Misc("PULL_MODE=UP")), |
| 19 | + |
| 20 | + # Leds |
| 21 | + ("user_led_n", 0, Pins("16"), Misc("PULL_MODE=UP DRIVE=8")), |
| 22 | + ("user_led_n", 1, Pins("15"), Misc("PULL_MODE=UP DRIVE=8")), |
| 23 | + ("user_led_n", 2, Pins("14"), Misc("PULL_MODE=UP DRIVE=8")), |
| 24 | + ("user_led_n", 3, Pins("13"), Misc("PULL_MODE=UP DRIVE=8")), |
| 25 | + ("user_led_n", 4, Pins("11"), Misc("PULL_MODE=UP DRIVE=8")), |
| 26 | + ("user_led_n", 5, Pins("10"), Misc("PULL_MODE=UP DRIVE=8")), |
| 27 | + |
| 28 | + # Buttons |
| 29 | + ("user_btn_n", 0, Pins("3"), Misc("PULL_MODE=UP")), |
| 30 | + ("user_btn_n", 1, Pins("4"), Misc("PULL_MODE=UP")), |
| 31 | + |
| 32 | + # Serial |
| 33 | + ("serial", 0, |
| 34 | + Subsignal("rx", Pins("18"), Misc("PULL_MODE=UP")), |
| 35 | + Subsignal("tx", Pins("17"), Misc("PULL_MODE=UP DRIVE=8")), |
| 36 | + IOStandard("LVCMOS33") |
| 37 | + ), |
| 38 | + |
| 39 | + # SPIFlash |
| 40 | + ("spiflash", 0, |
| 41 | + Subsignal("cs_n", Pins("60"), Misc("PULL_MODE=UP DRIVE=8")), |
| 42 | + Subsignal("clk", Pins("59"), Misc("PULL_MODE=UP DRIVE=8")), |
| 43 | + Subsignal("miso", Pins("62"), Misc("PULL_MODE=UP")), |
| 44 | + Subsignal("mosi", Pins("61"), Misc("PULL_MODE=UP DRIVE=8")), |
| 45 | + IOStandard("LVCMOS33"), |
| 46 | + ), |
| 47 | + |
| 48 | + # PSRAM |
| 49 | + ("O_psram_ck", 0, Pins(2)), |
| 50 | + ("O_psram_ck_n", 0, Pins(2)), |
| 51 | + ("O_psram_cs_n", 0, Pins(2)), |
| 52 | + ("O_psram_reset_n", 0, Pins(2)), |
| 53 | + ("IO_psram_dq", 0, Pins(16)), |
| 54 | + ("IO_psram_rwds", 0, Pins(2)), |
| 55 | +] |
| 56 | + |
| 57 | +# Connectors --------------------------------------------------------------------------------------- |
| 58 | + |
| 59 | +_connectors = [ |
| 60 | + ["J5", "25 26 27 28 29 30 33 34 35 36 37 38 39 40 41 42"], |
| 61 | + ["J6", "77 76 75 74 73 72 71 70 69 68 57 56 55 54 53 51"], |
| 62 | +] |
| 63 | + |
| 64 | +# Platform ----------------------------------------------------------------------------------------- |
| 65 | + |
| 66 | +class Platform(GowinPlatform): |
| 67 | + default_clk_name = "clk27" |
| 68 | + default_clk_period = 1e9/27e6 |
| 69 | + |
| 70 | + def __init__(self, toolchain="gowin"): |
| 71 | + GowinPlatform.__init__(self, "GW1NR-LV9QN88PC7/I6", _io, _connectors, toolchain=toolchain, devicename="GW1NR-9C") |
| 72 | + self.toolchain.options["use_mspi_as_gpio"] = 1 |
| 73 | + self.toolchain.options["use_sspi_as_gpio"] = 1 |
| 74 | + |
| 75 | + def create_programmer(self): |
| 76 | + return OpenFPGALoader("brs-100-gw1nr9") |
| 77 | + |
| 78 | + def do_finalize(self, fragment): |
| 79 | + GowinPlatform.do_finalize(self, fragment) |
| 80 | + self.add_period_constraint(self.lookup_request("clk27", loose=True), 1e9/27e6) |
0 commit comments