• 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
  • sdav
    sdav over 15 years ago

    I was eventually able to get this to work using VPI.  Here's some of the code from the C++ side:

    # include "vpi_user.h"

    vpiHandle net;              // name of signal to probe
    s_vpi_value cur_val;  // current value of the signal


    net = vpi_handle_by_name("testbench.u1.u2.dout", NULL);  // set the name of the signal you are probing
    vector_size = vpi_get(vpiSize, net);    // returns the size of the signal you are probing
    cur_val.format = vpiVectorVal;             // set the format you want for the returned data
    vpi_get_value(net, &cur_val);              // probe the signal and return the value into cur_val structure

    // The value of the probed net is available in:

    cur_val.value.vector[0].aval   // bits [31:0] of the probed signal
    cur_val.value.vector[0].bval
    cur_val.value.vector[1].aval   // bits [63:32] of the probed signal
    cur_val.value.vector[1].bval
    ... and so on, depending on the vector_size of the net you probed
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • sdav
    sdav over 15 years ago

    I was eventually able to get this to work using VPI.  Here's some of the code from the C++ side:

    # include "vpi_user.h"

    vpiHandle net;              // name of signal to probe
    s_vpi_value cur_val;  // current value of the signal


    net = vpi_handle_by_name("testbench.u1.u2.dout", NULL);  // set the name of the signal you are probing
    vector_size = vpi_get(vpiSize, net);    // returns the size of the signal you are probing
    cur_val.format = vpiVectorVal;             // set the format you want for the returned data
    vpi_get_value(net, &cur_val);              // probe the signal and return the value into cur_val structure

    // The value of the probed net is available in:

    cur_val.value.vector[0].aval   // bits [31:0] of the probed signal
    cur_val.value.vector[0].bval
    cur_val.value.vector[1].aval   // bits [63:32] of the probed signal
    cur_val.value.vector[1].bval
    ... and so on, depending on the vector_size of the net you probed
    • 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