简体   繁体   中英

Get port name in SystemVerilog

I wonder if the modules have any visibility into the hierarchy of the ports? Can the port hierarchy be printed out?

For a minimum working example, assume I have this:

module top ();
  
  logic my_sig;

  child ichild (.sig(my_sig));

endmodule : top


module child (input logic sig);
  
  initial $display(/* SystemVerilog-Fu here */)

endmodule : child

I expect the $display to print top.my_sig -- or something that conveys my_sig name instead of just reading out the value. I looked into the DPI guide as well, but it doesn't seem to have any such facility.

Thanks in advance!

The DPI is for behavioral modeling interoperability between SystemVerilog and C. The VPI gives you the introspection you are looking for in from C. Also, many tools have a command line interface ( find signals -ports in Modelsim/Questa without having to learn a complicated C API.

Explaining how to do this is too deep a discussion for SO . I suggest you read my DVCon 2016 paper on SystemVerilog introspection with examples here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM