🐛 Fix reading sequential AIGER files produced by ABC - #700
Open
marcelwa wants to merge 1 commit into
Open
Conversation
A sequential network written by ABC could not be read back correctly. Three separate defects, all in the AIGER latch and output handling. **Omitted latch reset values were read as undefined.** Both the binary and the ASCII reader defaulted to NONDETERMINISTIC when a latch line carried no reset field. The format specifies the opposite: the original AIGER format initialized every latch to zero, and the reset field added in 1.9 is optional, so its absence means 0. ABC relies on this and omits the field for zero-initialized latches, so every zero-initialized register came back undefined. **The ASCII reader compared the wrong token.** The branch recognizing a reset value of 1 tested `tokens[1u]`, the next-state literal, instead of `tokens[2u]`. An explicit reset of 1 was therefore never recognized, and a latch whose next-state literal happened to be 1 was wrongly reported as one-initialized. **Bad state properties were dropped.** A writer emitting the AIGER 1.9 extended header moves the primary outputs into the bad-state section; ABC does this for any design with a non-zero latch initialization. `on_bad_state` was not overridden, so those outputs disappeared and the network came back with none. They are now kept as primary outputs, which is what they were, along with their names from the symbol table. Also fix an adjacent defect in the destructor: the output index only advanced for outputs that carried a name, so with a sparse symbol table every name after the first unnamed output landed on the wrong one. Verified end to end against ABC. A network with three registers initialized to 0, 1, and undefined previously returned with no outputs and a corrupted first register; it now round-trips through `resyn2` with its inputs, outputs, registers, and reset values intact. Note that AIGER constraints are still ignored. They are assumptions rather than outputs, so mapping them onto primary outputs would change the meaning of the network. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GbUqcnZayPooFgekEXVSjz
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #700 +/- ##
==========================================
- Coverage 84.06% 84.06% -0.01%
==========================================
Files 190 190
Lines 29468 29474 +6
==========================================
+ Hits 24773 24777 +4
- Misses 4695 4697 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 28, 2026
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.
Description
A sequential network written by ABC cannot currently be read back correctly. Three
separate defects in the AIGER latch and output handling.
1. Omitted latch reset values are read as undefined
Both the binary and the ASCII reader default to
NONDETERMINISTICwhen a latch linecarries no reset field. The format specifies the opposite — AIGER's
FORMATdocumentstates "Latches are always assumed to be initialized to zero", and the reset field
added in 1.9 is optional, so its absence means
0.ABC relies on this and omits the field for zero-initialized latches, so every
zero-initialized register comes back undefined. This affects even the simplest
sequential round trip.
2. The ASCII reader compares the wrong token
An explicit reset of
1is therefore never recognized, and a latch whose next-stateliteral happens to be
1is wrongly reported as one-initialized.3. Bad state properties are dropped
A writer emitting the AIGER 1.9 extended header moves the primary outputs into the
bad-state section. ABC does this for any design with a non-zero latch initialization —
from
ioWriteAiger.c:on_bad_stateis not overridden, so those outputs disappear and the network comes backwith none at all. They are now kept as primary outputs — which is what they were —
together with their names from the symbol table.
Drive-by
The
aiger_readerdestructor advances the output index only for outputs that carry aname, so with a sparse symbol table every name after the first unnamed output lands on
the wrong output.
Verification
End to end against ABC, with a network carrying three registers initialized to
0,1,and undefined, put through
resyn2:Five new test cases in
test/io/aiger_reader.cppcover omitted, explicit0/1, andundefined resets, the extended header with a bad state, and the sparse symbol table.
Notes
lib/lorina. Happy to openthe equivalent change against
hriener/lorinaas well — let me know if you wouldprefer to take it that way round.
mapping them onto primary outputs would change the meaning of the network.
Context: this came out of building a Python-side ABC bridge in
aigverse, where sequential designs survived the
trip to ABC but not back. Companion to #699.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GbUqcnZayPooFgekEXVSjz