def has_axi_master(self):
return False
+ def irq_name(self):
+ return ""
+
+ def mk_dma_irq(self, name, count):
+ if not self.irq_name():
+ return ''
+ sname = self.get_iname(count)
+ return "{0}_interrupt".format(sname)
+
+ def mk_dma_rule(self, name, count):
+ irqname = self.mk_dma_irq(name, count)
+ if not irqname:
+ return ''
+ pirqname = self.irq_name().format(count)
+ template = " {0}_interrupt.send(\n" + \
+ " slow_peripherals.{1});"
+ return template.format(irqname, pirqname)
+
+ def get_clock_reset(self, name, count):
+ return "slow_clock,slow_reset"
+
+ def mk_dma_sync(self, name, count):
+ irqname = self.mk_dma_irq(name, count)
+ if not irqname:
+ return ''
+ sname = self.peripheral.iname().format(count)
+ template = " SyncBitIfc#(Bit#(1)) {0} <-\n" + \
+ " <-mkSyncBitToCC({1});"
+ return template.format(irqname, self.get_clock_reset(name, count))
+
+ def mk_dma_connect(self, name, count):
+ return ''
+
def fastifdecl(self, name, count):
return ''
'slowifdecl', 'slowifdeclmux',
'fastifdecl',
'mkslow_peripheral',
+ 'mk_dma_sync', 'mk_dma_connect', 'mk_dma_rule',
'mkfast_peripheral',
'mk_plic', 'mk_ext_ifacedef',
'mk_connection', 'mk_cellconn', 'mk_pincon']:
ret.append(txt)
return '\n'.join(list(filter(None, ret)))
+ def mk_dma_irq(self):
+ ret = []
+ sync = []
+ rules = []
+ cnct = []
+
+ self.dma_count = 0
+
+ for (name, count) in self.ifacecount:
+ ifacerules = []
+ for i in range(count):
+ if not self.is_on_fastbus(name, i):
+ continue
+ txt = self.data[name].mk_dma_sync(name, i)
+ if txt:
+ self.dma_count += 1
+ sync.append(txt)
+ txt = self.data[name].mk_dma_rule(name, i)
+ ifacerules.append(txt)
+ txt = self.data[name].mk_dma_connect(name, i)
+ cnct.append(txt)
+ ifacerules = list(filter(None, ifacerules))
+ if ifacerules:
+ txt = " rule synchronize_%s_interrupts;" % name
+ rules.append(txt)
+ rules += ifacerules
+ rules.append(" endrule")
+
+ ct = self.dma_count
+ _cnct = [" rule rl_connect_interrupt_to_DMA;",
+ " Bit #(%d) lv_interrupt_to_DMA={" % ct]
+ cnct = _cnct + cnct
+ cnct.append(" };")
+ cnct.append(" dma.interrupt_from_peripherals(\n" + \
+ " lv_interrupt_to_DMA);")
+ cnct.append(" endrule;")
+
+ return '\n'.join(list(filter(None, sync + rules + cnct)))
+
def mk_ext_ifacedef(self):
ret = []
for (name, count) in self.ifacecount:
def slowimport(self):
return " import Uart16550 :: *;"
+ def irq_name(self):
+ return "quart{0}_intr"
+
def slowifdecl(self):
return " interface RS232_PHY_Ifc quart{0}_coe;\n" + \
- " method Bit#(1) quart{0}_intr;"
+ " method Bit#(1) %s;" % self.irq_name()
+
+ def get_clock_reset(self, name, count):
+ return "slow_clock,slow_reset" # XXX TODO: change to uart_clock/reset
def num_axi_regs32(self):
return 8
def mkslow_peripheral(self, size=0):
- return " Uart16550_AXI4_Lite_Ifc quart{0} <- \n" + \
+ return " // XXX XXX TODO: change to uart_clock/reset" + \
+ " Uart16550_AXI4_Lite_Ifc quart{0} <- \n" + \
" mkUart16550(clocked_by sp_clock,\n" + \
" reset_by sp_reset, sp_clock, sp_reset);"
mkplic = ifaces.mk_plic()
numsloirqs = ifaces.mk_sloirqsdef()
ifacedef = ifaces.mk_ext_ifacedef()
+ dma = ifaces.mk_dma_irq()
with open(soc, "w") as bsv_file:
bsv_file.write(soct.format(imports, ifdecl, mkfast,
slavedecl, mastdecl, mkcon,
- inst,
+ inst, dma,
#'', '' #regdef, slavedecl,
#'', mkslow, #fnaddrmap, mkslow, mkcon, mkcellcon,
#pincon, inst, mkplic,