本文说的PLI,特指PLI 2, VPI。DPI是SV标准中组成,而DirectC和TLI是VCS中的功能组件。
关于PLI的文献只有Verilog PLI Handbook这本书。并且Verilog PLI是一本相对成熟的技术。PLI有三个libraries, TF(task/function) interface, ACC(access) interface, 以及VPI(Verilog Procedural Interface),连同DPI,四者的时间先后顺序是1985-1989-1995-2003。而前面两个已经在IEEE 1364-2005(IEEE 1364就是verilog std)中被删除。所以重要的就是VPI和DPI。
part 1 VPI
Handbook一书中part 1的7章介绍了VPI的构建及应用。
1. 创建VPI应用。共分为四步($hello system task为例)。
先是在Verilog module中引用,即调用$hello()或者$hello;
》》然后是编写一个calltf routine for $hello,这个routine 是VPI和C mixed,其中需要include "vpi_user.h"包含VPI的数据结构,也可以调用C std libraries 来使用C语言的相应函数。
》》注册编写的VPI 函数,因为是calltf routine,调用s_vpi_systf_data(s_vpi_systf_data,以s_开头的为struct结构体,以t_开头的表示数据类型,以p_开头的表示指针指向struct结构体)结构,并做好相应的注册。
》》Compiling and linking $hello system task。
2a. VPI的分类
calltf routines, ---The calltf routine is executed when simulation is running
compiletf routines, --- The compiletf routine should only be used for syntax checking, routine called before simulation time 0
sizetf的作用:The intent of the sizetf routine is to notify the simulator compiler or elaborator of the return size for system functions
注: eve