ghong6003的个人空间 https://blog.eetop.cn/1430538 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

SystemVerilog 与 C语言的接口

已有 2394 次阅读| 2018-6-11 06:05 |个人分类:Verification|系统分类:芯片设计

1. System verily 与C语言之间的数据传递
Verilog使用编程语言接口(Programming Language Interface)来跟C语言程序交互。
使用比较复杂。
SystemVerilog使用直接编程接口(Direct Programming Interface),他能跟家简单的连接C,C++或者其他非Ve ri lo g, 一旦使用import语句导入了一个C程序,就可以像调用SV中的子程序一样调用。

# 导入C程序
import “DPI-C” function int factorial (input int i)
program automatic test;
initial begin
$display("%d != %0d", i, factorial(i))
end
end:test

#改变导入程序的名字
program automatic test;
import “DPI-C” test = function void my_test();
initial my_test();
import “DPI-C” \expect=function int fexpect;
end:test

# 调用位置
被导入的程序将只有在它被声明的空间中有效。

# 参数方向
默认input,可为input,output,不可用ref。
可以将input变量声明为const, 一旦对input变量执行写操作便会出错。

# 参数类型
通过DPI传递的变量都有两个相匹配的定义,一个是SV的,一个是C的,必须相匹配。

# 导入数学库函数
import “DPI-C” function real sin(input real r);

2. 连接简单的C子程序


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 1

    关注
  • 3

    粉丝
  • 0

    好友
  • 2

    获赞
  • 1

    评论
  • 1539

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-3-28 21:41 , Processed in 0.017794 second(s), 15 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部