Skip to content

Commit 6914b30

Browse files
Pinmux combine logic now uses selectors
1 parent 4561ed6 commit 6914b30

4 files changed

Lines changed: 53 additions & 14 deletions

File tree

python-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ packaging
77
anytree
88
hjson
99
mako
10+
mypy
11+
pydantic
1012
pyyaml
1113
wheel
1214
toml

rtl/system/pinmux.sv

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rtl/templates/pinmux.sv.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ module pinmux (
171171
% endfor
172172

173173
// Combining inputs for combinable inouts
174-
% for block_input, inst, combine_pins, combine_type in combine_list:
174+
% for block_input, inst, combine_pins, combine_pin_selectors, combine_type in combine_list:
175175
assign ${block_input}_o[${inst}] =
176176
% for idx, pin in enumerate(combine_pins):
177-
${pin}${';' if idx == len(combine_pins)-1 else ' &&' if combine_type == 'and' else ' ||'}
177+
(${pin}_sel == ${combine_pin_selectors[idx]} ? ${pin} : ${'1' if combine_type == 'and' else '0'})${';' if idx == len(combine_pins)-1 else ' &' if combine_type == 'and' else ' |'}
178178
% endfor
179179
% endfor
180180
endmodule

util/top_gen.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ def get_pin(name: str) -> Pin:
194194
io.type == BlockIoType.INOUT,
195195
)
196196
)
197+
for block in config.blocks:
198+
for io in block.ios:
197199
if (
198200
io.type == BlockIoType.INOUT
199201
and io.combine != BlockIoCombine.MUX
@@ -207,8 +209,37 @@ def get_pin(name: str) -> Pin:
207209
for inst_idx, pins in enumerate(io.pins[0]):
208210
input_name = block.name + "_" + io.name
209211
combine_pins = pins
212+
combine_pin_selectors = []
213+
for pin_name in combine_pins:
214+
pin = get_pin(pin_name)
215+
for sel_idx, block_output in enumerate(
216+
pin.block_outputs
217+
):
218+
if block_output[3] != "":
219+
print(
220+
"Combining indexed pins is currently "
221+
+ "unsupported."
222+
)
223+
exit()
224+
if block_output[0] is block.name and (
225+
block_output[1] is io.name
226+
and block_output[2] is inst_idx
227+
):
228+
combine_pin_selectors.append(
229+
1 << (sel_idx + 1)
230+
)
231+
break
232+
if len(combine_pins) != len(combine_pin_selectors):
233+
print("Could not fill combine pin selectors properly.")
234+
exit()
210235
combine_list.append(
211-
(input_name, inst_idx, combine_pins, io.combine)
236+
(
237+
input_name,
238+
inst_idx,
239+
combine_pins,
240+
combine_pin_selectors,
241+
io.combine,
242+
)
212243
)
213244

214245
output_list: list[
@@ -241,7 +272,13 @@ def get_pin(name: str) -> Pin:
241272
pinmux_spec = ("rtl/templates/pinmux.sv.tpl", "rtl/system/pinmux.sv")
242273
pinmux_doc_spec = ("doc/ip/pinmux.md.tpl", "doc/ip/pinmux.md")
243274

244-
specs = [xbar_spec, sonata_xbar_spec, pkg_spec, pinmux_spec, pinmux_doc_spec]
275+
specs = [
276+
xbar_spec,
277+
sonata_xbar_spec,
278+
pkg_spec,
279+
pinmux_spec,
280+
pinmux_doc_spec,
281+
]
245282

246283
for template_file, output_file in specs:
247284
print("Generating from template: " + template_file)

0 commit comments

Comments
 (0)