integration/soc: set use_rom when cpu_reset_address is defined in a rom region.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 9 Mar 2020 18:36:39 +0000 (19:36 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 9 Mar 2020 18:36:47 +0000 (19:36 +0100)
litex/boards/targets/icebreaker.py
litex/soc/integration/soc.py

index c8644d80e2083452dbd2ccd55f6d671080385c04..b8045b0cffbc1bf1701ee77860351465889d542f 100755 (executable)
@@ -68,7 +68,7 @@ class BaseSoC(SoCCore):
         kwargs["integrated_sram_size"] = 0
         kwargs["integrated_rom_size"]  = 0
 
-         # Set CPU variant / reset address
+        # Set CPU variant / reset address
         kwargs["cpu_reset_address"] = self.mem_map["spiflash"] + bios_flash_offset
 
         # CRG --------------------------------------------------------------------------------------
index 37fed544022afed4b81b5c6558af8cb70fb6a72d..30f91f9164345f7d940b9464c92c498b5c7925ba 100644 (file)
@@ -774,7 +774,6 @@ class SoC(Module):
         self.csr.update_alignment(self.cpu.data_width)
         # Add Bus Masters/CSR/IRQs
         if not isinstance(self.cpu, cpu.CPUNone):
-            self.cpu.use_rom = (reset_address is None)
             if reset_address is None:
                 reset_address = self.mem_map["rom"]
             self.cpu.set_reset_address(reset_address)
@@ -854,20 +853,20 @@ class SoC(Module):
 
         # SoC CPU Check ----------------------------------------------------------------------------
         if not isinstance(self.cpu, cpu.CPUNone):
-            for name in ["sram"] + ["rom"] if self.cpu.use_rom else []:
-                if name not in self.bus.regions.keys():
-                    self.logger.error("CPU needs {} Region to be {} as Bus or Linker Region.".format(
-                        colorer(name),
-                        colorer("defined", color="red")))
-                    self.logger.error(self.bus)
-                    raise
-
+            if "sram" not in self.bus.regions.keys():
+                self.logger.error("CPU needs {} Region to be {} as Bus or Linker Region.".format(
+                    colorer("sram"),
+                    colorer("defined", color="red")))
+                self.logger.error(self.bus)
+                raise
             cpu_reset_address_valid = False
-            for container in self.bus.regions.values():
+            for name, container in self.bus.regions.items():
                 if self.bus.check_region_is_in(
                     region    = SoCRegion(origin=self.cpu.reset_address, size=self.bus.data_width//8),
                     container = container):
                     cpu_reset_address_valid = True
+                    if name == "rom":
+                        self.cpu.use_rom = True
             if not cpu_reset_address_valid:
                 self.logger.error("CPU needs {} to be in a {} Region.".format(
                     colorer("reset address 0x{:08x}".format(self.cpu.reset_address)),