8.1 Introduction to Verilog PLI
Category Advanced Verilog Tutorial
When engaging in digital design, special situations often arise where the tasks and functions in Verilog cannot meet the simulation requirements, necessitating the customization of some system tasks and functions. The Programming Language Interface (PLI) provides a set of interface subroutines for accessing the internal data structures of the design and extracting simulation environment information. Users can invoke these subroutines to define system tasks and functions, interacting with the internal data of the design and the Verilog simulator environment.
PLI Functions
In layman's terms, Verilog PLI offers a set of C language functions that designers can call to write software C programs. During RTL compilation, the software program written is also integrated into the simulation environment. When the simulation is running, system tasks can be called to dynamically access the data structures in the simulation. This access is bidirectional, allowing not only reading of information from the simulator's data structures but also modification of the data structure information.
The capabilities of PLI are extremely powerful, limited only by the designer's imagination.
PLI allows users to write custom system tasks and functions in C, enabling complex operations that cannot be completed with Verilog.
Some application software, such as file I/O tools and delay calculation tools, can also be written using PLI.
PLI can extract design information, such as accessing hierarchy, interconnections, and the number of specific types of logic elements.
PLI can be used to write specialized output display programs, such as custom waveform viewers that generate information on logic interconnections, hierarchy, and data waveforms.
PLI can accomplish tedious monitoring or stimulation tasks.
PLI can control the simulation process, such as pausing and exiting, facilitating debugging.
Other extended uses of PLI include RAM/ROM program download tools, power consumption analysis, CModel interfaces, and co-simulation environments...
Here is a summary of the frequently used functions of PLI:
(1) Implementing co-simulation of CModel and Verilog models. For more complex systems, developers often need to first create a working model described in C language, then rewrite it module by module in Verilog.
(2) Generating test stimuli or performing direct verification. For input stimuli with large data volume, or more complex control inputs, and data verification under specific environments, PLI implementation has more advantages than Verilog.
(3) Capturing simulation processes and results, and outputting them in a user-friendly manner. For example, some encoding and decoding modules, using custom display effects, are easier to debug.
(4) Hardware-software co-simulation. For example, if the design includes a CPU entity, the software can be compiled into machine code and loaded into the corresponding ROM for co-simulation.
PLI Versions
The development of PLI has mainly gone through three generations.
1985-TF Interface
The first generation is called the Task/Function interface, or TF interface for short. The TF interface includes a set of C language function libraries, all prefixed with tf_, defined in veriuser.h. These C functions are generally referred to as TF subroutines, mainly including user-defined tasks and functions, utility functions, callback mechanisms, and data write outputs.
1989-ACC Interface
The second generation is called the Access interface, or ACC interface for short. The functions in the ACC interface are all prefixed with acc_, defined in acc_user.h. ACC subroutines are mainly used for accessing and modifying various objects described in Verilog. The ACC library functions are an addition to the TF library functions, not a replacement.
The general PLI interface specifically refers to the TF and ACC interfaces.
1995-VPI Interface
The third generation is called the Verilog Process Interface, or VPI interface for short. VPI subroutines are a combination of the functions of TF and ACC subroutines, defined in vpi_user.h.
Compared to the numerous and chaotic PLI subroutines, VPI is particularly refined. Due to the lack of a unified standard at the inception of PLI, which evolved entirely in practice, there are nearly a hundred commonly used PLI library functions, and it is basically necessary to refer to the manual when writing programs.
VPI, on the other hand, was planned and formulated according to certain standards, incorporating many object-oriented ideas, and the library functions are far more streamlined than PLI. However, VPI has a more complex structure and is not easy to get started with. The biggest weakness of VPI is still the lack of friendly support for simulators.
2003-SystemVerilog and DPI
As an extension of Verilog, the SystemVerilog standard was released in 2003, supporting more forms of simulation.
The DPI interface (Direct Process Interface) has become the interface for interaction between software and SystemVerilog -9.2 Verilog Synthesizable Design