第三部分 PLI 程序

Verilog PLI教程 第一部分 介绍2007-09-24 来源:数字集成电路设计者 作者:5lifeVerilog PLI(可编程语言接口)是在Verilog代码中运行C或者C++的一种机制。用C/C++写函数编译代码并产生共享库(windows下是*.dll文件,Unix下是*.so文件)。VCS这样的仿真工具也允许静态链接。在verilog代码中调用这些函数…Verilog PLI(可编程语言接口)是在Verilog代码中运行C或者C++的一种机制。 系统调用是指在verilog代码中调用的函数。一个例子:内置系统任务$di 阅读详情

PLI提供两种类型的程序:Access程序;任务和函数程序。Access 程序是能访问verilog内部的信息的C编程语言……

PLI提供两种类型的程序,他们是

  • access程序
  • 任务和函数程序

PLI2.0把access程序和tf程序整合为VPI函数,也澄清了PLI中的一些confusion。

Access 程序
Access 
程序是能访问verilog内部的信息的C编程语言。access程序能执行两个操作:

读取操作: 直接从内部数据结构中读取特定对象的数据。access程序可以读取以下对象的信息:

  •   例化模块
  •   模块端口
  •   模块通路
  •   内部模块通路 
  •   顶层模块
  •   例化primitive
  •   Primitive terminals
  •   线网
  •   寄存器
  •   参数
  •   时序检查
  •   named events
  •   整型,实数和时间变量

写操作:向内部数据结构写入有关对象的新信息。

  •   模块内部通路
  •   模块通路
  •   例化primitives
  •   时序检验
  •   寄存器逻辑值
  •   sequential UDP逻辑值

根据access的操作,可以分为六类:

  •    Fetch: 返回设计层次中不同对象信息
  •    Handle: 返回设计层次中的句柄
  •    Modify: 修改设计层次中各种对象的值
  •    Next:   当在循环结构时,next程序寻找每个符合给定类型的对象
  •    Utility: 执行许多操作,比如初始化和配置access程序环境
  •    VCL: VCL允许PLI 应用程序监测选定对象的值的改变

Access 函数参考

Routine

Description

acc_handle_scope()

This function returns the handle to the scope of an object. The scope can be either a module, task, function, named parallel block, or named sequential block.

acc_handle_by_name()

This routine returns the handle to a Verilog-HDL object based on the specified name and scope.

acc_handle_parent()

This function returns handle for the parent primitive instance or module instance of an object

acc_handle_port()

This function returns handle for a module port

acc_handle_hiconn()

This function returns the hierarchically higher net connection to a scalar module port or a bit of a vector port

acc_handle_loconn()

This function returns the hierarchically lower net connection to a scalar module port or a bit of a vector port.

acc_handle_path()

This function returns a handle to an inter-module path that represents the connection from an output port to an input port

acc_handle_modpath()

This function returns handle to the path of a module

acc_handle_datapath()

This function returns a handle to a datapath for a module instance for the specified edge-sensitive module path

acc_handle_pathin()

This function returns handle for the first net connected to a module path source

acc_handle_pathout()

This function returns handle for the first net connected to a module path destination

acc_handle_condition()

This function returns a handle to the conditional expression for the specified path

acc_handle_tchk()

This function returns handle for the specified timing check of a module (or cell)

acc_handle_tchkarg1()

This function returns handle for the net connected to the first argument of a timing check

acc_handle_tchkarg2()

This function returns handle for the net connected to the second argument of a timing check

acc_handle_simulated_net()

This function returns the simulated net associated with the collapsed net passed as an argument

acc_handle_terminal()

This function returns handle for a primitive_terminal

acc_handle_conn()

This function returns handle to the net connected to a primitive terminal

acc_handle_tfarg()

This function returns handle for the specified argument of the system task or function associated (through the PLI mechanism) with your C-language routine`

acc_fetch_attribute()

This function returns the value of a parameter or specparam named as an attribute in your source description

acc_fetch_paramtype()

This function returns the data type of a parameter as one of three predefined integer constants.

acc_fetch_paramval()

This function returns the value of a parameter or specparam

acc_fetch_defname()

This function returns a pointer to the defining name of a module instance or primitive instance

acc_fetch_fullname()

This function returns a pointer to the full hierarchical name of any named object or module path

acc_fetch_name()

This function returns a pointer to the instance name of any named object or module path

acc_fetch_delays()

This function fetches different delay values for different objects

acc_fetch_size()

This function returns the bit size of a net, register, or port.

acc_fetch_range()

This function retrieves the most significant bit and least significant bit range values for a vector.

acc_fetch_tfarg()

This function returns value of the specified argument of the system task or function associated (through the PLI mechanism) with your C-language routine

acc_fetch_direction()

This function returns the direction of a port or terminal as one of three predefined integer constants.

acc_fetch_index()

This function returns a zero-based integer index for a port or terminal

acc_fetch_edge()

This function returns the edge specifier (type) of a path input or output terminal as one of these predefined integer constants.

acc_set_value()

This function returns a pointer to a character string indicating the logic or strength value of a net, register or variable.

acc_initialize()

This function initializes the environment for access routines

acc_close()

This function frees internal memory used by access routines; resets all configuration parameters to default values

acc_configure()

This function sets parameters that control the operation of various access routines

acc_product_version()

This function returns a pointer to a character string that indicates what version of a Verilog simulator is linked to the access routines

acc_version()

This function returns a pointer to a character string that indicates version number of your access routine software

acc_count()

This function returns an integer count of the number of objects related to a particular reference object

acc_collect()

This function returns a pointer to an array that contains handles for all objects related to a particular reference object

acc_free()

This function frees memory allocated by acc_collect

acc_compare_handles()

This function returns true if the two input handles refer to the same object

acc_object_in_typelist()

This function determines whether an object fits a type or fulltype or exhibits a property specified in an input array

acc_object_of_type()

This function determines whether an object fits a specified type or fulltype, or exhibits a specified property

acc_next_cell()

This function returns the next cell instance within the region that includes the entire hierarchy below a module

acc_next_child()

This function returns the next child of a module

acc_next_modpath()

This function returns the next path of a module

acc_next_net()

This function returns the next net of a module

acc_next_parameter()

This function returns the next parameter within a module

acc_next_port()

This function returns the next input, output or inout port of a module in the order specified by the port list

acc_next_portout()

This function returns the next output or inout port of a module in the order specified by the port list

acc_next_primitive()

This function returns the next gate, switch or user-defined primitive (UDP) within a module

acc_next_specparam()

This function returns the next specparam within a module

acc_next_tchk()

This function returns the next timing check within a module

acc_next_terminal()

This function returns the next terminal of a gate, switch or user-defined primitive (UDP)

acc_next()

This function within a scope, returns the next object of each type specified in object_type_array

acc_next_topmod()

This function returns the next top-level module

acc_next_cell_load()

This function returns the next load on a net inside a cell

acc_next_load()

This function returns the next primitive terminal driven by a net

acc_next_driver()

This function returns the next primitive terminal that drives a net

acc_next_hiconn()

This function returns the next hierarchically higher net connection to a port of a module

acc_next_loconn()

This function returns the next hierarchically lower net connection to a port of a module

acc_next_bit()

This function returns the handles of each bit in an expanded vector port or expanded vector net

acc_next_input()

This function returns a handle to the next input path terminal of the specified module path or datapath

acc_next_output()

This function returns a handle to the next output path terminal of the specified module path or datapath

 

 

 

 

使用access程序流程
就像在前面例子里看见的一样,在我们写用户应用程序的之前,要执行一系列步骤,如下:

1

#include <acc_user.h>

2

 

3

void pli_func() {

4

 

acc_initialize();

5

 

// Main body: Insert the user application code here

6

 

acc_close();

7

}

  • acc_user.h: 所有有关access程序的数据结构
  • acc_initialize(): 初始化变量和建立环境
  • 主体: 用户定义应用
  • acc-close(): 取消acc-initialize执行的操作

对象的句柄
句柄是预定义的数据类型,类似于C中的指针,用来指向设计数据库中的对象和指向任何类型的对象。句柄是access程序的支柱,PLI1.0中引入的最重要的新概念。

申明:

  • handle my_handle;
  • handle clock;
  • handle reset;

VCL(Value change link)
VCL
是一个PLI应用程序来监测被选定对象值的改变

  •    事件
  •    标量和矢量寄存器
  •    标量线网
  •    扩展的矢量线网的位选
  •    未扩展的矢量线网

VCL不能提取有关下面对象的信息:

  •    Bit-selects of unexpanded vector nets or registers
  •    部分选择
  •    存储器
  •    表达式

Verilog ACC 子程序列表 阅读详情

相关推荐

八 WebRTC 关键帧请求PLI与FIR

目录 一 关键帧请求场景 二 PLI与FIR 前言: IDR Request 关键帧也叫做即时刷新帧,简称IDR帧。对视频来说,IDR帧的解码无需参考之前的帧,因此在丢包严重时可以通过发送关键帧请求进行画面的恢复。关键帧的请求方式分为三种:RTCP FIR反馈(Full intra frame request)、RTCP PLI 反馈(Picture Loss Indictor)或SIP Info消息,具体使用哪种可通过协商确定. 一 关键帧请求场景 1.1 H264解码无sps,pps信息 .

zrjliming的博客 2688

#PLI# Verilog PLI 简介(一)

编程语言接口(PLI, Program Language Interface)提供了一套接口子程序,用于访问设计内部的数据结构,并可以提取仿真环境信息。用户可以调用这些子程序,自定义系统任务和系统函数,与设计内部数据以及 Verilog 仿真器环境进行交互。

那么菜的博客 3761

verilog_PLI参考手册_tf和acc例程详解

verilog_PLI参考手册_tf和acc例程详解

verilog PLI简介

0.简介 Verilog PLI(Programming Language Interface )是一种Verilog代码调用C/C++函数的机制。它能让Verilog像调用一些系统调用(如$display/$stop/$random)一样调用用户编写的C/C++函数。PLI可以完成如下功能: 功耗分析 代码覆盖率工具 修改Verilog仿真数据结构(如修改为更精确的延时,即sdf反标...

weixin_34037515的博客 1043

网格聚类 Grid Clustering/Grid-based Clustering

本文主要简单介绍了网格聚类的基本概念,优缺点,应用场景,建模时的注意事项,评价指标,实现方法,python示例和模型参数等。

JasonH2021的博客 4829

RimWorld Mod开发避坑指南:从Defs命名规范到XML结构详解(附实战代码)

本文深入解析RimWorld Mod开发中Defs文件的编写规范与高级技巧,涵盖命名冲突预防、XML结构优化及高级功能实现。通过实战代码示例,帮助开发者避开常见陷阱,提升Mod兼容性与稳定性,特别适合RimWorld Mod开发者参考。

weixin_30790841的博客 453

三、13【Verilog HDL】编程语言接口(PLI)-自定义系统任务

用户自定义系统任务(PLI)

ARM_qiao的博客 1852

在运行opencv时出现的两个问题:AttributeError: module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipeline‘

解决了opencv的两个问题:由问题一引出 AttributeError: module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' cv2.error:OpenCV(4.1.2)C:\projects\opencvpython\opencv\modules\highgui\src\window.cpp:717:error: (-2:Unspecified error) The function is not implemented...

hu_yinghui的博客 3278

Verilog PLI介绍及运行NC的三种方法

1. PLI 功能介绍 Verilog PLI(Programming Language Interface )是一种Verilog代码调用C/C++函数的机制。它能让Verilog像调用一些系统调用(如$display/$stop/$random)一样调用用户编写的C/C++函数,这样我们可以用C/C++语言开始自己的system ta...

weixin_34110749的博客 2243

基于STM32的无人机智能避障与路径规划系统设计

本文详细介绍了基于STM32的无人机智能避障与路径规划系统设计,涵盖硬件选型、传感器组合、软件架构及算法实现。通过多传感器数据融合和改进的VFH+算法,系统在复杂环境中实现92%以上的避障成功率。STM32微控制器的实时性和低功耗特性为无人机自主导航提供了可靠保障,适用于工业巡检、仓储物流等场景。

blockchain9miner的博客 878

维护测试监控LLM应用

LangFuse: 开源 + SaaS(免费/付费),LangSmith 平替,可集成 LangChain 也可直接对接 OpenAI API;LangSmith: LangChain 的官方平台,SaaS 服务(免费/付费),非开源,企业版支持私有部署;调试 Prompt 的 Playground测试/验证系统的相关指标数据集管理各种指标监控与统计:访问量、响应时长、Token 费等等。

SunnyRivers 1785

Verilog PLI 简介

Verilog PLI(编程语言接口)是Verilog HDL提供的C/C++交互机制,用于扩展仿真功能。它通过系统任务/函数访问仿真数据,支持信号监控、层次遍历和外部工具集成。PLI包含TF、ACC和VPI三种接口,仅用于仿真不可综合。典型应用包括测试平台开发、调试工具和实时数据交互。使用时需注册PLI任务并链接C代码,注意仿真器依赖性和性能优化。文中通过一个信号打印示例演示了PLI的基本用法,并指出SystemVerilog DPI是现代替代方案。

m0_57545130的博客 1075

UOS系统手动添加1920x1080分辨率:xrandr命令详解与持久化配置

本文详细介绍了在UOS系统中使用xrandr命令手动添加1920x1080分辨率的方法。针对系统设置中缺失该选项的常见问题,文章提供了从识别显示设备、使用cvt生成模式、添加并切换分辨率,到通过修改.profile文件实现持久化配置的完整步骤。同时涵盖了虚拟机环境、设备名识别及排错等进阶内容,帮助用户彻底解决UOS分辨率配置难题。

weixin_29300931的博客 500

Verilog PLI已死( 可能), SystemVerilog DPI当立

Verilog PLI已死( 可能), SystemVerilog DPI当立 SNUG San Jose 2004 作者: Stuart Sutherland 译者: 韦和民 摘要 在古老的英格兰, 当一个君主死掉以后, 一个继承者会立即得到王位. 因此就有了这样的歌谣, “ The king is dead— long live the king!” . 随着新的SystemVerilog 直接编程接口(DPI)的出现, Verilog编 程 语 言 接 口 (PLI)看来也有 了继承者。 那么是不是老

Holden_Liu的博客 4416

硬方案——几种实用的恒流源电路设计方案,敬请收藏(运放、三极管在手,让你玩出多种花样)

0 引言 我们在信号测量、供电等应用场景时常会涉及到使用恒流源,以前觉得恒流源挺神奇的,研究了下实现方案,其实也没有多么高深(这里讨论的仅限于用在信号测量中的小电流恒流源设计),这里给出几个实用的恒流源电路设计方案。 1 恒流源电路设计 (1)使用三极管搭建的恒流源 (2)使用运放搭建的恒流源 (3)使用恒流二极管搭建的恒流源 pt100恒流源测温电路图_电子技术_电工之家 ...

数字世界 万物互联 9525

uniapp [全端兼容] - 详细实现拍照或相册选取图片后插入水印功能,手机拍照或相册上传图像并添加自定义水印及指定位置显示水印,uniApp给图片加水印后上传到后端服务器或保存到本机相册详细教程!

uni-app,h5移动端网页,微信小程序,支付宝小程序,Android安卓,苹果ios,app,nvue,图片水印,上传照片带水印,从相册选择图片加水印功能,拍完照片给图片加水印,添加照片水印,uniapp图片加水印,为图片添加自定义水印,uni-app上传图片并添加水印,上传图片加水印,uni-app如何对拍摄的照片加水印,uni-app实现图片上传添加水印操作,给上传的图片添加上水印,图片加完水印后如何上传到服务器,水印相机,拍照图片加水印,相册选取后给图片加上水印,渲染失败,无法保存,文字水印,日期

🏆 前端领域优质创作者 1万+

第二部分 编写PLI应用程序

 先前我们所看的例子太基础也没有实际用途。让我们看计数器的例子,写一个DUT的参考模型以及用C写的Checker程序,并把它链入到Verilog的Testbench。首先列出我们要用PLI写C模型的要求。  调用C模型的方法,当输入信号有任何变化时;  获得verilog代码中改变了的信号值或者任何C代码内部的信号的方法  通过C代码驱动Verilog内部值VerilogPLI提供一系列满足以上要求的程序(函数)。PLI 应用的SPEC我们定义使用PLI的计数器testbench的要求。 该PLI函数我们称

1220

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

小姜的Verilog PLI Handbook学习笔记

在routines之间分享数据;仿真行为发生;特定的仿真时间;逻辑值发生变化;程序执行语句。

Cloudriver_的博客 1393

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

第二部分 编写PLI应用程序(续)

<br /><br /> 先前我们所看的例子太基础也没有实际用途。让我们看计数器的例子,写一个DUT的参考模型以及用C写的Checker程序,并把它链入到Verilog的Testbench。首先列出我们要用PLI写C模型的要求。  调用C模型的方法,当输入信号有任何变化时;  获得verilog代码中改变了的信号值或者任何C代码内部的信号的方法  通过C代码驱动Verilog内部值<br />VerilogPLI提供一系列满足以上要求的程序(函数)。<br />PLI 应用的SPEC<br />我们定义使用

913

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

modelsim用PLI的方法

modelsim用PLI的方法 本文简要说明windows下面的modelsim,如何调用PLI。 工具: 1.modelsim,我是6.5版 2.MinWG去官网下载 原理: verilog提供的库非常有限,经常需要自己添加一些常用的“库函数”,而这些库函数,反映出来就是一些task,PLI的task。所谓PLI,就是programing language  interfac

tommyjsj的专栏 1866

什么是PLI?

首先,什么是PLI? 本部分设定了隐藏,您已回复过了,以下是隐藏的内容 PLI 就是product liability insurance 的简写,中文可以翻译成“产品责任险”说白了,就是你的产品如果出现问题造成事故了,又第三方保险公司负责赔偿。 转载于:https://www.cnblogs.com/pingshuixiangfeng/p/9894081.html...

weixin_33943347的博客 2631

PLI, DPI, DirectC,TLI

本文说的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 Pro...

weixin_30471561的博客 665

IVerilog 源码分析 --PLI框架简介

PLI 基础 Verilog 提供了PLI(Programming Language Interface)机制, 用来进行硬件设计和软件设计者进行交互。 它可以在Verilog的设计之中加入用户自定义的系统函数,这些系统函数是通过C语言软件的方式实现, 这可以理解为, 通过插件的方式, 来扩充硬件设计语言的功能。 PLI常见的功能如下: C语言bus函数建模; 访问C语言代码库函数; 延时计算功能; 自定义输出显示; 联合仿真; 设计的debug功能; 仿真结果分析; 我们比较感兴趣的是访问C语言代码库

baijiwei的博客 1558

基于VCS使用VPI+PLI/DPI在verilog中调用C程序进行cover property驱动的仿真控制

本文介绍一种在verilog中,运用PLI机制调用C程序的方法,其中的C程序,可以接受传参,且可以有返回值,仿真器选择的VCS。 编写C程序 #include <stdio.h> //#include "vpi_user.h" //使用PLI有两种机制:TF/ACC机制,或者VPI机制 void hello_calltf(int user_data, int reason) { int var,result; var = tf_getp(1);//取$hello调用时的第

253765952 5311

WEBRTC 的RTP/RTCP的 NACK, PLI,SLI,FIR

在网络环境不是太好的情况下,比如网络拥塞比较严重,丢包率可能比较高,简单实用NACK重传的机制,这样就会有大量的RTCP NACK报文,发送端收到相应的报文,又会发送大量指定的RTP报文,反而会增加网络的拥塞程度,可能导致更高的丢包率,导致接收端解码失败,导致花屏等马赛克现象。

thehunters的专栏 1762
上一篇: 第二部分 编写PLI应用程序(续)
下一篇: 第三部分 PLI 程序
study16
博客等级 码龄18年 18粉丝 55原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值