Sort netlists according to block traversal ordering#454
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to make generated KiCad netlists deterministic by ordering nets (and pin entries within each net) based on block/link traversal order, and updates the example/reference .net files to match the new stable output.
Changes:
- Track block/link traversal order during netlist generation and sort nets accordingly.
- Sort pins within each net deterministically.
- Update example/reference netlists to reflect the new ordering.
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| edg/electronics_model/NetlistGenerator.py | Implements traversal-based ordering for nets and deterministic pin ordering within nets. |
| examples/UsbUart/UsbUart.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/UsbKey/UsbKey.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/UsbFpgaProgrammer/UsbFpgaProgrammer.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestLed/TestLed.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyWithSchematicImport/TestBlinkyWithSchematicImport.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyWithModeledSchematicImport/TestBlinkyWithModeledSchematicImport.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyWithLibraryExport/TestBlinkyWithLibraryExport.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyWithLibrary/TestBlinkyWithLibrary.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyPacked/TestBlinkyPacked.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyMicro/TestBlinkyMicro.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyImplicit/TestBlinkyImplicit.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyExpanded/TestBlinkyExpanded.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyComplete/TestBlinkyComplete.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyChain/TestBlinkyChain.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyBasicBattery/TestBlinkyBasicBattery.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyBasic/TestBlinkyBasic.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/TestBlinkyArray/TestBlinkyArray.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/SwdDebugger/SwdDebugger.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/Simon/Simon.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/RobotOwl/RobotOwl.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/ProtectedCharger/ProtectedCharger.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/PicoProbe/PicoProbe.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/LedMatrix/LedMatrix.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/Keyboard/Keyboard.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/JacdacKeyswitch/JacdacKeyswitch.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/IotRollerBlinds/IotRollerBlinds.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/IotCurtainCrawler/IotCurtainCrawler.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/EspProgrammer/EspProgrammer.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/CanAdapter/CanAdapter.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/BleJoystick/BleJoystick.net | Updated reference netlist ordering to match new deterministic generation. |
| examples/BasicKeyboard/BasicKeyboard.net | Updated reference netlist ordering to match new deterministic generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| named_nets = sorted( | ||
| [(self.name_net(net), net) for net in nets], | ||
| key=lambda pair: path_ordering[pair[0].link_component(must_have_link=False)], |
|
|
||
| named_nets = sorted( | ||
| [(self.name_net(net), net) for net in nets], | ||
| key=lambda pair: path_ordering[pair[0].link_component(must_have_link=False)], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes netlists more deterministic and less sensitive to the ordering of connects.
Updates reference netlists to match new order.