-
Notifications
You must be signed in to change notification settings - Fork 901
[hw/prim] Adapted primitives to no longer require primgen.py
#23523
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
Conversation
This change pulls in the previously generated primitive wrappers, so that the `primgen.py` generator is no longer needed. The consequence of this is that one can now use upstream FuseSoC to build OpenTitan, as oppose to needing the lowRISC fork. Signed-off-by: Hugo McNally <[email protected]>
The `primgen` generator is no longer required by any core files so can be removed. Signed-off-by: Hugo McNally <[email protected]>
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.
Huge fan of being able to build with upstream FuseSoC!
I'm on board with the first commit so we don't depend on primgen in the build process. For the second commit, I wonder whether we should keep primgen around so that there is an automated way to update all the primitives through the templates. What do you think?
Apologies for my SystemVerilog ignorance, but does the "abstract" file for these prims contain any real logic, or is it solely selecting which tech-specific prim to use? If the latter, would the following work?
|
I think if primgen is no longer used for builds it will start to bitrot, which would cause future devs pain. For the use case you are suggesting, primgen would need to be adapted to generate files in there expected locations in the repository. It can always be revived from the history, if we wish to do this. Going forward there is a lot of cruft that could be removed and re-organised. For example if ((Impl == prim_pkg::ImplXilinx) || (Impl == prim_pkg::ImplXilinx_ultrascale)) begin : gen_xilinx
prim_xilinx_xor2 #(
.Width(Width)
) u_impl_xilinx (
.*
);
end else begin : gen_generic
prim_generic_xor2 #(
.Width(Width)
) u_impl_generic (
.*
);
end In fact, the only difference between These sorts of changes would require further, significant changes to primgen. |
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.
Thanks for this @HU90m this looks like good work, however we must hold off on merging for now to avoid any possible disruption to M4.
So marking a 'Request changes' to prevent an accidental merge. I think this would be better off as a draft PR for now to make it clear the intent is early visibility and review.
I had considered this and we could still do this. A reason not to do this now is that we want to make the changes to the A reason not to do this ever is that the current approach is pure system verilog and easy to understand. Using FuseSoC would make it harder for people with less familiar with FuseSoC to understand what is going on and would make it harder for people injesting the RTL into a different build flow to swap at the technology library without re-injesting the RTL. |
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 misses the reason we have primgen. What is it about primgen that makes it incompatible with upstream fusesoc?
An alternative that might not break the model would be to turn the abstract cores that were generated into virtual cores. Each tech lib would implement their own providers, and the particular tech lib would be chosen at the top level. This idea might need massaging for dealing with the chip-level cores that already specify the tech lib to use, though maybe that could be the output of a simple fusesoc generator, where a simple VLNV string provides the tech lib to depend on.
- all other references (grep for it!). | ||
4. Implement all primitives. Replace the module body of the generic implementation with a technology-specific implementation as needed. | ||
Do *not* modify the list of ports or parameters in any way! | ||
5. Add the new technology library to the enum in `prim_pkg.sv` with a value in the form `prim_pkg::ImplTechlibname`. |
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 what I would object to here. primgen's purpose is to allow out-of-tree primitives without modifying the upstream repo.
- lowrisc:prim:prim_pkg | ||
- lowrisc:prim:primgen | ||
- lowrisc:prim:assert | ||
- lowrisc:prim_xilinx:and2:0 |
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.
Explicit dependencies here is going to make this not scale.
I get what you mean. Just for the record, this is what I did when porting prims to Bender, so it's not necessarily FuseSoC specific, it just needs an equivalent in whatever system you're using to build hardware. |
I haven't tested this beyond running fusesoc --setup on a few chip-level cores, but this might show what I was talking about with virtual cores: #23555 This won't work without a very recent commit of fusesoc, though: The fixes to how virtual cores work aren't in a fusesoc release yet. On top of that, a more recent fusesoc appears to change the build directory compared to what dvsim currently expects, so that'll need to be fixed up. |
Closing in favor of exploring a virtual core approach. See #23555 and olofk/fusesoc#524 |
This change pulls in the previously generated primitive wrappers, so that the
primgen.py
generator is no longer needed.With these changes, OpenTitan can be built with upstream FuseSoC (tested on version 2.2).
I think there is some reorganisation of the primatives that could be nice; these are simply the minimal changes to remove
primgen.py
.Fixes: #20379 #6604
@rswarbrick This follows the initial plan without any additional changes needed.