soc/init_rom: Add SoCError when ROM Size < Contents Size and cosmetic cleanups.

This commit is contained in:
Florent Kermarrec 2024-04-02 09:12:03 +02:00
parent 0601bf51c4
commit f181eabebb
1 changed files with 9 additions and 2 deletions

View File

@ -1068,8 +1068,15 @@ class SoC(LiteXModule, SoCCoreCompat):
self.logger.info("Initializing ROM {} with contents (Size: {}).".format(
colorer(name),
colorer(f"0x{4*len(contents):x}")))
if self.bus.regions[name].size < 4*len(contents):
self.logger.error("Contents Size ({}) {} ROM Size ({}).".format(
colorer(f"0x{4*len(contents):x}"),
colorer("exceeds", color="red"),
colorer(f"0x{self.bus.regions[name].size:x}"),
))
raise SoCError()
getattr(self, name).mem.init = contents
if auto_size and "w" not in self.bus.regions[name].mode:
if auto_size and ("w" not in self.bus.regions[name].mode):
self.logger.info("Auto-Resizing ROM {} from {} to {}.".format(
colorer(name),
colorer(f"0x{self.bus.regions[name].size:x}"),