Skip to content

Commit 525c7e2

Browse files
committed
back.rtlil: do not translate empty subfragments at all.
It was thought previously (by me) that adding a wire that does nothing to an empty subfragment is enough to prevent it from being treated as a blackbox. This is enough for Yosys but not Vivado. Another workaround could probably be used that satisfies both, but instead let's just not translate any empty subfragments. This doesn't account for the case of the empty toplevel, but that does not seem worth addressing. Fixes #899.
1 parent 4e07832 commit 525c7e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

amaranth/back/rtlil.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -832,11 +832,6 @@ def _convert_fragment(builder, fragment, name_map, hierarchy):
832832
lhs_compiler = _LHSValueCompiler(compiler_state)
833833
stmt_compiler = _StatementCompiler(compiler_state, rhs_compiler, lhs_compiler)
834834

835-
# If the fragment is completely empty, add a dummy wire to it, or Yosys will interpret
836-
# it as a black box by default (when read as Verilog).
837-
if not fragment.ports and not fragment.statements and not fragment.subfragments:
838-
module.wire(1, name="$empty_module_filler")
839-
840835
# Register all signals driven in the current fragment. This must be done first, as it
841836
# affects further codegen; e.g. whether \sig$next signals will be generated and used.
842837
for domain, signal in fragment.iter_drivers():
@@ -861,6 +856,12 @@ def _convert_fragment(builder, fragment, name_map, hierarchy):
861856
# name) names.
862857
memories = OrderedDict()
863858
for subfragment, sub_name in fragment.subfragments:
859+
if not (subfragment.ports or subfragment.statements or subfragment.subfragments):
860+
# If the fragment is completely empty, skip translating it, otherwise synthesis
861+
# tools (including Yosys and Vivado) will treat it as a black box when it is
862+
# loaded after conversion to Verilog.
863+
continue
864+
864865
if sub_name is None:
865866
sub_name = module.anonymous()
866867

0 commit comments

Comments
 (0)