From 12b8063941564344b5318bfd0f8fae1bae98ff2c Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 26 Jul 2022 11:44:03 +0200 Subject: [PATCH] sipeed_tang_primer_20k: Add LedChaser through 204 pin SODIMM connector/Dock. --- .../platforms/sipeed_tang_primer_20k.py | 30 ++++++++++++++----- .../targets/sipeed_tang_primer_20k.py | 9 +++++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/litex_boards/platforms/sipeed_tang_primer_20k.py b/litex_boards/platforms/sipeed_tang_primer_20k.py index 683fc33..1df54f7 100644 --- a/litex_boards/platforms/sipeed_tang_primer_20k.py +++ b/litex_boards/platforms/sipeed_tang_primer_20k.py @@ -51,10 +51,12 @@ _io = [ ), ] -# 204 Pins SODIMM Connector ------------------------------------------------------------------------ +# Dock 204 Pins SODIMM Connector ------------------------------------------------------------------- _connectors = [ - ["CARD1A", + ["CARD1", + # A. + # ------------------------------------------------- "---", # 0 # GND GND 5V 5V 5V 5V GND GND NC ( 1-10). " T13 --- --- --- --- --- --- --- --- ---", @@ -72,9 +74,8 @@ _connectors = [ " --- H16 R12 H14 P13 --- R13 G16 T14 H15", # GND GND (71-72). " --- ---", - ], - ["CARD1B", - "---", # 0 + # B. + # ------------------------------------------------- # NC (73-82). " M15 L13 M14 K11 F13 K12 G12 K13 T15 ---", # NC NC (83-92). @@ -106,6 +107,18 @@ _connectors = [ ], ] +# Dock IOs ----------------------------------------------------------------------------------------- + +_dock_io = [ + # Leds + ("user_led", 0, Pins( "CARD1:44"), IOStandard("LVCMOS33")), + ("user_led", 1, Pins( "CARD1:46"), IOStandard("LVCMOS33")), + ("user_led", 3, Pins( "CARD1:40"), IOStandard("LVCMOS33")), + ("user_led", 2, Pins( "CARD1:42"), IOStandard("LVCMOS33")), + ("user_led", 4, Pins( "CARD1:98"), IOStandard("LVCMOS33")), + ("user_led", 5, Pins("CARD1:136"), IOStandard("LVCMOS33")), +] + # Platform ----------------------------------------------------------------------------------------- class Platform(GowinPlatform): @@ -114,8 +127,11 @@ class Platform(GowinPlatform): def __init__(self, toolchain="gowin"): GowinPlatform.__init__(self, "GW2A-LV18PG256C8/I7", _io, _connectors, toolchain=toolchain, devicename="GW2A-18C") - self.toolchain.options["use_mspi_as_gpio"] = 1 - self.toolchain.options["use_sspi_as_gpio"] = 1 + self.add_extension(_dock_io) + self.toolchain.options["use_mspi_as_gpio"] = 1 + self.toolchain.options["use_sspi_as_gpio"] = 1 + self.toolchain.options["use_ready_as_gpio"] = 1 + self.toolchain.options["use_done_as_gpio"] = 1 def create_programmer(self, kit="openfpgaloader"): return OpenFPGALoader(cable="ft2232") diff --git a/litex_boards/targets/sipeed_tang_primer_20k.py b/litex_boards/targets/sipeed_tang_primer_20k.py index 5317690..1bce951 100755 --- a/litex_boards/targets/sipeed_tang_primer_20k.py +++ b/litex_boards/targets/sipeed_tang_primer_20k.py @@ -51,7 +51,7 @@ class _CRG(Module): # BaseSoC ------------------------------------------------------------------------------------------ class BaseSoC(SoCCore): - def __init__(self, sys_clk_freq=int(48e6), with_spi_flash=False, **kwargs): + def __init__(self, sys_clk_freq=int(48e6), with_spi_flash=False, with_led_chaser=True, **kwargs): platform = sipeed_tang_primer_20k.Platform() # CRG -------------------------------------------------------------------------------------- @@ -66,6 +66,13 @@ class BaseSoC(SoCCore): from litespi.opcodes import SpiNorFlashOpCodes as Codes self.add_spi_flash(mode="1x", module=SpiFlashModule(Codes.READ_1_1_1)) + # Leds ------------------------------------------------------------------------------------- + if with_led_chaser: + self.submodules.leds = LedChaser( + pads = platform.request_all("user_led"), + sys_clk_freq = sys_clk_freq + ) + # Build -------------------------------------------------------------------------------------------- def main():