Fixing missing csr_constant/config support.
authorTim 'mithro' Ansell <mithro@mithis.com>
Sat, 14 Jan 2017 08:05:55 +0000 (19:05 +1100)
committerTim 'mithro' Ansell <mithro@mithis.com>
Sat, 14 Jan 2017 08:24:04 +0000 (19:24 +1100)
Missed as part of misoc merge at ff31959aea1e3815d95798996c3999f122314ae6.

litex/soc/integration/soc_core.py

index df54355f1acf8bb34ef6c2356ce09ba67e741081..223380dae958e5ac1c529bbf24c3e2ab0e72ef1c 100644 (file)
@@ -71,6 +71,8 @@ class SoCCore(Module):
         self._wb_masters = []
         self._wb_slaves = []
 
+        self.config = dict()
+
         if cpu_type is not None:
             if cpu_type == "lm32":
                 self.add_cpu_or_bridge(lm32.LM32(platform, self.cpu_reset_address))
@@ -82,6 +84,7 @@ class SoCCore(Module):
                 raise ValueError("Unsupported CPU type: {}".format(cpu_type))
             self.add_wb_master(self.cpu_or_bridge.ibus)
             self.add_wb_master(self.cpu_or_bridge.dbus)
+        self.config["CPU_TYPE"] = str(cpu_type).upper()
 
         if integrated_rom_size:
             self.submodules.rom = wishbone.SRAM(integrated_rom_size, read_only=True)
@@ -98,6 +101,7 @@ class SoCCore(Module):
 
         self.submodules.wishbone2csr = wishbone2csr.WB2CSR(
             bus_csr=csr_bus.Interface(csr_data_width, csr_address_width))
+        self.config["CSR_DATA_WIDTH"] = csr_data_width
         self.add_constant("CSR_DATA_WIDTH", csr_data_width)
         self.register_mem("csr", self.mem_map["csr"], self.wishbone2csr.wishbone)
 
@@ -107,6 +111,7 @@ class SoCCore(Module):
 
         if ident:
             self.submodules.identifier = identifier.Identifier(ident)
+        self.config["CLOCK_FREQUENCY"] = int(clk_freq)
         self.add_constant("SYSTEM_CLOCK_FREQUENCY", int(clk_freq))
 
         if with_timer:
@@ -205,6 +210,10 @@ class SoCCore(Module):
                 self.add_csr_region(name, (self.mem_map["csr"] + 0x800*mapaddr) | self.shadow_base, self.csr_data_width, csrs)
             for name, memory, mapaddr, mmap in self.csrbankarray.srams:
                 self.add_csr_region(name + "_" + memory.name_override, (self.mem_map["csr"] + 0x800*mapaddr) | self.shadow_base, self.csr_data_width, memory)
+            for name, constant in self.csrbankarray.constants:
+                self._constants.append(((name + "_" + constant.name).upper(), constant.value.value))
+            for name, value in sorted(self.config.items(), key=itemgetter(0)):
+                self._constants.append(("CONFIG_" + name.upper(), value))
 
             # Interrupts
             if hasattr(self.cpu_or_bridge, "interrupt"):