Verilog Procedural Interface

Verilog Procedural Interface

The Verilog Procedural Interface (VPI) is an interface primarily intended for the C programming language. It allows behavioral Verilog code to invoke C functions, and C functions to invoke standard Verilog system tasks. The IEEE 1364-2005 standard defines the Verilog Procedural Interface. VPI is sometimes also referred to as PLI 2, since it replaces the deprecated Program Language Interface (PLI).

Example

As an example, consider the following Verilog code fragment:

val = 41;$increment(val);$display("After $increment, val=%d", val);

Suppose the increment system task increments its first parameter by one. Using C and the VPI mechanism, the increment task can be implemented as follows:

// Implements the increment system taskstatic int increment(char *userdata) { vpiHandle systfref, args_iter, argh; struct t_vpi_value argval; int value; // Obtain a handle to the argument list systfref = vpi_handle(vpiSysTfCall, NULL); args_iter = vpi_iterate(vpiArgument, systfref); // Grab the value of the first argument argh = vpi_scan(args_iter); argval.format = vpiIntVal; vpi_get_value(argh, &argval); value = argval.value.integer; vpi_printf("VPI routine received %d ", value); // Increment the value and put it back as first argument argval.value.integer = value + 1; vpi_put_value(argh, &argval, NULL, vpiNoDelay);

// Cleanup and return vpi_free_object(args_iter); return 0;}

Also, a function that registers this system task is necessary. This function is invoked prior to elaboration or resolution of references when it is placed in the externally visible vlog_startup_routines [] array.

// Registers the increment system taskvoid register_increment() { s_vpi_systf_data data = {vpiSysTask, 0, "$increment", increment, 0, 0, 0}; vpi_register_systf(&data);}

// Contains a zero-terminated list of functions that have to be called at startupvoid (*vlog_startup_routines [] )() = { register_increment, 0};

The C code is compiled into a shared object that will be used by the Verilog simulator. A simulation of the earlier mentioned Verilog fragment will now result in the following output:

VPI routine received 41After $increment, val=42

ources

* [http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=496013 IEEE Xplore]

External links

* [http://www.edn.com/article/CA46145.html Verilog PLI primer]
* [http://www.asic-world.com/verilog/pli6.html#Verilog_Procedural_Interface_(VPI) Verilog VPI tutorial]
* [http://ruby-vpi.rubyforge.org/ Ruby-VPI] - Verilog VPI interface for the Ruby programming language
* [http://jove.sourceforge.net/ JOVE] - Verilog VPI interface for the Java programming language
* [http://teal.sourceforge.net/ Teal] - Verilog VPI interface for the C++ programming language
* [http://embedded.eecs.berkeley.edu/Alumni/pinhong/scriptEDA/ ScriptEDA] - Verilog VPI interface for the Perl programming language, Python programming language, and Tcl programming language


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Verilog — In the semiconductor and electronic design industry, Verilog is a hardware description language (HDL) used to model electronic systems. Verilog HDL , not to be confused with VHDL, is most commonly used in the design, verification, and… …   Wikipedia

  • VPI — may refer to:* Vietnam Petroleum Institute * Virginia Polytechnic Institute and State University (Virginia Tech) * Virtual Path Identifier, in computer networking * Verilog Procedural Interface, in computer programming * Velopharyngeal… …   Wikipedia

  • SystemVerilog — In the semiconductor and electronic design industry, SystemVerilog is a combined Hardware Description Language and Hardware Verification Language based on extensions to Verilog. SystemVerilog was created by the donation of the Superlog language… …   Wikipedia

  • C++ — The C++ Programming Language, written by its architect, is the seminal book on the language. Paradigm(s) Multi paradigm:[1] procedural …   Wikipedia

  • Hardware description language — In electronics, a hardware description language or HDL is any language from a class of computer languages and/or programming languages for formal description of electronic circuits. It can describe the circuit s operation, its design and… …   Wikipedia

  • Domain-specific language — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • Communicating sequential processes — In computer science, Communicating Sequential Processes (CSP) is a formal language for describing patterns of interaction in concurrent systems.[1] It is a member of the family of mathematical theories of concurrency known as process algebras, or …   Wikipedia

  • Thread (computer science) — This article is about the concurrency concept. For the multithreading in hardware, see Multithreading (computer architecture). For the form of code consisting entirely of subroutine calls, see Threaded code. For other uses, see Thread… …   Wikipedia

  • Parallel computing — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • Langage de programmation — Programme écrit en Perl. Programm …   Wikipédia en Français

Share the article and excerpts

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