1 from string
import digits
3 from string
import maketrans
5 maketrans
= str.maketrans
8 # ============== common bsv templates ============ #
9 # first argument is the io-cell number being assigned.
10 # second argument is the mux value.
11 # Third argument is the signal from the pinmap file
13 rule assign_{2}_on_cell{0}(wrcell{0}_mux=={1});
18 rule assign_{1}_on_cell{0};
22 # ============================================================
23 digits
= maketrans('0123456789', ' ' * 10) # delete space later
27 return "cell%s_mux" % str(idx
)
31 temp
= temp
.split('_')
33 temp
[0] = temp
[0].translate(digits
)
34 temp
[0] = temp
[0] .replace(' ', '')
41 for x
, cell
in enumerate(p
.muxed_cells
):
42 p
.pinmux
+= " // output muxer for cell idx %d\n" % x
43 p
.pinmux
+= " %s_out=" % cn(cell
[0])
44 for i
in range(0, len(cell
) - 2):
45 p
.pinmux
+= "wr%s" % cn(cell
[0]) + \
46 "==" + str(i
) + "?" + cell
[i
+ 1] + "_io:\n\t\t\t"
47 p
.pinmux
+= cell
[i
+ 2] + "_io"
49 # ======================================================== #
51 # check each cell if "peripheral input/inout" then assign its wire
52 # Here we check the direction of each signal in the dictionary.
53 # We choose to keep the dictionary within the code and not user-input
54 # since the interfaces are always standard and cannot change from
55 # user-to-user. Plus this also reduces human-error as well :)
56 for i
in range(0, len(cell
) - 1):
59 x
= ifaces
.getifacetype(temp
)
60 #print (cname, temp, x)
61 assert x
is not None, "ERROR: The signal : " + \
63 " of pinmap.txt isn't present \nin the current" + \
64 " dictionary. Update dictionary or fix-typo."
67 mux_wire
.format(cell
[0], i
, "wr" + cname
) + "\n"
70 mux_wire
.format(cell
[0], i
, "wr" + cname
+
72 # ============================================================ #
74 # ================== Logic for dedicated pins ========= #
75 for cell
in p
.dedicated_cells
:
76 p
.pinmux
+= " %s_out=%s_io;\n" % (cn(cell
[0]), cell
[1])
77 temp
= cell
[1].translate(digits
)
78 x
= ifaces
.getifacetype(temp
)
81 dedicated_wire
.format(cell
[0], "wr" + cell
[1]) + "\n"
84 dedicated_wire
.format(cell
[0], "wr" + cell
[1] + "_in") + "\n"
85 # =======================================================#