Repository navigation
Conversation
The exact placer builds whatever NOR netlist it is handed, so a hand-written netlist such as the full adder's nor9 fixes its torch count and logic depth before placement starts. egraph.rs explores the equivalent netlists with egg and extracts ones worth placing. Saturation runs De Morgan, double negation, commutativity and associativity, distribution and factoring both ways, absorption, and XOR and XNOR expansions. Each e-class carries its truth table, and classes with equal tables are unioned in modify, so different forms of one function always meet. The full adder reaches 230 of the 256 three-input functions in 73 ms. Greedy extraction decides class by class and missed the shared NORs (13 gates against nor9's 9), so extraction is exact: egraph_extract.rsdsl, grounded with rsdsl and solved with the placer's CaDiCaL binding, picks one node per needed class (outputs are torches, a NOT adds a tick, an OR none) and minimizes gates, plus or_cost per OR node since every NOR input is a signal to route, within an optional depth bound. Each extraction is proven optimal for its e-graph in 0.1-10 s. On the full adder: - fewest gates: 8 (nor9 has 9), depth 3/4, but NORs of up to 4 inputs; - depth 3: 9 gates, depth 2/3; - or_cost 1: 9 gates, depth 4/5 against nor9's 5/6, fan-in 3, and the same 4 nets alive at once as nor9. The circuit harness places them (CIRCUIT=egraph-full-adder with EGRAPH_DEPTH and EGRAPH_OR_COST); explore_egraph_netlists sweeps depth bounds and OR costs. ExactLocalPlacer::from_netlist takes a netlist built elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The e-graph finds full adders with fewer gates (8) or less depth than nor9, so the question was whether placement gains from them. Placed with the same settings, the wide NORs they rely on are what construction cannot handle: steps with a 3- or 4-input NOR ran out of their 60 s repeatedly. The 8-gate and depth-3 netlists found no layout in 3 and 5 restarts; the or_cost 1 netlist (9 gates, depths 4/5, fan-in 3) took 15-16 minutes to construct against nor9's 1-1.5, and then compacted to the best cell of the runs on one seed (88 blocks, 11 ticks) and a poor one on the other. A `binary` extraction option allows only two-input NORs (an OR may not join classes built as ORs). Under it the minimum is nor9 itself, 9 gates at depth 5/6, proven optimal for the e-graph, so every gain over nor9 needs wider NORs and therefore a construction that can build them. docs/egraph_netlists.md records the method, the extractions, the placements, and that as the next step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
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.
Middle of a stack: the switch fix below, OR nets for wide NORs above.
Why
The exact placer builds whatever NOR netlist it is given. A hand-written netlist (the full adder's
nor9) therefore fixes the torch count and the logic depth before placement starts. This layer searches the equivalent netlists with an e-graph and measures whether placement gains from them.What
exact/egraph.rs(egg 0.9):modify.exact/egraph_extract.rsdsl):nor9's 9).ExactLocalPlacer::from_netlist,CIRCUIT=egraph-full-adderwithEGRAPH_DEPTH,EGRAPH_OR_COSTandEGRAPH_BINARY, andexplore_egraph_netlistsfor the sweep.Findings (full adder,
docs/egraph_netlists.md)nor9or_cost1nor9, proven optimalnor9uses NORs of 3-4 signals, and construction struggles with those.or_cost1 netlist took 15-16 minutes to construct, against 1-1.5 fornor9. Once built, its two seeds gave 88 blocks and 11 ticks, and 121 blocks and 19 ticks.Test plan
egraph_netlists_compute_the_full_adder: the extractions compute the full adder; 8 gates, proven; depth 3 with 9 gates; nothing at depth 2.cargo test --release --lib exact::: all pass.🤖 Generated with Claude Code