Search code examples
system-veriloginoutvpi

Active direction of inout port during simulation using PLI


I am trying to find if an inout port is used as an input port or as an output port during simulation from my PLI based C-code. How can it be done?


Solution

  • Before you go down this path, note that most tools have capabilities to give you this information with Extended VCD files or in other formats usually associated with power estimation tools.

    Doing this withe the VPI requires extensive knowledge of the §38 VPI routines and §36 VPI object model diagrams in the 1800-2012 LRM. I can give you an outline of what needs to be done:

    • For each inout port
      • Register a cbValueChange callback using vpi_register_cb
      • Build a list of drivers using the diagram §37.16 Nets
      • Classify each driver as being outside the module (HiConn) or inside (local or LoConn)
    • The callback routine needs to scan the list of drivers for the port that changed value
      • If the active driver is outside the module, the port is in input mode.
      • If the active driver is inside the module, the port is in output mode.