From: Jacob Lifshay Date: Wed, 13 Oct 2021 00:55:19 +0000 (-0700) Subject: format code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fcecc0062397d0893dd5032275c347fbfe6bc7c5;p=ieee754fpu.git format code --- diff --git a/src/ieee754/part/layout_experiment.py b/src/ieee754/part/layout_experiment.py index e76e85b9..b4e7de15 100644 --- a/src/ieee754/part/layout_experiment.py +++ b/src/ieee754/part/layout_experiment.py @@ -33,9 +33,9 @@ def layout(elwid, signed, part_counts, lane_shapes=None, fixed_width=None): # https://bugs.libre-soc.org/show_bug.cgi?id=713#c67 if lane_shapes is None: assert fixed_width is not None, \ - "both fixed_width and lane_shapes cannot be None" + "both fixed_width and lane_shapes cannot be None" lane_shapes = {i: fixed_width // part_counts[i] for i in part_counts} - print ("lane_shapes", fixed_width, lane_shapes) + print("lane_shapes", fixed_width, lane_shapes) # identify if the lane_shapes is a mapping (dict, etc.) # if not, then assume that it is an integer (width) that # needs to be requested across all partitions @@ -43,38 +43,38 @@ def layout(elwid, signed, part_counts, lane_shapes=None, fixed_width=None): lane_shapes = {i: lane_shapes for i in part_counts} # compute a set of partition widths cpart_wid = [-lane_shapes[i] // c for i, c in part_counts.items()] - print ("cpart_wid", cpart_wid, "part_counts", part_counts) + print("cpart_wid", cpart_wid, "part_counts", part_counts) cpart_wid = -min(cpart_wid) part_count = max(part_counts.values()) # calculate the minumum width required width = cpart_wid * part_count - print ("width", width, cpart_wid, part_count) - if fixed_width is not None: # override the width and part_wid + print("width", width, cpart_wid, part_count) + if fixed_width is not None: # override the width and part_wid assert width < fixed_width, "not enough space to fit partitions" part_wid = fixed_width // part_count assert part_wid * part_count == fixed_width, \ - "calculated width not aligned multiples" + "calculated width not aligned multiples" width = fixed_width - print ("part_wid", part_wid, "count", part_count) + print("part_wid", part_wid, "count", part_count) else: # go with computed width part_wid = cpart_wid # create the breakpoints dictionary. # do multi-stage version https://bugs.libre-soc.org/show_bug.cgi?id=713#c34 # https://stackoverflow.com/questions/26367812/ - dpoints = defaultdict(list) # if empty key, create a (empty) list + dpoints = defaultdict(list) # if empty key, create a (empty) list for i, c in part_counts.items(): def add_p(p): - dpoints[p].append(i) # auto-creates list if key non-existent + dpoints[p].append(i) # auto-creates list if key non-existent for start in range(0, part_count, c): - add_p(start * part_wid) # start of lane - add_p(start * part_wid + lane_shapes[i]) # start of padding + add_p(start * part_wid) # start of lane + add_p(start * part_wid + lane_shapes[i]) # start of padding # do not need the breakpoints at the very start or the very end dpoints.pop(0, None) dpoints.pop(width, None) plist = list(dpoints.keys()) plist.sort() - print ("dpoints") + print("dpoints") pprint(dict(dpoints)) # second stage, add (map to) the elwidth==i expressions. # TODO: use nmutil.treereduce? @@ -90,15 +90,15 @@ def layout(elwid, signed, part_counts, lane_shapes=None, fixed_width=None): bitp[i] = 0 for p, elwidths in dpoints.items(): if i in elwidths: - bitpos = plist.index(p) - bitp[i] |= 1<< bitpos + bitpos = plist.index(p) + bitp[i] |= 1 << bitpos # fourth stage: determine which partitions are 100% unused. # these can then be "blanked out" - bmask = (1<