Skip to content

write_aiger: Add no-sort option #5150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

KrystalDelusion
Copy link
Member

What are the reasons/motivation for this change?

read_verilog << EOF
module top (input X, C, B, output A, Z, Y);

assign A = C;
assign Z = X;
assign Y = B & C;

endmodule
EOF
prep
aigmap
write_aiger -ascii -symbols

gives the following:

aag 4 3 0 3 1
2
4
6
4
8
6
8 4 2
i0 B
i1 C
i2 X
o0 A
o1 Y
o2 Z
c

As with #5133, the input and output ports are alphabetically sorted, rather than in the same order as the input design.

Explain how this is achieved.

Add -no-sort option, which prevents sorting input/output bits. Also use the module->ports to get inputs/outputs in order, separating the ports from the rest of the wires.

If applicable, please suggest to reviewers how they can test the change.

Test above script, adding -no-sort with the changes from this PR and get the following instead:

aag 4 3 0 3 1
2
4
6
4
2
8
8 6 4
i0 X
i1 C
i2 B
o0 A
o1 Z
o2 Y
c

Prevents sorting input/output bits so that they remain in the same order they were read in.
@KrystalDelusion
Copy link
Member Author

Note that I went with the solution of adding an option to prevent sorting rather than changing the default behaviour, since that has been the behaviour for the 8.5 years since the pass was added, so somebody might be expecting it to behave that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant