Merge pull request #303 from sergachev/master

sipeed_tang_nano_4k: add option to build with Gowin EMCU
This commit is contained in:
enjoy-digital 2021-12-09 14:30:54 +01:00 committed by GitHub
commit 35e0026875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 13 deletions

View File

@ -64,23 +64,28 @@ class _CRG(Module):
# BaseSoC ------------------------------------------------------------------------------------------ # BaseSoC ------------------------------------------------------------------------------------------
class BaseSoC(SoCCore): class BaseSoC(SoCCore):
mem_map = {**SoCCore.mem_map, **{"spiflash": 0x80000000}}
def __init__(self, sys_clk_freq=int(27e6), with_hyperram=False, with_led_chaser=True, with_video_terminal=True, **kwargs): def __init__(self, sys_clk_freq=int(27e6), with_hyperram=False, with_led_chaser=True, with_video_terminal=True, **kwargs):
platform = tang_nano_4k.Platform() platform = tang_nano_4k.Platform()
if 'cpu_type' in kwargs and kwargs['cpu_type'] == 'gowin_emcu':
kwargs['with_uart'] = False # CPU has own UART
kwargs['integrated_sram_size'] = 0 # SRAM is directly attached to CPU
kwargs["integrated_rom_size"] = 0 # boot flash directly attached to CPU
else:
# Put BIOS in SPIFlash to save BlockRAMs. # Put BIOS in SPIFlash to save BlockRAMs.
self.mem_map = {**SoCCore.mem_map, **{"spiflash": 0x80000000}}
kwargs["integrated_rom_size"] = 0 kwargs["integrated_rom_size"] = 0
kwargs["cpu_reset_address"] = self.mem_map["spiflash"] + 0 kwargs["cpu_reset_address"] = self.mem_map["spiflash"] + 0
kwargs["cpu_type"] = 'vexriscv'
kwargs["cpu_variant"] = 'minimal'
# SoCCore ---------------------------------------------------------------------------------- # SoCCore ----------------------------------------------------------------------------------
SoCCore.__init__(self, platform, sys_clk_freq, SoCCore.__init__(self, platform, sys_clk_freq,
ident = "LiteX SoC on Tang Nano 4K", ident = "LiteX SoC on Tang Nano 4K",
ident_version = True, ident_version = True,
**kwargs) **kwargs)
if self.cpu_type == 'vexriscv':
assert self.cpu_variant == 'minimal', 'use --cpu-variant=minimal to fit into number of BSRAMs'
# CRG -------------------------------------------------------------------------------------- # CRG --------------------------------------------------------------------------------------
self.submodules.crg = _CRG(platform, sys_clk_freq, with_video_pll=with_video_terminal) self.submodules.crg = _CRG(platform, sys_clk_freq, with_video_pll=with_video_terminal)
@ -89,6 +94,9 @@ class BaseSoC(SoCCore):
from litespi.opcodes import SpiNorFlashOpCodes as Codes from litespi.opcodes import SpiNorFlashOpCodes as Codes
self.add_spi_flash(mode="1x", module=W25Q32(Codes.READ_1_1_1), with_master=False) self.add_spi_flash(mode="1x", module=W25Q32(Codes.READ_1_1_1), with_master=False)
if self.cpu_type == 'gowin_emcu':
self.cpu.connect_uart(platform.request('serial'))
else:
# Add ROM linker region -------------------------------------------------------------------- # Add ROM linker region --------------------------------------------------------------------
self.bus.add_region("rom", SoCRegion( self.bus.add_region("rom", SoCRegion(
origin = self.mem_map["spiflash"] + 0, origin = self.mem_map["spiflash"] + 0,
@ -136,6 +144,10 @@ def main():
soc_core_args(parser) soc_core_args(parser)
args = parser.parse_args() args = parser.parse_args()
if args.cpu_type == 'gowin_emcu':
# FIXME: ARM software not supported yet
args.no_compile_software = True
soc = BaseSoC( soc = BaseSoC(
sys_clk_freq=int(float(args.sys_clk_freq)), sys_clk_freq=int(float(args.sys_clk_freq)),
**soc_core_argdict(args) **soc_core_argdict(args)