Direct Programming Interface

Direct Programming Interface

Direct Programming Interface (DPI) is an interface which we use to interface System Verilog with foreign languages. These Foreign languages can be a C, C++, System C as well as others. DPI's consists of two layers: A System Verilog Layer and a Foreign language layer. Both the layers are isolated from each other.

Explanation

Direct Programming Interface (DPI) allows direct inter language function calls between the System Verilog and Foreign language. The functions implemented in Foreign language can be called from System Verilog and such functions are called Import functions similarly functions implemented in System Verilog can be called from Foreign language (C/C++ or System C) such functions are called Export functions. DPI's allows transfer of data between two domains through function arguments and return.

Function Import and Export

1) Function Import:- A function implemented in Foreign language can be used in System Verilog by importing it. A Foreign language function used in System Verilog is called Imported function.

Properties of Imported Function and Task

1) An imported function shall complete there execution instantly and consume zero simulation time. Imported task can consume time.

2) Imported function can have input, output, and inout arguments. The formal input aguments shall not be modified. If such arguments are changed within a function, the chages shall not be visible outside the function.

Imported function shall not assume any initial values of formal arguments. The initial value of output arguments is undetermined and implementation dependent.

Imported function can access the initial value of a formal inout argument. Changes that the Imported function makes to a formal inout argument shall be visible outside the function.

3) An Imported function shall not free the memory allocated by System Verilog code nor expect System Verilog code to free memory allocated by Foreign code or (Foreign Compiler).

4) A call to an Imported task can result in suspension of the currently executing thread. This occurs when an Imported task calls an Exported task, and the Exported task executes a delay control, event control or wait statement. Thus it is possible for an Imported task to be simultaneously active in multiple execution threads.

5) A Imported function or task can be equip with special properties called pure or context.

Pure and Context Tasks and Functions

Pure Functions

A function whose results solely depends on the value of its input arguments with no side effects is called Pure function.

Properties of Pure Funtions

1) Only Non-Void functions with no output or inout can be called as Pure functions.

2) Functions specified as Pure shall have no side effects, their results need to depend solely on the values of their input arguments.

3) A Pure function call can be safely eliminated if it's result is not needed or if it's results for the same value of input arguments is available for reuse without needing to recalculate.

4) A Pure function is assumed not to directly or indirectly perform the following:

a) Perform any file operation. b) Read or Write anything in Environment Variable, Shared memory, Sockets etc. c) Access any persistent data like Global or Static variable.

5) An Imported task can never be declared Pure.

Context Tasks and Functions

An Imported task or function which call "Exported" tasks or functions or accesses System Verilog data objects other than it's actual arguments is called Context task or function.

Properties of Context Tasks and Functions

1) A Context Imported task or function can access (read or write) any System Verilog data object by calling (PLI/VPI) or by calling Export task or function. Therefore, a call to Context task or function is a barrier for System Verilog compiler optimization.

Import Declaration

import “DPI-C” function int calc_parity (input int a);

Export Declaration

export “DPI-C” my_cfunction = function myfunction;

DPI Example

Calling 'C' Functions in System Verilog

C - Code File

#include #include

int add() {

int a = 10, b = 20;

a = a + b;

printf("Addition Successful and Result = %d ", a); return a;

}

System Verilog Code File

module tb_dpi; import "DPI-C" function int add(); int j;

initial begin $display("Entering in System Verilog Initial Block"); #20;

j = add(); $display("Value of J = %d", j); $display("Exiting from System Verilog Initial Block"); #5 $finish; end

endmodule

References

[http://www.project-veripage.com/dpi_tutorial_1.php]
*


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Direct manipulation interface — In computer science, direct manipulation is a human computer interaction style which involves continuous representation of objects of interest, and rapid, reversible, incremental actions and feedback. The intention is to allow a user to directly… …   Wikipedia

  • Application programming interface — API redirects here. For other uses, see API (disambiguation). An application programming interface (API) is a source code based specification intended to be used as an interface by software components to communicate with each other. An API may… …   Wikipedia

  • Speech Application Programming Interface — The Speech Application Programming Interface or SAPI is an API developed by Microsoft to allow the use of speech recognition and speech synthesis within Windows applications. To date a number of versions of the API have been released, which have… …   Wikipedia

  • Server Application Programming Interface — Le Server Application Programming Interface (SAPI), l interface de programmation des applications serveurs, est le terme générique utilisé en informatique pour désigner les modules d interface d applications serveur web comme Apache, Internet… …   Wikipédia en Français

  • Server Application Programming Interface — In computer science, the Server Application Programming Interface (SAPI) is the generic term used to designate direct module interfaces to web server applications such as the Apache HTTP Server, Microsoft IIS, or iPlanet. Microsoft also uses the… …   Wikipedia

  • Performance Application Programming Interface — In computer science, Performance Application Programming Interface (PAPI) is a portable interface (in the form of a library) to hardware performance counters on modern microprocessors. It is being widely used to collect low level performance… …   Wikipedia

  • Interface (computer science) — Interface generally refers to an abstraction that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside …   Wikipedia

  • Direct Show — Microsoft DirectX Entwickler: Microsoft Corporation Aktuelle Version: 10.1 (März 2009 Build) …   Deutsch Wikipedia

  • Direct Sound 3D — Microsoft DirectX Entwickler: Microsoft Corporation Aktuelle Version: 10.1 (März 2009 Build) …   Deutsch Wikipedia

  • Direct X — Microsoft DirectX Entwickler: Microsoft Corporation Aktuelle Version: 10.1 (März 2009 Build) …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”