John M
John M

Reputation: 1496

Packed Structs in System Verilog VPI?

I have some Verilog VPI code that prints information about all of the input and outputs of a given module in my System Verilog code. Some of these I/Os, however, are System Verilog packed structs, and I want to be able to have my VPI code print the values of the individual fields in the struct and their associated names. Unfortunately "struct" shows up nowhere in the official VPI specification (because VPI was standardized 4 years before System Verilog came into existence, I assume). All of my structs just show up in VPI as plain old registers or nets.

Is there some System Verilog specific extension to the VPI that I can use, or am I out of luck here? If it helps, I'm using vcs to compile.

Upvotes: 2

Views: 924

Answers (1)

Chiggs
Chiggs

Reputation: 2864

You want vpiStructVar which was introduced as part of SystemVerilog and defined in sv_vpi_user.h.

There's some code you might be interested in on the Issue#17 branch of Cocotb which has all sorts of vpi related fun. For example we can iterate over all objects in a design from Python:

@cocotb.test()
def discover_objects(dut):
    for thing in dut:
        print "Found %s.%s of type %s" % (dut._name, thing._name, type(thing))

You can also recursively discover the entire design etc.

We've expended a lot of effort in figuring out all of the often undocumented quirks and of course bugs in the EDA tools so taking a look at the code and/or comments may save you some time.

Upvotes: 3

Related Questions