# ######## Generate bus transactors ################
gpiocfg = '\t\tinterface GPIO_config#({4}) bank{3}_config\n;' \
'\t\tinterface AXI4_Lite_Slave_IFC#({0},{1},{2}) bank{3}_slave;'
- muxcfg = '\t\tinterface MUX_config#({4}) muxb{3}_config;\n' \
- '\t\tinterface AXI4_Lite_Slave_IFC#({0},{1},{2}) muxb{3}_slave;'
+ muxcfg = '\t\tinterface MUX_config#({4}) muxb{3}_config;\n' \
+ '\t\tinterface AXI4_Lite_Slave_IFC#({0},{1},{2}) muxb{3}_slave;'
gpiodec = '\tGPIO#({0} mygpio{1} <- mkgpio();'
- muxdec = '\tMUX#({0} mymux{1} <- mkgpio();'
+ muxdec = '\tMUX#({0} mymux{1} <- mkgpio();'
gpioifc = '\tinterface bank{0}_config=mygpio{0}.pad_config;\n' \
'\tinterface bank{0}A_slave=mygpio{0}.axi_slave;'
- muxifc = '\tinterface muxb{0}_config=mymux{0}.pad_config;\n' \
- '\tinterface muxb{0}A_slave=mymux{0}.axi_slave;'
+ muxifc = '\tinterface muxb{0}_config=mymux{0}.pad_config;\n' \
+ '\tinterface muxb{0}A_slave=mymux{0}.axi_slave;'
with open(bvp, 'w') as bsv_file:
# assume here that all muxes have a 1:1 gpio
cfg = []
decl = []
idec = []
- iks = ifaces.keys()
- iks.sort()
+ iks = sorted(ifaces.keys())
for iname in iks:
- if not iname.startswith('gpio'): # TODO: declare other interfaces
+ if not iname.startswith('gpio'): # TODO: declare other interfaces
continue
bank = iname[4:]
ifc = ifaces[iname]
npins = len(ifc.pinspecs)
cfg.append(gpiocfg.format(p.ADDR_WIDTH, p.DATA_WIDTH,
- 0, # USERSPACE
- bank, npins))
+ 0, # USERSPACE
+ bank, npins))
cfg.append(muxcfg.format(p.ADDR_WIDTH, p.DATA_WIDTH,
- 0, # USERSPACE
- bank, npins))
+ 0, # USERSPACE
+ bank, npins))
decl.append(gpiodec.format(npins, bank))
decl.append(muxdec .format(npins, bank))
idec.append(gpioifc.format(bank))
print dir(ifaces['gpioa'])
print ifaces['gpioa'].pinspecs
gpiodecl = '\n'.join(decl) + '\n' + '\n'.join(idec)
- gpiocfg = '\n'.join(cfg)
+ gpiocfg = '\n'.join(cfg)
bsv_file.write(axi4_lite.format(gpiodecl, gpiocfg))
# ##################################################
for pnum in range(npins):
args.append("sel%d" % pnum)
args.append("pin%d" % pnum)
- #for pnum in range(nfns):
+ # for pnum in range(nfns):
# args.append("fn%d" % pnum)
args = ','.join(args)
x = x.format(args)
return func(args[0], args[1], args[2], args[3])
return wrapper
+
class FnCls(object):
def __init__(self):
self.attrs = ['uart', 'i2c', 'spi', 'gpio']
def getfn(self, idx):
return getattr(self, self.attrs[idx])
+
@block
def muxer(clk, p, ifaces, args):
muxes = []
inputs.append(fncls.i2c.out)
inputs.append(fncls.spi.out)
inputs.append(fncls.gpio.out)
- #for i in range(4):
- #inputs.append(fncls.getfn(i).out)
+ # for i in range(4):
+ # inputs.append(fncls.getfn(i).out)
for i in range(len(muxes)):
mux = muxes[i]
mux_inst.convert(hdl="Verilog", initial_values=True, testbench=False)
-
-
if __name__ == '__main__':
fncls = FnCls()
num_fns = 4