From c9babac880a83acaab2a088c00b6562b937dcf3b Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 6 Nov 2021 15:33:33 +0000 Subject: [PATCH] convert to python3 --- src/parse.py | 4 ++-- src/spec/base.py | 2 +- src/spec/gen.py | 6 ++--- src/spec/ifaceprint.py | 50 +++++++++++++++++++++--------------------- src/spec/interfaces.py | 8 +++---- src/spec/ls180.py | 36 +++++++++++++++--------------- 6 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/parse.py b/src/parse.py index 8d67b01..32a0682 100644 --- a/src/parse.py +++ b/src/parse.py @@ -61,7 +61,7 @@ class Parse(object): if line1[i].startswith('pwm'): line1[i] = 'pwm%s_out' % line1[i][4:] line1 = [line1[0]] + line1[3:] - print "line", line1 + print ("line", line1) self.muxed_cells.append(line1) self.pinnumbers = sorted(self.pinnumbers) @@ -115,7 +115,7 @@ class Parse(object): def get_max_cell_bitwidth(self): max_num_cells = 0 for cell in self.muxed_cells: - print cell + print (cell) max_num_cells = max(len(cell) - 1, max_num_cells) return int(math.log(max_num_cells + 1, 2)) diff --git a/src/spec/base.py b/src/spec/base.py index 3207b40..dc2cf0c 100644 --- a/src/spec/base.py +++ b/src/spec/base.py @@ -18,7 +18,7 @@ class PinSpec(Pinouts): bankspec = OrderedDict() self.offs = 0 pkeys = self.pinbanks.keys() - print self.pinbanks + print (self.pinbanks) for kn in pkeys: bankspec[kn] = self.offs self.offs += self.pinbanks[kn] diff --git a/src/spec/gen.py b/src/spec/gen.py index 492ba53..6a8518f 100644 --- a/src/spec/gen.py +++ b/src/spec/gen.py @@ -72,14 +72,14 @@ def specgen(of, pth, pinouts, bankspec, muxwidths, pinbanks, fixedpins, # truly dreadful way to work out the max mux size... for k in pks: for (sz, bname) in bankpins: - print "keys", k, sz, bname + print ("keys", k, sz, bname) if k >= sz: - print "found", bname + print ("found", bname) muxentries[k] = muxwidths[bname] cellbank[k] = bname break - print muxentries + print (muxentries) # write out the mux... with open(os.path.join(pth, 'pinmap.txt'), 'w') as g: for k in pks: diff --git a/src/spec/ifaceprint.py b/src/spec/ifaceprint.py index 4eac66f..8440ee5 100644 --- a/src/spec/ifaceprint.py +++ b/src/spec/ifaceprint.py @@ -88,13 +88,13 @@ def create_sv(fname, pins): woffs = scale*40#-width/2 hoffs = scale*40#-height/2 - nepads = bondmap['N'].keys() + nepads = list(bondmap['N'].keys()) nepads.sort() - wepads = bondmap['W'].keys() + wepads = list(bondmap['W'].keys()) wepads.sort() - eepads = bondmap['E'].keys() + eepads = list(bondmap['E'].keys()) eepads.sort() - sepads = bondmap['S'].keys() + sepads = list(bondmap['S'].keys()) sepads.sort() owoffs = woffs + (width/2) - len(nepads)/2 * outerscale @@ -442,7 +442,7 @@ def find_fn(fname, names): def map_name(pinmap, fn, fblower, pin, rename): if not rename: if pin[:-1].isdigit(): - print "map name digit", pin, fn, fblower + print ("map name digit", pin, fn, fblower) if fn in ['PWM', 'EINT', 'VDD', 'VSS']: return fn.lower() + pin.lower() if fn == 'GPIO': @@ -455,8 +455,8 @@ def map_name(pinmap, fn, fblower, pin, rename): pk = '%s%s_out' % (fblower, pin[:-1]) else: pk = '%s_%s' % (fblower, pin[:-1]) - print "map name", pk, fblower, pinmap.has_key(pk) - if not pinmap.has_key(pk): + print ("map name", pk, fblower, pk in pinmap) + if not pk in pinmap: return pin.lower() remapped = pinmap[pk] uscore = remapped.find('_') @@ -487,7 +487,7 @@ def python_pindict(of, pinmap, pins, function_names, dname, remap): of.write("\n ") count = 0 of.write("]\n") - print " dict %s" % dname, a, n, pingroup + print (" dict %s" % dname, a, n, pingroup) of.write("\n\n") return res @@ -503,20 +503,20 @@ def python_dict_fns(of, pinmap, pins, function_names): fnidx = list(fns.keys()) fnidx.sort(key=fnsplit) - print "python fnames", function_names - print "python speckeys", pins.byspec.keys() - print "python dict fns", dir(pins.gpio) - print pins.gpio.pinfn('', '') - print pins.pwm.pinfn('', '') - print pins.sdmmc.pinfn('', '') - print "by spec", pins.byspec - print pinmap + print ("python fnames", function_names) + print ("python speckeys", pins.byspec.keys()) + print ("python dict fns", dir(pins.gpio)) + print (pins.gpio.pinfn('', '')) + print (pins.pwm.pinfn('', '')) + print (pins.sdmmc.pinfn('', '')) + print ("by spec", pins.byspec) + print (pinmap) pd = python_pindict(of, {}, pins, function_names, 'pindict', False) ld = python_pindict(of, pinmap, pins, function_names, 'litexdict', True) - print "pd", pd - print "ld", ld + print ("pd", pd) + print ("ld", ld) # process results and create name map litexmap = OrderedDict() for k in pd.keys(): @@ -528,7 +528,7 @@ def python_dict_fns(of, pinmap, pins, function_names): if k in ['eint', 'pwm', 'gpio', 'vdd', 'vss']: # sigh lname = "%s_%s" % (k, lname) litexmap[pname] = lname - print "litexmap", litexmap + print ("litexmap", litexmap) of.write("litexmap = {\n") for k, v in litexmap.items(): of.write("\t'%s': '%s',\n" % (k, v)) @@ -584,10 +584,10 @@ def check_functions(of, title, bankspec, fns, pins, required, eint, pwm, of.write("# Pinmap for %s\n\n" % title) - print "fn_idx", fnidx - print "fns", fns - print "fnspec", pins.fnspec.keys() - print "required", required + print ("fn_idx", fnidx) + print ("fns", fns) + print ("fnspec", pins.fnspec.keys()) + print ("required", required) for name in required: of.write("## %s\n\n" % name) if descriptions and name in descriptions: @@ -649,10 +649,10 @@ def check_functions(of, title, bankspec, fns, pins, required, eint, pwm, removedcount += 1 of.write("* %s %d %s%d/%d\n" % (fname, pin_, bank, pin, mux)) - print fns + print (fns) if removedcount != count: if fname is None: - print "no match between required and available pins" + print ("no match between required and available pins") else: print ("not all found", name, removedcount, count, title, found, fns[fname]) diff --git a/src/spec/interfaces.py b/src/spec/interfaces.py index 744f803..f5ecf48 100644 --- a/src/spec/interfaces.py +++ b/src/spec/interfaces.py @@ -68,7 +68,7 @@ class PinGen(object): rev=False): bank = offs[0] pf = self.pinfn(suffix, bank) - print "pf", suffix, bank, pf + print ("pf", suffix, bank, pf) pingroup, gangedgroup, clock = pf if clock: self.pinouts.clocks[self.fname] = clock @@ -79,13 +79,13 @@ class PinGen(object): if start and limit: # limit turns into an offset from start limit = start + limit sk = "%s:%s" % (self.fname, str(suffix)) - print "pingroup pre", sk, pingroup + print ("pingroup pre", sk, pingroup) pingroup = pingroup[start:limit] # see comment in spec.pinfunctions if rev: # reverse order of pingroup pingroup.reverse() - print "pingroup post", sk, pingroup - if self.pinouts.byspec.has_key(sk): + print ("pingroup post", sk, pingroup) + if sk in self.pinouts.byspec: self.pinouts.byspec[sk] += pingroup else: self.pinouts.byspec[sk] = deepcopy(pingroup) diff --git a/src/spec/ls180.py b/src/spec/ls180.py index 6c1e127..35a649d 100644 --- a/src/spec/ls180.py +++ b/src/spec/ls180.py @@ -116,7 +116,7 @@ def pinspec(): #ps.mquadspi("1", ('S', 0), 0) - print "ps clocks", ps.clocks + print ("ps clocks", ps.clocks) # Scenarios below can be spec'd out as either "find first interface" # by name/number e.g. SPI1, or as "find in bank/mux" which must be @@ -163,8 +163,8 @@ def pinparse(psp, pinspec): pinmap = {} litexmap = {} - print p.muxed_cells - print p.muxed_cells_bank + print (p.muxed_cells) + print (p.muxed_cells_bank) ps = [''] * 32 pn = [''] * 32 @@ -185,7 +185,7 @@ def pinparse(psp, pinspec): padnum = int(padnum) start = p.bankstart[bank] banknum = padnum - start - print "bank", bank, banknum, "padname", name, padnum, x + print ("bank", bank, banknum, "padname", name, padnum, x) padbank = pads[bank] pad = None # VSS @@ -218,7 +218,7 @@ def pinparse(psp, pinspec): #name = 'p_sys_rst_1' pad = [name, name, name] padbank[banknum] = name - print "sys_rst add", bank, banknum, name + print ("sys_rst add", bank, banknum, name) name = None elif name == 'sys_pllclk': name = None # ignore @@ -235,7 +235,7 @@ def pinparse(psp, pinspec): pad = [name, name2, name2] #if name: # iopads.append([pname, name, name]) - print "sys pad", name + print ("sys pad", name) # SPI Card elif name.startswith('mspi0') or name.startswith('mspi1'): domain = 'MSPI' @@ -388,18 +388,18 @@ def pinparse(psp, pinspec): fn, name = orig_name.split("_") if domain == 'PWM': name = fn[3:] - print psp.byspec + print (psp.byspec) spec = None for k in psp.byspec.keys(): if k.startswith(domain): spec = psp.byspec[k] - print "spec found", domain, spec + print ("spec found", domain, spec) assert spec is not None found = None for pname in spec: if pname.lower().startswith(name): found = pname - print "found spec", found + print ("found spec", found) assert found is not None # whewwww. add the direction onto the pad spec list dirn = found[-1] @@ -423,24 +423,24 @@ def pinparse(psp, pinspec): iopads.append([name, name2, name2, "-"]) nc_idx += 1 - print p.bankstart + print (p.bankstart) pprint(psp.clocks) - print - print "N pads", pn - print "S pads", ps - print "E pads", pe - print "W pads", pw + print() + print ("N pads", pn) + print ("S pads", ps) + print ("E pads", pe) + print ("W pads", pw) # do not want these del clocks['SYS'] del domains['SYS'] - print "chip domains (excluding sys-default)" + print ("chip domains (excluding sys-default)") pprint(domains) - print "chip clocks (excluding sys-default)" + print ("chip clocks (excluding sys-default)") pprint(clocks) - print "pin spec" + print ("pin spec") pprint(psp.byspec) chip = { -- 2.30.2