-
Notifications
You must be signed in to change notification settings - Fork 53
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
Conversation
There was a problem hiding this 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.
calyx-backend/src/firrtl.rs
Outdated
@@ -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]>, |
There was a problem hiding this comment.
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?
ports: &SmallVec<[RRC<Port>; 10]>, | |
ports: &[RRC<Port>], |
I assume SmallVec
supports this "free" slice extraction, but I could be wrong!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relevant Deref
impl is here: https://docs.rs/smallvec/latest/smallvec/struct.SmallVec.html#impl-Deref-for-SmallVec%3CA%3E
* 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
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!