Skip to content

Maintain port ordering for functional backend #5133

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

Conversation

KrystalDelusion
Copy link
Member

What are the reasons/motivation for this change?

As per #5128 (comment),

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

input A, C, B;
output X, Z, Y;

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

endmodule
EOF
hierarchy
opt_clean
write_functional_rosette

returns ports in reverse alphabetical order:

(struct top_Inputs (C B A) #:transparent
  ; C (bitvector 1)
  ; B (bitvector 1)
  ; A (bitvector 1)
)
(struct top_Outputs (Z Y X) #:transparent
  ; Z (bitvector 1)
  ; Y (bitvector 1)
  ; X (bitvector 1)
)

(without the opt_clean then the order is the same as input).

Explain how this is achieved.

  1. Use module->ports instead of module->wires() to get the ordered list of ports.
  2. Use reverse iterators to compensate for hashlib::dict iterating backwards.

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

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