self.logger.info(colorer("IRQ Handler created.", color="cyan"))
# Add ------------------------------------------------------------------------------------------
- def add(self, name, n=None):
+ def add(self, name, n=None, use_loc_if_exists=False):
allocated = False
- if name in self.irqs.keys():
- self.logger.error("{} IRQ name already used.".format(colorer(name, "red")))
- self.logger.error(self)
- raise
- if n in self.irqs.values():
- self.logger.error("{} IRQ Location already used.".format(colorer(n, "red")))
- self.logger.error(self)
- raise
- if n is None:
- allocated = True
- n = self.alloc(name)
- else:
- if n < 0:
- self.logger.error("{} IRQ Location should be positive.".format(
- colorer(n, color="red")))
+ if not (use_loc_if_exists and name in self.irqs.keys()):
+ if name in self.irqs.keys():
+ self.logger.error("{} IRQ name already used.".format(colorer(name, "red")))
+ self.logger.error(self)
raise
- if n > self.n_irqs:
- self.logger.error("{} IRQ Location too high (Up to {}).".format(
- colorer(n, color="red"),
- colorer(self.n_csrs, color="green")))
+ if n in self.irqs.values():
+ self.logger.error("{} IRQ Location already used.".format(colorer(n, "red")))
+ self.logger.error(self)
raise
+ if n is None:
+ allocated = True
+ n = self.alloc(name)
+ else:
+ if n < 0:
+ self.logger.error("{} IRQ Location should be positive.".format(
+ colorer(n, color="red")))
+ raise
+ if n > self.n_irqs:
+ self.logger.error("{} IRQ Location too high (Up to {}).".format(
+ colorer(n, color="red"),
+ colorer(self.n_csrs, color="green")))
+ raise
+ else:
+ n = self.irqs[name]
self.irqs[name] = n
self.logger.info("{} IRQ {} at Location {}.".format(
colorer(name, color="underline"),
self.submodules.uart = ResetInserter()(uart.UART(self.uart_phy))
self.add_csr("uart_phy", allow_user_defined=True)
self.add_csr("uart", allow_user_defined=True)
- self.add_interrupt("uart")
+ self.add_interrupt("uart", allow_user_defined=True)
# Add Identifier
if ident:
if with_timer:
self.submodules.timer0 = timer.Timer()
self.add_csr("timer0", allow_user_defined=True)
- self.add_interrupt("timer0")
+ self.add_interrupt("timer0", allow_user_defined=True)
# Add Wishbone to CSR bridge
self.config["CSR_DATA_WIDTH"] = csr_data_width
# Methods --------------------------------------------------------------------------------------
def add_interrupt(self, interrupt_name, interrupt_id=None, allow_user_defined=False):
- self.irq.add(interrupt_name, interrupt_id)
+ self.irq.add(interrupt_name, interrupt_id, use_loc_if_exists=allow_user_defined)
def add_csr(self, csr_name, csr_id=None, allow_user_defined=False):
self.csr.add(csr_name, csr_id, use_loc_if_exists=allow_user_defined)