X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fbsv%2Fperipheral_gen%2Fgpio.py;h=50b9f63c3f7dd2a25885e94ddd4ebac8e37e4610;hb=9334e2230a72545dfa2f2ce3180b66546982cad0;hp=90671a569a0ec586cb639526f066be117565af6e;hpb=02eb92231842a122625b8f3ab9d861cf90d5d0c1;p=pinmux.git diff --git a/src/bsv/peripheral_gen/gpio.py b/src/bsv/peripheral_gen/gpio.py index 90671a5..50b9f63 100644 --- a/src/bsv/peripheral_gen/gpio.py +++ b/src/bsv/peripheral_gen/gpio.py @@ -4,14 +4,20 @@ from bsv.peripheral_gen.base import PBase class gpio(PBase): def slowimport(self): - return " import pinmux::*;\n" + \ - " import mux::*;\n" + \ - " import gpio::*;\n" + return "import pinmux::*;\n" + \ + "import mux::*;\n" + \ + "import gpio::*;\n" + + def extifinstance2(self, name, count): + template = "interface pad_config{0} = {1}.pad_config;" + dname = self.mksuffix(self.name, count) + return template.format(dname, name) def slowifdeclmux(self, name, count): size = len(self.peripheral.pinspecs) - return " interface GPIO_config#(%d) pad_config%d;" % \ - (size, count) + dname = self.mksuffix(self.name, count) + return "interface GPIO_config#(%d) pad_config%s;" % \ + (size, dname) def num_axi_regs32(self): return 2 @@ -30,16 +36,20 @@ class gpio(PBase): def mkslow_peripheral(self, size=0): print "gpioslow", self.peripheral, dir(self.peripheral) + print "gpioslow", self.peripheral.configs size = len(self.peripheral.pinspecs) - return " MUX#(%d) mux{0} <- mkmux();\n" % size + \ - " GPIO#(%d) gpio{0} <- mkgpio();" % size + dflt_ = "%s" % ("0" * size * 2) # default if not set in spec + dflt = self.peripheral.configs[0].get("muxconfig", dflt_) + return "MUX#(%d) mux{0} <- mkmux('b%s);\n" % (size, dflt) + \ + "GPIO#(%d) gpio{0} <- mkgpio();" % size - def mk_connection(self, count): + def mk_connection(self, name, count, fabricname, typ): print "GPIO mk_conn", self.name, count res = [] dname = self.mksuffix(self.name, count) for i, n in enumerate(['gpio' + dname, 'mux' + dname]): - res.append(PBase.mk_connection(self, count, n)) + res.append(PBase.mk_connection(self, name, count, fabricname, typ, + name_override=n)) return '\n'.join(res) def _mk_connection(self, name=None, count=0): @@ -54,10 +64,10 @@ class gpio(PBase): return name[3:] return name[4:] - def mk_cellconn(self, cellnum, name, count): + def mk_cellconn(self, name, count, cellnum): ret = [] bank = self.mksuffix(name, count) - txt = " pinmux.mux_lines.cell{0}_mux(mux{1}.mux_config.mux[{2}]);" + txt = "pinmux.mux_lines.cell{0}_mux(mux{1}.mux_config.mux[{2}]);" for p in self.peripheral.pinspecs: ret.append(txt.format(cellnum, bank, p['name'][1:])) cellnum += 1 @@ -69,12 +79,13 @@ class gpio(PBase): def pinname_outen(self, pname): return "func.gpio_out_en[{0}]".format(pname[1:]) - def mk_pincon(self, name, count): + def _mk_pincon(self, name, count, typ): #ret = [PBase.mk_pincon(self, name, count)] # special-case for gpio in, store in a temporary vector + assert typ == 'slow' ret = [] plen = len(self.peripheral.pinspecs) - template = " mkConnection({0}.{1},\n\t\t\t{2}_{1});" + template = "mkConnection({0}.{1},\n\t\t\t{2}_{1});" ps = "pinmux.peripheral_side.%s" % name n = "{0}.func.gpio".format(name) for ptype in ['out', 'out_en', 'in']: