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

Support for /*verilator public*/ on SV structs too? #860

Open
veripoolbot opened this issue Dec 11, 2014 · 1 comment
Open

Support for /*verilator public*/ on SV structs too? #860

veripoolbot opened this issue Dec 11, 2014 · 1 comment

Comments

@veripoolbot
Copy link

@veripoolbot veripoolbot commented Dec 11, 2014


Author Name: Jonathon Donaldson
Original Redmine Issue: 860 from https://www.veripool.org
Original Date: 2014-12-11


The recently added feature of being able to use /verilator public/ on SV enums is priceless and works very very well. I no longer have to duplicate (i.e. recreate) any enums in my C++ code that already exist in my SV code. This saves loads of tedious copy & paste work when creating the testbench!

I'm now wondering if the same capability can easily be added for SV structs? The reason I ask is because I also have a lot of SV structs in my designs that are made up of these enums and so I end up having to duplicate the SV structs in my C++ code.

Let's assume I have the following SV package that I verilate:

package our_types;

// Flags
typedef enum logic {n,N} T_Flg_N /*verilator public*/;
typedef enum logic {r,R} T_Flg_R /*verilator public*/;
typedef enum logic {o,O} T_Flg_O /*verilator public*/;

// Processor Status Register
typedef struct packed {
  T_Flg_N N;
  T_Flg_R R;
  T_Flg_O O;
} T_PS_Reg /*verilator public*/;

endpackage : our_types

With the current version of verilator the "/verilator public/" on the struct is ignored. So this results in having to do the following in the C++ testbench code:

#include "Vour_our_types.h" // for access to T_Flg_N/T_Flg_R/T_Flg_O

// My manually duplicated T_PS_Reg
typedef struct {
  Vour_our_types::T_Flg_N N;
  Vour_our_types::T_Flg_R R;
  Vour_our_types::T_Flg_O O;
} T_PS_Reg;

int main () {
  Vour_our_types::T_PS_Reg PS_Reg;
}

But if /verilator public/ worked on SV structs then all I would have to do is this:

#include "Vour_our_types.h" // for access to T_PS_Reg

int main () {
  Vour_our_types::T_PS_Reg PS_Reg;
}

With the existing support for /verilator public/ on SV enums is support for SV structs something that can be easily added? Or are SV structs a whole different problem altogether that would require a significant amount of work?

I attached an example in test_regress format.

@veripoolbot

This comment has been minimized.

Copy link
Author

@veripoolbot veripoolbot commented Dec 19, 2014


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2014-12-19T23:17:45Z


Structures can reference structures and arrays, so this is a lot harder than enums. If you'd like to work more on a patch an I can give suggestions as to how to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.