steveicarus / iverilog

Icarus Verilog
https://steveicarus.github.io/iverilog/
GNU General Public License v2.0
2.81k stars 521 forks source link

SV %p support for class objects #286

Open svenka3 opened 4 years ago

svenka3 commented 4 years ago

Hello, I see vvl throwing error for %p - a handy format for class object printing in SV (See below for sample error). I have pasted a code as well below.

Is this easy to add in Icarus?

Thanks Srini

iverilog -g2012 a.sv [Srinivasans-MacBook-Air-2:src/WIP/run_dir] srini% vvp a.out ERROR: a.sv:17: $display does not support argument type (vpiClassVar). ERROR: a.sv:17: $display does not support argument type (vpiClassVar).

Code:

program p; class a; int a1; endclass : a

class b extends a; int abcd; endclass : b

a a0; b b0;

initial begin : test a0 = new(); b0 = new(); $display ("a0: %d b0: %d", a0.a1, b0.abcd); $display ("a0: %p b0: %p", a0, b0); end : test

endprogram : p

martinwhitaker commented 4 years ago

No, I don't think this is easy. VPI access to class variables does not appear to be implemented in vvp. Also, the compiler converts packed structs to vectors, so vvp has no knowledge of the struct members.