Skip to content

Netlist - #675

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

Netlist #675
desmonddak wants to merge 72 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
}

/// Returns a synthesized netlist JSON representation of this [Module].
String generateNetlist(

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've been sort of regretting having generateSynth at all, maybe long term can deprecate it, but it keeps being convenient. this expansion of the pattern is maybe not great in that regard. what if we instead upgraded the generateSynth to accept a Synthesizer and default to SystemVerilogSynthesizer to maintain backwards compatibility? thoughts?

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.

Please look at the module_services branch. I move away from generateSynth -- not deprecate (yet), but I use a 'Service' that has its own options and output instead of in the Module api

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.

This was ONLY done to make this branch reviewable at this point in time (this 'era' of having generateSynth).

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.

Should we omit it then from this PR if it's going to be removed/deprecated soon anyways?

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.

Tests need it. We will deprecate in module_services_api.

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.

im concerned that once we merge this if we do a release it will become an API that needs deprecation

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.

This PR is designed to come before module_services_api which we are still not completely sure of.
meanwhile, netlist needs tests.
So we could simply mark this as testing only for now.

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.

This is why this PR is from branch netlist_pre. The _pre means before module_services. I tried to peel apart the changes into digestible PRs, but this means things like this need to happen: APIs need to be there for a period and then disappear. I cannot design a perfect merge order, especially when we can't quite agree on the services api.

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 marked it @visibleForTesting.

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.

or we can make it an extension only visible in that test that uses it?

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
@@ -1,7 +1,12 @@
// Copyright (C) 2024-2025 Intel Corporation

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.

copyright year (and check in general)

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 scanned for these. I think this file was indeed changed in 2025 as I started netlist then. But I didn't check, might as well make it 2026 to match the significant amount of changes made.

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.

this still has 2025

Comment thread lib/src/utilities/namer.dart Outdated
Comment thread lib/src/synthesizers/netlist/netlist_passes.dart
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
@desmonddak
desmonddak requested a review from mkorbel1 August 8, 2026 22:48

@mkorbel1 mkorbel1 left a comment

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.

can you pull main also again just so it's up to date?

Comment thread lib/src/module.dart
}

/// Returns a synthesized netlist JSON representation of this [Module].
String generateNetlist(

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.

or we can make it an extension only visible in that test that uses it?

/// );
/// final synth = NetlistSynthesizer(options: options);
/// ```
class NetlistOptions {

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.

the systemverilog one uses the word "configuration" instead of "options" (I know I think you came first, sorry, but mine merged first unfortunately), should we align?

Comment thread lib/src/synthesizers/netlist/netlist_options.dart
///
/// This is backward-compatible: Yosys-format arrays already mix
/// integers with constant strings `"0"` and `"1"`. Parsers can
/// detect range strings by the presence of `:`.

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.

why do you want this to be exposed as a configurability option? any config you have is something you have to support or else deprecate in the future. this applies to the other ones in here too (e.g. enableDCE)

/// When `true`, dead-cell elimination is performed after aliasing to
/// remove cells whose inputs are entirely undriven or whose outputs
/// are entirely unconsumed.
final bool enableDCE;

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.

nit: why not enableDeadCellElimination?

@@ -1,7 +1,12 @@
// Copyright (C) 2024-2025 Intel Corporation

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.

this still has 2025


import 'package:rohd/rohd.dart';

/// Provides bit ranges and field names for a packed [LogicStructure].

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: this applies to the leaves of a structure if there is hierarchy?

String get instanceTypeName => getInstanceTypeOfModule(module);

/// Non-fatal warnings reported while producing this synthesis result.
final List<String> warnings;

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.

In general, been avoiding adding "warnings" to ROHD -- either things are bad and fatal or good and allowed. Trying to avoid warning soup that happens in a lot of EDA flows, where they grow forever to the point where it's just slowing down and bloating logs. Do we really need warnings?

@@ -1,8 +1,10 @@
// Copyright (C) 2021-2025 Intel Corporation

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.

year

export 'synthesis_result.dart';
export 'synthesizer.dart';
export 'systemverilog/systemverilog.dart';
export 'utilities/synth_module_stop_policy.dart';

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.

why export this?

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