+ def busfmt(self, *args):
+ """ this function creates a bus "ganging" system based
+ on input from the {interfacename}.txt file.
+ only inout pins that are under the control of the
+ interface may be "ganged" together.
+ """
+ if not self.ganged:
+ return ''
+ #print self.ganged
+ res = []
+ for (k, pnames) in self.ganged.items():
+ name = self.pname('%senable' % k).format(*args)
+ decl = 'Bit#(1) %s = 0;' % name
+ res.append(decl)
+ ganged = []
+ for p in self.pinspecs:
+ if p['name'] not in pnames:
+ continue
+ pname = self.pname(p['name']).format(*args)
+ if p.get('outen') is True:
+ outname = self.ifacefmtoutfn(pname)
+ ganged.append("%s_outen" % outname) # match wirefmt
+
+ gangedfmt = '{%s} = duplicate(%s);'
+ res.append(gangedfmt % (',\n '.join(ganged), name))
+ return '\n'.join(res) + '\n\n'
+