Closed tomeroberts closed 3 years ago
While some instances of type parameters may have an equivalent representation that can be applied, I don't think this is true in the general case. Complications that come to mind include structs, default type parameters, and port bindings using unbased unsized literals (such as '1
).
As you mentioned, if the files are converted in a single pass, this works correctly. This restriction is true of other conversions as well. For example, wildcard port bindings (.*
) cannot be converted unless (at least the header of) the instantiated module is available at conversion time.
Could you explain why converting the files together is prohibitive for your use case? Perhaps there is another solvable issue at hand.
Understood - thanks.
We convert the files one by one just to maintain easier debug-ability in the verilog files passed into the rest of the toolflow (here). It's not a particularly strong requirement, so we can move away from that if we need to.
I've toyed with the idea of a mode wherein the input files would be converted in aggregate, but output in individual files, potentially in some other directory. Would that provide the debug-ability you're looking for?
Yes that would be equivalent. Again, not a strong requirement since one rarely needs to inspect the generated verilog.
I created a branch https://github.com/zachjs/sv2v/tree/write which adds a new option (--write=adjacent
, -wadj
, etc.) which takes each input .sv
and writes its corresponding converted output to a file in the same location, but with the .v
extension instead. It refuses to proceed if any input files don't have that extension. It also refuses to overwrite any files if they already exist. This isn't quite the implementation we discussed before, but I think it satisfies the use case. Please let me know what you think!
Thanks @zachjs - I'll take a look!
Just tried it - should work well for our use-case. Thanks @zachjs! I'll close this issue.
Thanks for checking it out! This has been pushed to master.
Not sure if this would be a complete nightmare to support(!), but it's quite a useful construct for creating generic helper modules.
Example:
Could be instantiated in:
This works currently if all files are passed as one (by creating multiple versions of the parameterized module). Is there a way to make it work if the files are converted one by one (maybe by converting the type parameterization into a width parameter)?