• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. Using DPI to get the current value of a signal

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 65
  • Views 16020
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using DPI to get the current value of a signal

sdav
sdav over 15 years ago
I'm using a C++ interface with SystemVerilog DPI to drive my Verilog simulation. From C++ I'd like to call a function which returns the current value of a Verilog signal. Ideally this function would take a string as an input parameter (e.g. "testbench.u1.u2.dout") and then return the reg value of the signal. I'm just not sure how to implement this in Verilog. $display, $monitor, $strobe all display to stdout (I know there are "file" versions of these system tasks, too). The TCL command "value" seems ideal, but how can I access the returned data in Verilog and then return it to C++? Anyway, I'm posting here because I've thought about this for a while and can't come up with an elegant way to do it. But, I'm convinced that there is a way and I'm not seeing it. Thanks, Shirley
  • Cancel
Parents
  • StephenH
    StephenH over 15 years ago

    Hi Shirley.

    I think you need to use some VPI functions to convert the hierarchical path string into a VPI handle to the object (signal). Then there are VPI functions that let you get/set the value of that object.

    It's perfectly OK to call VPI funtions from the DPI, you "just" need to figure out the right functions to call. I was looking for a good worked example but couldn't spot on immediately, sorry. However I suggest you take a look at the examples that ship with IUS, in IUS92/tools.lnx86/examples/vpi/*.

    The NCSim docs also have a whole bunch of info on DPI and VPI, including tutorials and "engineering notebooks" (app notes to use mere mortals) which give a nice cook-book approach to explaining the system.

    Hope this helps.

    Steve.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • StephenH
    StephenH over 15 years ago

    Hi Shirley.

    I think you need to use some VPI functions to convert the hierarchical path string into a VPI handle to the object (signal). Then there are VPI functions that let you get/set the value of that object.

    It's perfectly OK to call VPI funtions from the DPI, you "just" need to figure out the right functions to call. I was looking for a good worked example but couldn't spot on immediately, sorry. However I suggest you take a look at the examples that ship with IUS, in IUS92/tools.lnx86/examples/vpi/*.

    The NCSim docs also have a whole bunch of info on DPI and VPI, including tutorials and "engineering notebooks" (app notes to use mere mortals) which give a nice cook-book approach to explaining the system.

    Hope this helps.

    Steve.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information