integration/soc: Add CSR automatic allocation and enable it by default.
Un-allocated CSRs were already automatically detected so when un-allocated we can just simply allocate them automatically instead of raising an error. This also allows simplifying user's code since self.csr.add/self.add_csr will no longer be required.
This commit is contained in:
parent
3def6ae985
commit
aa9eb1f6a3
|
@ -587,15 +587,23 @@ class SoCCSRHandler(SoCLocHandler):
|
||||||
self.regions[name] = region
|
self.regions[name] = region
|
||||||
|
|
||||||
# Address map ----------------------------------------------------------------------------------
|
# Address map ----------------------------------------------------------------------------------
|
||||||
def address_map(self, name, memory):
|
def address_map(self, name, memory, auto_alloc=True):
|
||||||
if memory is not None:
|
if memory is not None:
|
||||||
name = name + "_" + memory.name_override
|
name = name + "_" + memory.name_override
|
||||||
if self.locs.get(name, None) is None:
|
if self.locs.get(name, None) is None:
|
||||||
self.logger.error("CSR {} {}.".format(
|
if auto_alloc:
|
||||||
colorer(name),
|
self.add(name, use_loc_if_exists=True)
|
||||||
colorer("not found", color="red")))
|
else:
|
||||||
self.logger.error(self)
|
self.logger.info("{} {} {} at Location {}.".format(
|
||||||
raise
|
colorer(name, color="underline"),
|
||||||
|
self.name,
|
||||||
|
colorer("allocated" if allocated else "added", color="cyan" if allocated else "green"),
|
||||||
|
colorer(n)))
|
||||||
|
self.logger.error("CSR {} {}.".format(
|
||||||
|
colorer(name),
|
||||||
|
colorer("not found", color="red")))
|
||||||
|
self.logger.error(self)
|
||||||
|
raise
|
||||||
return self.locs[name]
|
return self.locs[name]
|
||||||
|
|
||||||
# Str ------------------------------------------------------------------------------------------
|
# Str ------------------------------------------------------------------------------------------
|
||||||
|
@ -930,16 +938,6 @@ class SoC(Module):
|
||||||
|
|
||||||
# SoC finalization -----------------------------------------------------------------------------
|
# SoC finalization -----------------------------------------------------------------------------
|
||||||
def do_finalize(self):
|
def do_finalize(self):
|
||||||
self.logger.info(colorer("-"*80, color="bright"))
|
|
||||||
self.logger.info(colorer("Finalized SoC:"))
|
|
||||||
self.logger.info(colorer("-"*80, color="bright"))
|
|
||||||
self.logger.info(self.bus)
|
|
||||||
if hasattr(self, "dma_bus"):
|
|
||||||
self.logger.info(self.dma_bus)
|
|
||||||
self.logger.info(self.csr)
|
|
||||||
self.logger.info(self.irq)
|
|
||||||
self.logger.info(colorer("-"*80, color="bright"))
|
|
||||||
|
|
||||||
interconnect_p2p_cls = {
|
interconnect_p2p_cls = {
|
||||||
"wishbone": wishbone.InterconnectPointToPoint,
|
"wishbone": wishbone.InterconnectPointToPoint,
|
||||||
"axi-lite": axi.AXILiteInterconnectPointToPoint,
|
"axi-lite": axi.AXILiteInterconnectPointToPoint,
|
||||||
|
@ -1082,6 +1080,17 @@ class SoC(Module):
|
||||||
self.comb += self.cpu.interrupt[loc].eq(module.ev.irq)
|
self.comb += self.cpu.interrupt[loc].eq(module.ev.irq)
|
||||||
self.add_constant(name + "_INTERRUPT", loc)
|
self.add_constant(name + "_INTERRUPT", loc)
|
||||||
|
|
||||||
|
# SoC Infos --------------------------------------------------------------------------------
|
||||||
|
self.logger.info(colorer("-"*80, color="bright"))
|
||||||
|
self.logger.info(colorer("Finalized SoC:"))
|
||||||
|
self.logger.info(colorer("-"*80, color="bright"))
|
||||||
|
self.logger.info(self.bus)
|
||||||
|
if hasattr(self, "dma_bus"):
|
||||||
|
self.logger.info(self.dma_bus)
|
||||||
|
self.logger.info(self.csr)
|
||||||
|
self.logger.info(self.irq)
|
||||||
|
self.logger.info(colorer("-"*80, color="bright"))
|
||||||
|
|
||||||
# SoC build ------------------------------------------------------------------------------------
|
# SoC build ------------------------------------------------------------------------------------
|
||||||
def build(self, *args, **kwargs):
|
def build(self, *args, **kwargs):
|
||||||
self.build_name = kwargs.pop("build_name", self.platform.name)
|
self.build_name = kwargs.pop("build_name", self.platform.name)
|
||||||
|
|
Loading…
Reference in New Issue