[SOLVED] When do I use DPI-C? is this important things?

Status
Not open for further replies.

u24c02

Advanced Member level 1
Joined
May 8, 2012
Messages
404
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Visit site
Activity points
4,101
Hi.

When do I use DPI-C? is this important things?
 

what is different between c with verilog and dpi-c with SV?

Hi. I can't find which benefit is in there using dpi-c and SV against c and verilog methodology?

what is different benefit in there between c with verilog and dpi-c with SV?
 

System Verilog DPI (Direct Programming Interface) is the equivalent to Verilog's PLI & VPI. All three are used to add system task (e.g. $display, $random, etc) to SV/V.

It's useful for adding something that would be easy to do in C (e.g. like displaying a jpeg image (using a library) in your testbench) but would require significant coding work in Verilog.
 

SystemVerilog DPI (Direct Programming Interface) is the equivalent to Verilog's PLI & VPI. All three are used to add system task (e.g. $display, $random, etc) to SV/V.
Not quite equivalent enough for me.

The PLI/VPI is a C interface to the simulator that is still relevant for SystemVerilog. It lets tool developers add functionality to the simulator like waveform dumping, analysis using design introspection. And yes, it does allow you to add functionality in C that would be more difficult to write in Verilog/SystemVerilog.

The SystemVerilog DPI is strictly a modeling interface, and it is bi-directional. SV can call C, and C can call SV without either side knowing that they are being called from a different language. That make is very easy for a model writer to integrate C and SystemVerilog without having to know simulator API specifics. You simply pass arguments on the call stack like would with any C program instead of having to use query based routines for access in the VPI. Using the DPI does require that you know which argument types are compatible; an int is an int in both languages, but a bit has no corresponding type in C, but there are helper routines in C to access bit-level structures on SV.

Another key feature of the DPI is, as I mentioned, C can call SV. That includes C calling time consuming tasks. That is very useful for using C to generate stimulus, or having C models that interact with bus functional RTL models.

As for the benefits of writing in C versus using SystemVerilog, that depends on what you already have or readily available. You may already have reference models written in C by architects who need these models in a C only environment. Re-use of these C models in your RTL verification environment would be a benefit. An there is no longer a distinction between Verilog and SystemVerilog as far as most simulators are concerned. Verilog is just a syntactical subset of SystemVerilog.
 
Reactions: ads-ee

    ads-ee

    Points: 2
    Helpful Answer Positive Rating
Thanks but I have some question.
What if some beginner ask to you as to what should he does learn firstly?
Then what do you tell him?
 

It is difficult to learn anything without having a goal in mind. (Just ask my wife's high school math students :???

The DPI is certainly simpler to learn, but it does not do as much as the VPI.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…