Skip to content
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

[Calyx-FIRRTL] Primitive cell bug fix #1838

Merged
merged 6 commits into from
Jan 5, 2024
Merged

Conversation

ayakayorihiro
Copy link
Contributor

@ayakayorihiro ayakayorihiro commented Jan 4, 2024

I had a fault of omission in my previous primitive cell translation where the generated extmodule didn't list any of the input/output ports. I realized that the fix was pretty similar to the previous lines 80-106 so I extracted out that code into a function. I checked that the outputted FIRRTL files passed the FIRRTL to Verilog compiler, so this should be a fix!

Please let me know if there's anything I can improve here :) Thank you in advance!

@ayakayorihiro ayakayorihiro self-assigned this Jan 4, 2024
Copy link
Contributor

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful; looks great!!! I had one small Rust suggestion that may not even work out as written.

@@ -175,12 +152,17 @@ fn get_primitive_module_name(name: &Id, param_binding: &Binding) -> String {
}

fn emit_primitive_extmodule<F: io::Write>(
ports: &SmallVec<[RRC<Port>; 10]>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be just a slice type, to keep it slightly more generic?

Suggested change
ports: &SmallVec<[RRC<Port>; 10]>,
ports: &[RRC<Port>],

I assume SmallVec supports this "free" slice extraction, but I could be wrong!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! And the &[T] type is also compatible with references to normal vectors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so cool!! I'll read up about slice types, thanks for the suggestion!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayakayorihiro ayakayorihiro merged commit 1dc4a98 into main Jan 5, 2024
@ayakayorihiro ayakayorihiro deleted the primitive-cell-bug-fix branch January 5, 2024 19:41
rachitnigam pushed a commit that referenced this pull request Feb 16, 2024
* First commit of what I believe is the fix for primitive extmodule port bug. Need to fix the code clone

* fix code clone

* Update tests. Need to manually test whether this will compile in FIRRTL

* Fix formatting error

* recover panic message for an inout port

* Fixes from review comments
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.

4 participants