|
|
|
|
|
|
|
|
|
|
|
|
Introduction
|
|
|
DPI is direct programming interface, this is far better than VPI and PLI, which needed lot of understanding of various PLI and VPI calls. It was like learning another programming language. VPI and PLI will remain for very long time due to power they offer. There are still applications which will need PLI and VPI. But then major of them won't need PLI and VPI kind of interface, but rather simple DPI should do the job. |
|
|
|
|
|
There two layers in DPI. |
|
|
|
|
|
- SystemVerilog Language Layer
- Foreign Language Layer
|
|
|
|
|
|
Either language compiler need not compile or parse other language, DPI follows the principle of a black box: the specification and the implementation of a component are clearly separated, and the actual implementation is transparent to the rest of the system. Therefore, the actual programming language of the implementation is also transparent, although this standard defines only C linkage semantics. The separation between SystemVerilog code and the foreign language is based on using functions as the natural encapsulation unit in SystemVerilog. By and large, any function can be treated as a black box and implemented either in SystemVerilog or in the foreign language in a transparent way, without changing its calls. |
|
|
|
|
|
|
|
|
|
|
|
Example : Basic DPI SystemVerilog code
|
|
|
|
|
|
1 module top;
2
3 // Declare the DPI import function
4 import "DPI" function void hello(string str);
5
6 initial begin
7 hello("Hello SystemVerilog") ;
8 end
9
10 endmodule
You could download file basic_dpi.sv here
|
|
|
|
|
|
Example : Basic DPI C code
|
|
|
|
|
|
1 #include <stdio.h>
2 #include "svdpi.h"
3
4 void hello(char* str) {
5 printf ("%s\n", str) ;
6 }
You could download file basic_dpi.c here
|
|
|
|
|
|
Simulation : DPI
|
|
|
|
|
|
|
|
|
Hello SystemVerilog
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|