mkConnection (bridge.axi4_lite_master, slow_fabric.v_from_masters [0]);
/*======= Slave connections to AXI4Lite fabric =========*/
- `ifdef UART0
- mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(Uart0_slave_num))],
- uart0.slave_axi_uart);
- `endif
- `ifdef UART1
- mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(Uart1_slave_num))],
- uart1.slave_axi_uart);
- `endif
+{6}
`ifdef CLINT
mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(CLINT_slave_num))],
clint.axi4_slave);
mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(Plic_slave_num))],
plic.axi4_slave_plic); //
`endif
- `ifdef I2C0
- mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(I2c0_slave_num))],
- i2c0.slave_i2c_axi);
- `endif
- `ifdef I2C1
- mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(I2c1_slave_num))],
- i2c1.slave_i2c_axi); //
- `endif
`ifdef QSPI0
mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(Qspi0_slave_num))],
qspi0.slave);
class PBase(object):
- pass
+ def __init__(self, name):
+ self.name = name
def axibase(self, name, ifacenum):
name = name.upper()
def mkslow_peripheral(self):
return ''
+ def mk_connection(self, count):
+ aname = self.axi_slave_name(self.name, count)
+ txt = " mkConnection (slow_fabric.v_to_slaves\n" + \
+ " [fromInteger(valueOf({1}))],\n" + \
+ " {0});"
+
+ con = self._mk_connection().format(count, aname)
+ if not con:
+ return ''
+ return txt.format(con, aname)
+
+ def _mk_connection(self):
+ return ''
+
class uart(PBase):
- def __init__(self):
- PBase.__init__(self)
def slowimport(self):
return " import Uart16550 :: *;"
" mkUart16550(clocked_by uart_clock,\n" + \
" reset_by uart_reset, sp_clock, sp_reset);"
+ def _mk_connection(self):
+ return "uart{0}.slave_axi_uart"
+
+
class rs232(PBase):
- def __init__(self):
- PBase.__init__(self)
def slowimport(self):
return " import Uart_bs::*;\n" + \
" mkUart_bs(clocked_by sp_clock,\n" + \
" reset_by sp_reset, sp_clock, sp_reset);"
+ def _mk_connection(self):
+ return "uart{0}.slave_axi_uart"
+
class twi(PBase):
- def __init__(self):
- PBase.__init__(self)
def slowimport(self):
return " import I2C_top :: *;"
def mkslow_peripheral(self):
return " I2C_IFC i2c{0} <- mkI2CController();"
+ def _mk_connection(self):
+ return "i2c{0}.slave_i2c_axi"
+
class qspi(PBase):
- def __init__(self):
- PBase.__init__(self)
def slowimport(self):
return " import qspi :: *;"
def mkslow_peripheral(self):
return " Ifc_qspi qspi{0} <- mkqspi();"
+ def _mk_connection(self):
+ return "qspi{0}.slave"
+
class pwm(PBase):
- def __init__(self):
- PBase.__init__(self)
def slowimport(self):
return " import pwm::*;"
class gpio(PBase):
- def __init__(self):
- PBase.__init__(self)
def slowimport(self):
return " import pinmux::*;\n" + \
self.slow = None
slow = slowfactory.getcls(ifacename)
if slow:
- self.slow = slow()
- for fname in ['slowimport', 'slowifdecl', 'mkslow_peripheral']:
+ self.slow = slow(ifacename)
+ for fname in ['slowimport', 'slowifdecl', 'mkslow_peripheral',
+ 'mk_connection']:
fn = CallFn(self, fname)
setattr(self, fname, types.MethodType(fn, self))
ret.append(self.data[name].mkslow_peripheral().format(i))
return '\n'.join(list(filter(None, ret)))
+ def mk_connection(self, *args):
+ ret = []
+ for (name, count) in self.ifacecount:
+ for i in range(count):
+ txt = self.data[name].mk_connection(i)
+ ret.append(txt)
+ return '\n'.join(list(filter(None, ret)))
+
class PFactory(object):
def getcls(self, name):
slavedecl = ifaces.axi_slave_idx()
fnaddrmap = ifaces.axi_addr_map()
mkslow = ifaces.mkslow_peripheral()
+ mkcon = ifaces.mk_connection()
with open(slow, "w") as bsv_file:
bsv_file.write(template.format(imports, ifdecl, regdef, slavedecl,
- fnaddrmap, mkslow))
+ fnaddrmap, mkslow, mkcon))
def write_bus(bus, p, ifaces):