X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fbsv%2Finterface_decl.py;h=4e16fa1349600730e4efbda7b11a8843803fbf1c;hb=48603ce2b71438af3d8fbba491e8046e56c60aaa;hp=5d3182d80c68b25c1ed8c88177d43894a551299e;hpb=aaf02ca9531349d644e059f7cac9a11fcf6d25d2;p=pinmux.git diff --git a/src/bsv/interface_decl.py b/src/bsv/interface_decl.py index 5d3182d..4e16fa1 100644 --- a/src/bsv/interface_decl.py +++ b/src/bsv/interface_decl.py @@ -20,6 +20,7 @@ class Pin(object): """ def __init__(self, name, + name_ = None, ready=True, enabled=True, io=False, @@ -27,6 +28,7 @@ class Pin(object): bitspec=None, outenmode=False): self.name = name + self.name_ = name_ self.ready = ready self.enabled = enabled self.io = io @@ -41,6 +43,18 @@ class Pin(object): Action io0_inputval (Bit#(1) in); """ + def ifacepfmt(self, fmtfn): + res = ' ' + status = [] + res += "interface " + name = fmtfn(self.name_) + if self.action: + res += "Put" + else: + res += "Get" + res += "#(%s) %s;" % (self.bitspec, name) + return res + def ifacefmt(self, fmtfn): res = ' ' status = [] @@ -134,6 +148,7 @@ class Interface(PeripheralIface): del _p['outen'] for psuffix in ['out', 'outen', 'in']: # changing the name (like sda) to (twi_sda_out) + _p['name_'] = "%s_%s" % (p['name'], psuffix) _p['name'] = "%s_%s" % (self.pname(p['name']), psuffix) _p['action'] = psuffix != 'in' self.pins.append(Pin(**_p)) @@ -142,6 +157,7 @@ class Interface(PeripheralIface): #{'name': 'twi_sda_in', 'action': False} # NOTice - outen key is removed else: + _p['name_'] = p['name'] _p['name'] = self.pname(p['name']) self.pins.append(Pin(**_p)) @@ -213,10 +229,17 @@ class Interface(PeripheralIface): res += '\n' return '\n' + res + def ifacepfmt(self, *args): + res = '\n'.join(map(self.ifacepfmtdecpin, self.pins)).format(*args) + return '\n' + res # pins is a list + def ifacefmt(self, *args): res = '\n'.join(map(self.ifacefmtdecpin, self.pins)).format(*args) return '\n' + res # pins is a list + def ifacepfmtdecfn(self, name): + return name + def ifacefmtdecfn(self, name): return name # like: uart @@ -237,6 +260,9 @@ class Interface(PeripheralIface): return pin.wirefmt(self.ifacefmtoutfn, self.ifacefmtinfn, self.ifacefmtdecfn2) + def ifacepfmtdecpin(self, pin): + return pin.ifacepfmt(self.ifacepfmtdecfn) + def ifacefmtdecpin(self, pin): return pin.ifacefmt(self.ifacefmtdecfn) @@ -298,6 +324,16 @@ class Interfaces(InterfacesBase, PeripheralInterfaces): bf = self.data[name].busfmt(i) f.write(bf) + def ifacepfmt(self, f, *args): + comment = ''' + // interface declaration between {0} and pinmux + (*always_ready,always_enabled*) + interface PeripheralSide{0};''' + for (name, count) in self.ifacecount: + f.write(comment.format(name.upper())) + f.write(self.data[name].ifacepfmt(0)) + f.write("\n endinterface\n") + def ifacefmt(self, f, *args): comment = ''' // interface declaration between %s-{0} and pinmux'''