X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fbsv%2Factual_pinmux.py;h=c5644307e3d5a34c0efae188ff41427b81a81a03;hb=c68ea7590aa3aaa449cf9c4edb1ac56219ac9a92;hp=ee90986e21dcf97589bea35c4109ff59f4c2a1c3;hpb=16756efbb296c720beaa3054d6bb5a15eb28ee9c;p=pinmux.git diff --git a/src/bsv/actual_pinmux.py b/src/bsv/actual_pinmux.py index ee90986..c564430 100644 --- a/src/bsv/actual_pinmux.py +++ b/src/bsv/actual_pinmux.py @@ -24,13 +24,6 @@ dedicated_wire = ''' digits = maketrans('0123456789', ' ' * 10) # delete space later -def get_cell_bit_width(p): - max_num_cells = 0 - for cell in p.muxed_cells: - max_num_cells = max(len(cell) - 1, max_num_cells) - return int(math.log(max_num_cells + 1, 2)) - - def cn(idx): # idx is an integer return "cell%s_mux" % str(idx) @@ -69,14 +62,14 @@ def fmt(ifaces, cells, idx, suffix=None): else: cell = '' if not cell: - return '0' + return 'val0' temp = transfn(cell) x = ifaces.getifacetype(temp) if x == 'input': - return '0' # inputs don't get passed through to the out mux + return 'val0' # inputs don't get passed through to the out mux if suffix == '_outen' and x == 'out': - return "wr%s%s" % (cells[1], suffix or '') # USE GPIO FOR SELECTION - if x == 'out': # sigh hack, should be using interface_decl + return "wr%s%s" % (cells[1], suffix or '') # USE GPIO FOR SELECTION + if x == 'out': # sigh hack, should be using interface_decl suffix = '' return "wr%s%s" % (cell, suffix or '') @@ -110,13 +103,15 @@ def mkmux(p, ifaces, cell, suffix, outenmode): multiple inputs and, based on an "address" routes a given indexed input through to the (one) output """ + cellnum = cell[0] comment = 'outen' if outenmode else 'output' fmtstr = "\t\t\twr%s==%d?%s:%s\n" # mux-selector format ret = '' - ret += " // %s muxer for cell idx %s\n" % (comment, cell[0]) - ret += " %s%s=\n" % (cn(cell[0]), suffix) + ret += " // %s muxer for cell idx %s\n" % (comment, cellnum) + ret += " %s%s=\n" % (cn(cellnum), suffix) + i = 0 for i in range( - 0, (1 << p.cell_bitwidth) - 1): # full mux range (minus 1) + 0, p.get_muxwidth(cellnum) - 1): # full mux range (minus 1) comment = mkcomment(ifaces, cell, i, outenmode) cf = fmt(ifaces, cell, i, suffix) ret += fmtstr % (cn(cell[0]), i, cf, comment) @@ -147,7 +142,6 @@ def init(p, ifaces): the last one, and we do not want the "default" (last line) to be the output. """ - p.cell_bitwidth = get_cell_bit_width(p) p.pinmux = ' ' global dedicated_wire for cell in p.muxed_cells: @@ -174,7 +168,7 @@ def init(p, ifaces): continue temp = transfn(cname) x = ifaces.getifacetype(temp) - #print (cname, temp, x) + print (cname, temp, x) assert x is not None, "ERROR: The signal : " + \ str(cname) + \ " of pinmap.txt isn't present \nin the current" + \