chipsalliance / UHDM

Universal Hardware Data Model. A complete modeling of the IEEE SystemVerilog Object Model with VPI Interface, Elaborator, Serialization, Visitor and Listener. Used as a compiled interchange format in between SystemVerilog tools. Compiles on Linux gcc, Windows msys2-gcc & msvc, OsX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ideal way to fetch all vpiStmts

mysoreanoop opened this issue · comments

commented

We are looking for If/IfElse statements (in procedural assignments), ternary operators (in continuous and procedural), and case statements. What would be the ideal way to do this?

Currently, we are doing a recursion of finding all vpiContAssign and vpiProcess, and recursively traversing most major nodes until we hit statements -- which doesn't seem optimal. There is no vpi_iterate through vpiStmts when in vpiModule scope (is there?). Would it be easy for us to implement that? Or was that not implemented for a reason? Is there a better way to accomplish this?

TIA

. There is no vpi_iterate through vpiStmts when in vpiModule scope (is there?).

No there is not, this is not in the standard VPI.

. Would it be easy for us to implement that?

Yes, it should be, if you can make it generic in taking an arbitrary set of object types you want to query, and an arbitrary set of stop objects you want the query not to traverse, it would be higher value for other people to use.
There is a similar Surelog internal set of routines that operate on the grammar AST:
https://github.com/chipsalliance/Surelog/blob/8bbae3af233cf8244c666b16b5eb5a0a49e7f2ad/src/Design/FileContent.cpp#L469
You need to develop (And please contribute it back) a similar one the UHDM data model.

. Or was that not implemented for a reason?
No one asked for that

Is there a better way to accomplish this?
No

commented

Got it, thank you. I'll try to do that when I get the time; will definitely contribute it back if I succeed!