Skip to content

Netlist #675

Open
desmonddak wants to merge 68 commits into
intel:mainfrom
desmonddak:netlist_pre
Open

Netlist #675
desmonddak wants to merge 68 commits into
intel:mainfrom
desmonddak:netlist_pre

Conversation

@desmonddak

Copy link
Copy Markdown
Contributor

Description & Motivation

This is a netlist synthesizer that produces a netlist for the generated design in an extension of the Yosys output netlist format.
It provides routines for emitting just the hierarchy and ports ("slim" mode) as well as fully expanded and has hooks for even more incremental expansion modes.

Related Issue(s)

None.

Testing

There is a suite of tests that compare the netlist and its names against the SystemVerilog output. This netlist depended on the last central_naming branch to assure that signals in both formats had identical names.

Backwards-compatibility

Is this a breaking change that will not be backwards-compatible? If yes, how so?

No.

Documentation

Does the change require any updates to documentation? If so, where? Are they included?

This is a minor API addition (Module.generateNetlist()) but we will add more documentation and examples of the format, etc.
It will have some options as well, such as multiFile, which should parallel the generateSynth() API.

desmonddak and others added 30 commits April 17, 2026 08:30
Clarify comment

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This aligns central_naming with the simplified naming approach already
adopted by all downstream branches (module_services, netlist, source_debug,
systemc_trace, fst-writer).

Changes:
- Remove Namer._instanceNames cache field
- Remove Namer.instanceNameOf(Module) method
- Update synthesizers to use Namer.allocateName(String) directly
- Remove destination tracking from _BusSubsetForStructSlice

Benefit: Eliminates duplication across 5+ branches, making each branch
truly orthogonal and mergeable without conflicts.

Trade-off: Instance names no longer cached across synthesis passes, but all
downstreams already use this simpler approach.
# Conflicts:
#	tool/gh_codespaces/install_dart.sh
instanceNameOf(Module) allocates a collision-free instance name on the
first call and returns the cached result thereafter.  The _instanceNames
Map is keyed by Module.instanceNameKey so repeated synthesis passes over
the same hierarchy always produce stable names.

This method belongs in central_naming because it is pure naming
infrastructure with no dependency on any feature branch.
- Update comment: 'allocateName' → 'instanceNameOf'
- Add 'submodule instance names are stable across repeated definitions'
  test (the canonical 'run synthesis twice, same names' regression test)

Both belong here since they directly exercise Namer.instanceNameOf,
which is now defined in central_naming.
Add regression test for _BusSubsetForStructSlice.instanceNameKey.
Each SynthModuleDefinition pass creates fresh _BusSubsetForStructSlice
instances for any submodule with a LogicStructure output port.  Without
the instanceNameKey override those instances use 'this' as the cache key,
so the namer allocates a new suffix every pass ('struct_slice' → 'struct_slice_0').
Restoring _destination and overriding instanceNameKey => _destination pins
the cache to the stable destination Logic, keeping names consistent.

Fixes: _BusSubsetForStructSlice._destination removed in 249b210.
Records which Logic the namer chose as the source of each signal name
(an additive reverse map; does not influence naming). Lets source-trace
and cross-probe callers attribute a merged net to its declared signal
rather than an arbitrary internal signal that merged into the same net.
Comment thread lib/src/examples/filter_bank_modules.dart Outdated
Comment thread lib/src/examples/filter_bank_modules.dart Outdated
Comment thread lib/src/module.dart
Comment thread lib/src/synthesizers/netlist/netlist_synthesizer.dart Outdated
Comment thread lib/src/synthesizers/netlist/netlist_synthesizer.dart
Comment thread lib/src/synthesizers/netlist/netlist_synthesizer.dart Outdated
Comment thread lib/src/synthesizers/netlist/netlist_synthesizer.dart
Comment thread lib/src/synthesizers/netlist/netlist_utils.dart Outdated
Comment thread lib/src/synthesizers/netlist/netlist.dart Outdated
Comment thread test/netlist_test.dart
Comment thread lib/src/module.dart
Comment thread lib/src/synthesizers/netlist/netlist_module_translation.dart Outdated
Comment thread lib/src/synthesizers/netlist/netlist_module_translation.dart
Comment thread lib/src/synthesizers/netlist/netlist_synth_module_definition.dart
Comment thread lib/src/synthesizers/utilities/utilities.dart Outdated
Comment thread lib/src/utilities/namer.dart Outdated
/// Canonical base name for synthesis-created structure concat operations.
static const String synthStructureConcatOperationName = 'struct_concat';

/// Returns the canonical base instance name for a synthesis-created

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what these changes in Namer are for. Is this mimicking the work that Uniquifier could already do? Why are there these special constant names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dilemma I have is that the netlister needs to create new elements to make things more easily visualized. Things that disappear when you think about them from an SV perspective. The problem is that means some leaking from netlister down into Namer to ask it for these names. No other synthesizer will see these, I don't believe unless these become constructions in the synth layer (that SV ignores or elides):

  /// Canonical base name for synthesis-created array slice operations.
  ///
  /// Netlist synthesis uses these when a [LogicArray] port or submodule output
  /// must be decomposed into element wires, such as a child reading
  /// `values.elements[0]` from an aggregate array input port.
  static const String synthArraySliceOperationName = 'array_slice';

  /// Canonical base name for synthesis-created array concat operations.
  ///
  /// Netlist synthesis uses these when independently driven [LogicArray]
  /// elements must be reassembled for an aggregate consumer, such as
  /// `values.elements[0] <= a` and `values.elements[1] <= b` feeding a child
  /// array input port.
  static const String synthArrayConcatOperationName = 'array_concat';

  /// Canonical base name for synthesis-created structure slice operations.
  ///
  /// Netlist synthesis uses these internally when a [LogicStructure] aggregate
  /// must expose field wires. The emitted netlist projection can replace them
  /// with `$struct_unpack` cells so field names are preserved.
  static const String synthStructureSliceOperationName = 'struct_slice';

  /// Canonical base name for synthesis-created structure concat operations.
  ///
  /// Netlist synthesis uses these when independently driven [LogicStructure]
  /// fields must be packed back into an aggregate struct output or submodule
  /// input. The emitted netlist projection represents this as `$struct_pack`.
  static const String synthStructureConcatOperationName = 'struct_concat';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could move these back up into netlist as they currently are synthesized there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it would be cleaner to just let those names be selected (late if necessary) along with all the other things needing selection, and be uniquified as needed. I had to do something similar with net_connect

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these down into the synth utilities for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still dont understand why these are relevant constants to define in a central place. what is this SynthOperationNamer for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Netlist optimizations can create NEW slices and concats. These need to be named. There are four flavors: array and struct times slice and concat.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are simply the base names of these special new slices and concats (which are then numbered for uniqueness).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibliity is that when we join concat operations, say, we name them by concatenating the names. But most of the time it would be concat_1 merging with concat_2, so concat_1_2 would not really be that meaningful. So these become array_concat (and the next one is array_concat_0.


/// Replaces a `$concat` of adjacent `$slice` outputs from the same source
/// with one wider `$slice`.
static void collapseConcatOfAdjacentSlices(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this already all merged with main and benefits from the common collapsing in the synth stack?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe netlist passes contains operations that are supersets of the common collapsing that was just added to the synth stack.

  • Adjacent $slice outputs feeding a $concat can collapse into one wider $slice; example module: [netlist_test.dart:79]
  • Transparent $slice/$buf alias chains can collapse by tracing bits back to the external source; example module: [netlist_test.dart:93
  • The netlist pass file also has cleanup passes for trivial concat aliases and unconsumed transparent cells in [netlist_passes.dart:322

Similarly, there is code for structure field extraction and concatenation that also need collapse.

I've factored out the common collapsing code to leverage what is in main, a first layer of optimization.

I think what we can do is generate examples that trigger these passes and see if we want to push these optimizations down into the synth layer. I have a feeling they would subsume the current collapsing code since they are more general.

Comment thread lib/src/synthesizers/netlist/netlist_utils.dart Outdated
Comment thread lib/src/synthesizers/netlist/netlist_validation.dart
Comment thread lib/src/synthesizers/utilities/synth_array_concat.dart Outdated
Comment thread lib/src/synthesizers/utilities/synth_logic.dart Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants