@@ -62,15 +62,20 @@ class BaseSoC(SoCCore):
6262 def __init__ (self , toolchain = "gowin" , sys_clk_freq = 27e6 , bios_flash_offset = 0x0 ,
6363 with_led_chaser = True ,
6464 with_video_terminal = False ,
65+ with_integrated_rom = False ,
6566 ** kwargs ):
6667 platform = sipeed_tang_nano_9k .Platform (toolchain = toolchain )
6768
6869 # CRG --------------------------------------------------------------------------------------
6970 self .crg = _CRG (platform , sys_clk_freq , with_video_pll = with_video_terminal )
7071
7172 # SoCCore ----------------------------------------------------------------------------------
72- # Disable Integrated ROM
73- kwargs ["integrated_rom_size" ] = 0
73+ # Keep the BIOS in external SPI Flash by default to save GW1N-9 resources.
74+ # --with-integrated-rom is useful for SRAM-only loading/debug, at the cost of extra BRAMs.
75+ if with_integrated_rom :
76+ kwargs .setdefault ("integrated_rom_size" , 128 * KILOBYTE )
77+ else :
78+ kwargs ["integrated_rom_size" ] = 0
7479 SoCCore .__init__ (self , platform , sys_clk_freq , ident = "LiteX SoC on Tang Nano 9K" , ** kwargs )
7580
7681 # SPI Flash --------------------------------------------------------------------------------
@@ -79,12 +84,13 @@ def __init__(self, toolchain="gowin", sys_clk_freq=27e6, bios_flash_offset=0x0,
7984 self .add_spi_flash (mode = "1x" , module = W25Q32 (Codes .READ_1_1_1 ), with_master = False )
8085
8186 # Add ROM linker region --------------------------------------------------------------------
82- self .bus .add_region ("rom" , SoCRegion (
83- origin = self .bus .regions ["spiflash" ].origin + bios_flash_offset ,
84- size = 64 * KILOBYTE ,
85- linker = True )
86- )
87- self .cpu .set_reset_address (self .bus .regions ["rom" ].origin )
87+ if not with_integrated_rom :
88+ self .bus .add_region ("rom" , SoCRegion (
89+ origin = self .bus .regions ["spiflash" ].origin + bios_flash_offset ,
90+ size = 64 * KILOBYTE ,
91+ linker = True )
92+ )
93+ self .cpu .set_reset_address (self .bus .regions ["rom" ].origin )
8894
8995 # HyperRAM ---------------------------------------------------------------------------------
9096 if not self .integrated_main_ram_size :
@@ -142,6 +148,7 @@ def main():
142148 parser .add_target_argument ("--bios-flash-offset" , default = "0x0" , help = "BIOS offset in SPI Flash." )
143149 parser .add_target_argument ("--with-spi-sdcard" , action = "store_true" , help = "Enable SPI-mode SDCard support." )
144150 parser .add_target_argument ("--with-video-terminal" , action = "store_true" , help = "Enable Video Terminal (HDMI)." )
151+ parser .add_target_argument ("--with-integrated-rom" , action = "store_true" , help = "Build BIOS into FPGA bitstream for SRAM-only loading/debug." )
145152 parser .add_target_argument ("--prog-kit" , default = "openfpgaloader" , help = "Programmer select from Gowin/openFPGALoader." )
146153 args = parser .parse_args ()
147154
@@ -150,6 +157,7 @@ def main():
150157 sys_clk_freq = args .sys_clk_freq ,
151158 bios_flash_offset = int (args .bios_flash_offset , 0 ),
152159 with_video_terminal = args .with_video_terminal ,
160+ with_integrated_rom = args .with_integrated_rom ,
153161 ** parser .soc_argdict
154162 )
155163
0 commit comments