Skip to content

back.rtlil: Emit proper source location for port-signals. #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion amaranth/back/rtlil.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def __init__(self, builder, netlist, module, name_map, empty_checker):
self.memories = {} # cell idx -> MemoryInfo
self.value_names = {} # value -> signal or port name
self.value_attrs = {} # value -> dict
self.value_src_loc = {} # value -> source location
self.sigport_wires = {} # signal or port name -> (wire, value)
self.driven_sigports = set() # set of signal or port name
self.nets = {} # net -> (wire name, bit idx)
Expand Down Expand Up @@ -372,6 +373,7 @@ def emit_signal_wires(self):
# the design is flattened) will do that anyway, so it doesn't matter.
attrs = self.value_attrs.setdefault(value, {})
attrs.update(signal.attrs)
self.value_src_loc[value] = signal.src_loc

for repr in signal._value_repr:
if repr.path == () and isinstance(repr.format, _repr.FormatEnum):
Expand Down Expand Up @@ -399,7 +401,8 @@ def emit_port_wires(self):
signed = named_signals[name].signed
wire = self.builder.wire(width=len(value), signed=signed,
port_id=port_id, port_kind=flow.value,
name=name, attrs=self.value_attrs.get(value, {}))
name=name, attrs=self.value_attrs.get(value, {}),
src=_src(self.value_src_loc.get(value)))
self.sigport_wires[name] = (wire, value)
if flow == _nir.ModuleNetFlow.Output:
continue
Expand Down