import types
+
def li(txt, indent):
indent = ' ' * indent
istxt = False
name = self.axi_slave_name(name, ifacenum, typ)
return ("typedef {0} {1};".format(idx, name), 1)
- def axi_addr_map(self, name, ifacenum):
+ def axi_fastaddr_map(self, name, ifacenum):
+ return self.axi_addr_map(name, ifacenum, 'fast')
+
+ def axi_addr_map(self, name, ifacenum, typ=""):
bname = self.axibase(name, ifacenum)
bend = self.axiend(name, ifacenum)
- name = self.axi_slave_name(name, ifacenum)
- return """\
- if(addr>=`{0} && addr<=`{1})
- return tuple2(True,fromInteger(valueOf({2})));
- else""".format(bname, bend, name)
+ name = self.axi_slave_name(name, ifacenum, typ)
+ template = """\
+if(addr>=`{0} && addr<=`{1})
+ return tuple2(True,fromInteger(valueOf({2})));
+else"""
+ return template.format(bname, bend, name)
def mk_pincon(self, name, count):
# TODO: really should be using bsv.interface_decl.Interfaces
pname = p['name']
#n = "{0}{1}".format(self.name, self.mksuffix(name, count))
n = name # "{0}{1}".format(self.name, self.mksuffix(name, count))
- ret.append(" //%s %s" % (n, str(p)))
+ ret.append("//%s %s" % (n, str(p)))
sname = self.peripheral.iname().format(count)
sname = "{0}.{1}".format(sname, pname)
ps = "pinmux.peripheral_side.%s" % sname
n_ = "{0}{1}".format(n, count)
n_ = '{0}.{1}'.format(n_, fname)
n_ = self.ifname_tweak(pname, 'in', n_)
- ret.append("mkConnection({1}, {0});".format(ps_, n_))
- return '\n'.join(li(ret, 6))
+ ret.append(
+ "mkConnection({1},\n\t\t\t{0});".format(
+ ps_, n_))
+ return '\n'.join(ret)
def mk_cellconn(self, *args):
return ''
print "PBase __mk_connection", self.name, aname
if not con:
return ''
- return li(txt.format(con, aname, fabricname), 8)
+ return txt.format(con, aname, fabricname)
def __mk_master_connection(self, con, aname):
txt = "mkConnection (slow_fabric.v_to_slaves\n" + \
print "PBase __mk_connection", self.name, aname
if not con:
return ''
- return li(txt.format(con, aname), 8)
+ return txt.format(con, aname)
def mk_connection(self, count, fabricname, typ, name=None):
if name is None:
plic = mkplic_rule.format(name, plic_obj, irq_offs)
res.append(plic)
irq_offs += 1 # increment to next irq
- return ('\n'.join(li(res, 5)), irq_offs)
+ return ('\n'.join(res), irq_offs)
def mk_ext_ifacedef(self, iname, inum):
return ''
def extfastifinstance(self, name, count):
return ''
- def _extifinstance(self, name, count, suffix, prefix, samename=False):
+ def _extifinstance(self, name, count, suffix, prefix, samename=False,
+ ifsuffix=None):
+ if ifsuffix is None:
+ ifsuffix = ''
pname = self.get_iname(count)
if samename:
sname = pname
else:
sname = self.peripheral.iname().format(count)
- template = " interface {0}{3} = {2}{1};"
- return template.format(pname, sname, prefix, suffix)
+ template = "interface {0}{3} = {2}{1}{4};"
+ return template.format(pname, sname, prefix, suffix, ifsuffix)
def extifinstance2(self, name, count):
return ''
def extifinstance(self, name, count):
return self._extifinstance(name, count, "",
- "pinmux.peripheral_side.")
+ "pinmux.peripheral_side.")
mkplic_rule = """\
endrule
"""
-axi_master_declarations= """\
+axi_master_declarations = """\
typedef 0 Dmem_master_num;
typedef 1 Imem_master_num;
{0}
axi_fastslave_declarations = """\
{0}
-typedef TAdd#(LastGen_fastslave_num,1) Sdram_cfg_slave_num;
+typedef TAdd#(LastGen_fastslave_num,1) Sdram_slave_num;
typedef TAdd#(Sdram_slave_num ,`ifdef SDRAM 1 `else 0 `endif )
Sdram_cfg_slave_num;
typedef TAdd#(Sdram_cfg_slave_num,`ifdef BOOTROM 1 `else 0 `endif )
Debug_slave_num ;
typedef TAdd#(Debug_slave_num , `ifdef TCMemory 1 `else 0 `endif )
TCM_slave_num;
-typedef TAdd#(TCM_slave_num ,`ifdef DMA 1 `else 0 `endif )
+typedef TAdd#(TCM_slave_num ,`ifdef DMA 1 `else 0 `endif )
Dma_slave_num;
typedef TAdd#(Dma_slave_num ,1 ) SlowPeripheral_slave_num;
typedef TAdd#(SlowPeripheral_slave_num,`ifdef VME 1 `else 0 `endif )
VME_slave_num;
-typedef TAdd#(VME_slave_num,`ifdef FlexBus 1 `else 0 `endif )
- FlexBus_slave_num;
-typedef TAdd#(FlexBus_slave_num,1)
- Num_Slaves;
-
+typedef TAdd#(VME_slave_num,1) Num_Fast_Slaves;
"""
axi_slave_declarations = """\
"""
pinmux_cellrule = """\
- rule connect_select_lines_pinmux;
+rule connect_select_lines_pinmux;
{0}
- endrule
+endrule
"""
return ('', 0)
return self.slow.axi_slave_idx(start, self.ifacename, count, typ)
+ def axi_fastaddr_map(self, count):
+ if not self.slow:
+ return ''
+ return self.slow.axi_fastaddr_map(self.ifacename, count)
+
def axi_addr_map(self, count):
if not self.slow:
return ''
for (name, count) in self.ifacecount:
#print "slowimport", name, self.data[name].slowimport
ret.append(self.data[name].slowimport())
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 4))
def extfastifinstance(self, *args):
ret = []
if self.is_on_fastbus(name, i):
continue
ret.append(self.data[name].extfastifinstance(name, i))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def extifinstance2(self, *args):
ret = []
for i in range(count):
iname = self.data[name].iname().format(i)
ret.append(self.data[name].extifinstance2(name, i))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def extifinstance(self, *args):
ret = []
if not self.is_on_fastbus(name, i):
continue
ret.append(self.data[name].extifinstance(name, i))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def extifdecl(self, *args):
ret = []
for (name, count) in self.ifacecount:
for i in range(count):
ret.append(self.data[name].slowifdeclmux(name, i))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def fastifdecl(self, *args):
ret = []
if self.is_on_fastbus(name, i):
continue
ret.append(self.data[name].fastifdecl(name, i))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 4))
def slowifdecl(self, *args):
ret = []
ret.append(self.data[name].slowifdecl().format(i, name))
return '\n'.join(list(filter(None, ret)))
+ def axi_fastmem_def(self, *args):
+ return self._axi_reg_def(0x50000000, *args)
+
def axi_reg_def(self, *args):
+ return self._axi_reg_def(0x00011100, *args)
+
+ def _axi_reg_def(self, start, *args):
ret = []
- start = 0x00011100 # start of AXI peripherals address
for (name, count) in self.ifacecount:
for i in range(count):
if self.is_on_fastbus(name, i):
return self._axi_num_idx(0, axi_fastslave_declarations, 'fastslave',
'fast', *args)
+ def axi_fastaddr_map(self, *args):
+ ret = []
+ for (name, count) in self.ifacecount:
+ for i in range(count):
+ if self.is_on_fastbus(name, i):
+ continue
+ ret.append(self.data[name].axi_fastaddr_map(i))
+ return '\n'.join(li(list(filter(None, ret)), 8))
+
def axi_addr_map(self, *args):
ret = []
for (name, count) in self.ifacecount:
if self.is_on_fastbus(name, i):
continue
ret.append(self.data[name].axi_addr_map(i))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def mkfast_peripheral(self, *args):
ret = []
print name, count, x
suffix = self.data[name].mksuffix(name, i)
ret.append(x.format(suffix))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def mkslow_peripheral(self, *args):
ret = []
print name, count, x
suffix = self.data[name].mksuffix(name, i)
ret.append(x.format(suffix))
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def mk_fast_connection(self, *args):
ret = []
print "txt", txt
print self.data[name].mk_connection
ret.append(txt)
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 12))
def mk_connection(self, *args):
ret = []
print "txt", txt
print self.data[name].mk_connection
ret.append(txt)
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def mk_cellconn(self):
ret = []
continue
(txt, cellcount) = res
ret.append(txt)
- ret = '\n'.join(list(filter(None, ret)))
- return pinmux_cellrule.format(ret)
+ ret = li('\n'.join(list(filter(None, ret))), 4)
+ return li(pinmux_cellrule.format(ret), 4)
def mk_pincon(self):
ret = []
continue
txt = self.data[name].mk_pincon(name, i)
ret.append(txt)
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 4))
def mk_dma_irq(self):
ret = []
cnct = list(filter(None, cnct))
ct = self.dma_count
- _cnct = ["rule rl_connect_interrupt_to_DMA;",
- " Bit #(%d) lv_interrupt_to_DMA={" % ct]
+ _cnct = ["rule rl_connect_interrupt_to_DMA;",
+ " Bit #(%d) lv_interrupt_to_DMA={" % ct]
spc = " "
spcsep = ",\n" + spc
cnct = _cnct + [spc + spcsep.join(cnct)]
cnct.append(" };")
- cnct.append(" dma.interrupt_from_peripherals(\n" + \
+ cnct.append(" dma.interrupt_from_peripherals(\n" +
" lv_interrupt_to_DMA);")
cnct.append("endrule;")
continue
txt = self.data[name].mk_ext_ifacedef(name, i)
ret.append(txt)
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 8))
def mk_plic(self):
ret = []
(txt, irq_offs) = res
ret.append(txt)
self.num_slow_irqs = irq_offs
- return '\n'.join(list(filter(None, ret)))
+ return '\n'.join(li(list(filter(None, ret)), 4))
def mk_sloirqsdef(self):
return " `define NUM_SLOW_IRQS {0}".format(self.num_slow_irqs)
from qspi import qspi, mqspi
from gpio import gpio
from rgbttl import rgbttl
+ from flexbus import flexbus
for k, v in {'uart': uart,
'rs232': rs232,
'sd': sdmmc,
'jtag': jtag,
'lcd': rgbttl,
+ 'fb': flexbus,
'gpio': gpio
}.items():
if name.startswith(k):