Add per-object origin tracking (vOrigins) to Gia_Man_t#487
Open
robtaylor wants to merge 1 commit intoberkeley-abc:masterfrom
Open
Add per-object origin tracking (vOrigins) to Gia_Man_t#487robtaylor wants to merge 1 commit intoberkeley-abc:masterfrom
robtaylor wants to merge 1 commit intoberkeley-abc:masterfrom
Conversation
Add lightweight origin tracking that propagates source-location provenance through ABC's optimization passes. This enables the Yosys abc9 flow to preserve \src attributes on LUT cells after technology mapping, achieving ~100% coverage on tested designs with negligible overhead (~0.6% time, ~3% memory on picorv32). Changes: - Add Vec_Int_t *vOrigins field to Gia_Man_t with inline accessors - Read/write origins via AIGER "y" extension (sentinel -1 for unmapped) - Propagate through all Gia_ManDup* variants via Gia_ManOriginsDup() - Propagate through structural hashing (AND/XOR/MUX) in giaHash.c - Recover origins after GIA→AIG→GIA round-trips (&dc2, &dch) via Gia_ManOriginsAfterRoundTrip() using CO driver + top-down propagation - Propagate through IF mapper using iCopy correspondence - Instrument giaEquiv, giaMuxes, giaTim, giaBalAig, dauGia Co-developed-by: Claude Code v2.1.44 (claude-opus-4-6)
robtaylor
added a commit
to robtaylor/yosys
that referenced
this pull request
Feb 28, 2026
ABC now propagates origin mappings natively through optimization passes via vOrigins (berkeley-abc/abc#487), so we no longer need to run &verify -y and rewrite the output to reconstruct the mapping. Keep &verify for correctness checking but without -y flag. Co-developed-by: Claude Code v2.1.44 (claude-opus-4-6)
6 tasks
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
This adds lightweight per-object origin tracking to
Gia_Man_t, enabling the Yosysabc9flow to preserve\src(source-location) attributes on LUT cells through ABC's optimization passes.Motivation
We are working on preserving
\src(source-location) attributes through the Yosysabc9synthesis flow. The approach uses the XAIGER "y" extension to pass an object-to-source mapping through ABC — Yosys writes the mapping on&read, ABC preserves it during optimization, and Yosys reads it back on&writeto annotate the resulting LUT cells.We initially prototyped a
&verify -yapproach that uses combinational equivalence checking to reconstruct the mapping after optimization, but this only achieves 17-57% coverage on non-trivial designs and doesn't work for sequential circuits. This PR takes a different approach — propagating origins during optimization — which achieves ~100% coverage.Approach
Add a single
Vec_Int_t *vOriginsvector toGia_Man_tthat maps each object to its "origin" input-side object ID:&read(AIGER reader)&write(AIGER writer)Two propagation helpers handle different transformation patterns:
Gia_ManOriginsDup()— for standard dup operations that use theValuefield for old→new mappingGia_ManOriginsAfterRoundTrip()— for GIA→AIG→GIA round-trips (&dc2,&dch) where per-object data is lost; recovers origins via CI/CO correspondence + top-down fanin propagationPerformance
Benchmarked on picorv32 (4-LUT mapping via
abc9):The overhead is negligible — approximately 4 bytes per GIA object for the
vOriginsvector, with O(1) propagation per node creation.Coverage
With this change,
\srcretention on LUT cells afterabc9mapping improves from 17-57% to 100% on all tested designs (simple combinational, Amaranth-style, and larger multi-output designs with 54 LUTs).Files changed
src/aig/gia/gia.hvOriginsfield + inline accessors + helper declarationssrc/aig/gia/giaMan.cvOriginsinGia_ManStopsrc/aig/gia/giaAiger.cvOriginsvia "y" extensionsrc/aig/gia/giaDup.cGia_ManOriginsDup+Gia_ManOriginsAfterRoundTriphelpers; instrument allGia_ManDup*variantssrc/aig/gia/giaHash.cGia_ManHashAnd,Gia_ManHashXorReal,Gia_ManHashMuxReal,Gia_ManRehashsrc/aig/gia/giaAig.cGia_ManCompress2(&dc2) andGia_ManPerformDch(&dch)src/aig/gia/giaIf.ciCopycorrespondencesrc/aig/gia/giaEquiv.cGia_ManEquivReducesrc/aig/gia/giaMuxes.cGia_ManDupMuxes/Gia_ManDupNoMuxessrc/aig/gia/giaTim.cGia_ManDupNormalize/Gia_ManDupUnnormalizesrc/aig/gia/giaBalAig.csrc/opt/dau/dauGia.cDsm_ManDeriveGiaContext
This is part of work on YosysHQ/yosys#5712 to improve
\srcattribute retention through theabc9flow.cc @alanminko @Ravenslofty — would appreciate your thoughts on this approach.