f24c9764a136bb22ca677271d153060cefa7be60
2 from string
import digits
5 # dictionary of properties of signals that are supported.
10 "spi_mosi" : "output",
22 # ============== common bsv templates ============ #
23 # first argument is the io-cell number being assigned.
24 # second argument is the mux value.
25 # Third argument is the signal from the pinmap file
27 rule assign_{2}_on_cell{0}(wrmux{0}=={1});
32 rule assign_{1}_on_cell{0};
36 # ============================================================
38 digits
= str.maketrans(dict.fromkeys('0123456789'))
40 for cell
in muxed_cells
:
41 pinmux
= pinmux
+ " cell" + str(cell
[0]) + "_out="
43 while(i
< len(cell
) - 1):
44 pinmux
= pinmux
+ "wrmux" + \
45 str(cell
[0]) + "==" + str(i
) + "?" + cell
[i
+ 1] + "_io:"
46 if(i
+ 2 == len(cell
) - 1):
47 pinmux
= pinmux
+ cell
[i
+ 2] + "_io"
51 pinmux
= pinmux
+ ";\n"
52 # ======================================================== #
54 # check each cell if "peripheral input/inout" then assign its wire
55 # Here we check the direction of each signal in the dictionary.
56 # We choose to keep the dictionary within the code and not user-input
57 # since the interfaces are always standard and cannot change from
58 # user-to-user. Plus this also reduces human-error as well :)
59 for i
in range(0, len(cell
) - 1):
60 temp
= cell
[i
+ 1].translate(digits
)
61 x
= dictionary
.get(temp
)
64 "ERROR: The signal : " +
66 " of pinmap.txt isn't present in the current dictionary.\
67 \nUpdate dictionary or fix-typo.")
71 mux_wire
.format(cell
[0], i
, "wr" + cell
[i
+ 1]) + "\n"
74 mux_wire
.format(cell
[0], i
, "wr" + cell
[i
+ 1] +
76 # ============================================================ #
78 # ================== Logic for dedicated pins ========= #
79 for cell
in dedicated_cells
:
80 pinmux
= pinmux
+ " cell" + \
81 str(cell
[0]) + "_out=" + cell
[1] + "_io;\n"
82 temp
= cell
[1].translate(digits
)
83 x
= dictionary
.get(temp
)
86 dedicated_wire
.format(cell
[0], "wr" + cell
[1]) + "\n"
89 dedicated_wire
.format(cell
[0], "wr" + cell
[1] + "_in") + "\n"
90 # =======================================================#