Support loading *.aig files in binary format #130
Merged
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.
Resolves #129
Main contributions:
the
parser.load
function reads the file in binary modethe
parser.parse
function expects either:In either case, the input is transformed into a stream of bytes, which is consumed by the parsers. I chose this solution since if the file is in
aig
format, then the list of and gates may contain bytes interpreted as the\n
character. Thus, splitting the string by the\n
character would not have worked.The parsers have been modified as follows:
parse_header
consumes the stream until the next\n
and then it tries to match the regex as before. Additionally, it checks whether the header starts withaag
oraig
and sets thebinary_mode
boolean attribute ofHeader
accordingly;parse_input
works as before in case ofaag
files. In case ofaig
files, it adds the inputs2, 4, ... 2 * (n_inputs)
;parse_latches
works as before in case ofaag
files. In case ofaig
files, it reads just one or two integers. I am not so sure if having two integers (one to set the initial value of the latch) is allowed in the binary format (I am not sure even if it is allowed in the ASCII format);parse_output
works as before in both cases;parse and
is the one involving most of the changes: in case ofaig
files, it consumes the stream one byte at a time, reading the gates as https://github.com/arminbiere/aiger/blob/5f8ce5ca5fc42a06e5d713309f99195a740ac2b4/aiger.c#L2376parse_symbol
andparse_comment
work basically as before