Add hierarchical subcircuit composition support - #39
Merged
Conversation
…osition Add support for hierarchical subcircuit composition via RecursiveNetlist: - Implement flatten_recursive_netlist() to flatten dict-of-Netlists to SAX format - Extend compile_circuit() to accept RecursiveNetlist input and Circuit objects - Store source netlist/models metadata on compiled Circuit objects via properties - Add 20 comprehensive tests covering flattening, composition, and edge cases - Document hierarchy specification and roadmap in references/ Handles circulax connection extensions (tuple targets, nets lists). GND instances are never prefixed during flattening. All 243 existing tests pass plus 20 new tests with zero regressions.
…C solve Adds two tests demonstrating circulax's pre-compilation flattening works at arbitrary depth: - test_6_level_deep_nesting: verifies correct instance naming (a~x~x~x~x~x~x) and component type after flattening 6 nested levels - test_6_level_deep_nesting_dc_solve: end-to-end test compiling and DC-solving a 6-level deep circuit, verifying correct voltage at deepest node These tests demonstrate an advantage over SAX's bottom-up circuit composition, which fails under JAX tracing at similar depth due to concrete boolean indexing.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Update references/hierarchy.md to document the actual implementation landed in PR #39: - Status: V1 now implemented (was: specified, not yet implemented) - Implementation Files: document all actual functions and helpers added - Circuit additions: list public properties (ports, source_netlist, source_models) - Test matrix: expand from 8 planned to 22 actual tests across 4 test classes - Verification: document 265 total tests (243 existing + 22 new), all passing - V2 notes: update to reflect V1 has landed
…specs/ Scaffold specs/ directory structure with overview index and move hierarchy specification from references/ to specs/ to co-locate with other design docs. Remove references/README.md now that its content is superseded.
cdaunt
marked this pull request as ready for review
July 28, 2026 15:58
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Summary
Adds support for hierarchical subcircuit composition to circulax, enabling the equivalent of SPICE's
.subcktdirective. This allows recursive netlist flattening before compilation, enabling arbitrary nesting depth — an advantage over SAX's bottom-up composition which fails under JAX tracing at deep nesting levels.Changes
feat(hierarchy): add recursive netlist flattening and subcircuit composition
flatten_recursive_netlist()to flatten dict-of-Netlists to SAX formatcompile_circuit()to accept RecursiveNetlist input and Circuit objectstest(subcircuit): add 6-level deep nesting tests for flattening and DC solve
test_6_level_deep_nesting: verifies correct instance naming and component type after flattening 6 nested levelstest_6_level_deep_nesting_dc_solve: end-to-end test compiling and DC-solving a 6-level deep circuitTesting
All 243 existing tests pass plus 20 new tests with zero regressions.