<- Click here to Toggle
Chapter 1-5
Chapter 5-10
Chapter 10-15
Chapter 15-20
Chapter 20-25
Chapter 25-30
Layers of DPI
DPI consists of two separate layers
a) DPI SystemVerilog layer:
The SystemVerilog side of DPI does not depend on the foreign programming language. In particular, the actual function call protocol and argument passing mechanisms used in the foreign language are transparent and irrelevant to SystemVerilog. It only describes the functionality, semantics and syntax of the SystemVerilog layer of the interface. The other half of the interface, the foreign language layer, defines the actual argument passing mechanism and the methods to access (read/write) formal arguments from the foreign code.
b) DPI foreign language layer:
The foreign language layer of the interface (which is transparent to SystemVerilog) shall specify how actual arguments are passed, how they can be accessed from the foreign code, how SystemVerilog-specific data types (such as logic and packed ) are represented, and how to translate them to and from some predefined C-like types. The data types allowed for formal arguments and results of imported functions or exported functions are generally SystemVerilog types.
Global name space of imported and exported functions:
Every task or function imported to SystemVerilog must eventually resolve to a global symbol. Similarly, every task or function exported from SystemVerilog defines a global symbol. SystemVerilog have their own global name space of linkage names, different from compilation unit scope name space.
Global names of imported and exported tasks and functions must be unique (no overloading is allowed ) and shall follow C conventions for naming; specifically, such names must start with a letter or underscore, and can be followed by alphanumeric characters or underscores.
The leading backslash ( \ ) character and the trailing white space shall be stripped off by the SystemVerilog tool to create the linkage identifier.
export "DPI" pkt_plus = function \pkt+ ; // "pkt+" exported as "pkt_plus"
export "DPI" function pkt; // "pkt" exported under its own name
import "DPI" init_1 = function void \init[1] (); //"init_1" is a linkage name
