Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
How to access SV enums via /*verilator public*/ #833
I'm not sure if it's something that I'm doing wrong or if it's simply just not supported yet, but I'm wondering how/if I can access the enums in my SV code from within my C++ code. With basic SV parameters using /verilator public/ works really well. But if I try to use it with enums I keep getting a verilator syntax error. For example:
The above results in:
If it's not currently supported I wonder if verilator could simply treat the SV enums as if each enumeration was simply a set of independent parameters (maybe that way verilator could leverage what's already supported)?
Right now I have to copy each SV enum code block into my C++ code somewhere and manual translate it to C++ syntax. Not a huge deal, but it is quite a bit of code duplication that would be great to get rid of.
Original Redmine Comment
Enums are presently flattened and not put into the C code.
Often enums come from CSRs or such, and a company has some flow to autogenerate such enums for both C and Verilog, so verilator doesn't have to translate them.
However if you want to add support for this please feel free. I don't think they should become parameters but real enumerations. They will need to be in a separate class as in Verilog they are separate namespaces (e.g. EnumName::FOO and AnotherEnumName::FOO).