您的位置:技术中心首页 > 逻辑验证 >> System Verilog DPI Example

System Verilog DPI Example

作者:未知   时间:2007-10-20 08:27:27  来自:网上转载  浏览次数:0  文字大小:【】【】【

String passing example

1) For illustration strings are used;
But strings can’t be used in module ports;
2) Use SystemVerilog “program” instead of “module” for testbenches.
See this: SystemVerilog program example

//  dpi_top.v
module top ();
import "DPI-C" context v2c_c=
task v2c_sv(input string a);
import "DPI-C" context c2v_c=
function string c2v_sv();
export "DPI-C" print_string_c =
function print_string_sv;
string v2c_string,c2v_string;
function void
print_string_sv(input string aaa);
$display("Exporting VerilogFunction:%s", aaa);
endfunction
initial
begin
v2c_string = "A v2c_string";
v2c_sv(v2c_string);
c2v_string = c2v_sv();
$display("c2v_string: %s n",
c2v_string);
$finish;
end
endmodule
//  dpi_main.c
#include <stdio.h>
#include "svdpi.h"
#include "dpi.h"
#include "veriuser.h"
void v2c_c(char* v2c_string)
{
io_printf("v2c_string: %sn",v2c_string);
print_string_c("string passed from C");
}
char* c2v_c(void)
{
char* c2v_string;
c2v_string="This is c2v_string";
//io_printf("c2v_string: %sn",
//c2v_string);
return c2v_string;
}
#####   shell script to run simulation
 ncverilog +sv dpi_top.v +elaborate +ncelabargs+-messages
 gcc -fPIC -shared -o dpi_main.so  dpi_main.c  -I/$CDS_INST_DIR/tools.lnx86/inca/include
 ncverilog +sv dpi_top.v +sv_lib=dpi_main.so +access+r +ncsimargs+"-sv_root ./"
责任编辑:5life

更多相关 verilog 的文章

Verilog讨论组精彩内容摘录 [2007-09-29]
verilog HDL 的阻塞和非阻塞语句分析 [2007-09-29]
Verilog 非阻塞赋值的仿真/综合问题 [2007-09-29]
Verilog的键盘源码keypad—有去抖功能 [2007-09-29]
Verilog 脉冲发生器程序 [2007-09-29]
Verilog 电梯控制器设计 [2007-09-29]
Verilog学习心得 [2007-09-29]
Verilog交通灯控制器程序 [2007-09-29]
一种基于移位寄存器的CAM的Verilog HDL实现 [2007-09-29]
SPI串行总线接口的Verilog实现 [2007-09-29]
本文共有0条评论,现在显示最新的5条。

栏目导航

电路基础
硬件语言
逻辑验证
电路综合
后端设计
可测设计
基本逻辑
制造封装
总线协议
说文解字
工具学习
数字滤波
闲话漫谈
数字锁相
设计杂项
低耗设计

站点最新

更多相关链接

  System Verilog DPI Example
  Modelsim仿真中的 vsim-...
  debussy 输入的方式
  NC 命令速查
  利用ModelSim SE6.0C实现...
  如何仿真IP核(建立mode...
  Modelsim 包会教程
  ModelSim仿真库问题
  Modelsim 的验证实例
  ModelSim SE操作指南

栏目最新

更多相关链接

  System Verilog DPI Example
  Modelsim仿真中的 vsim-...
  debussy 输入的方式
  NC 命令速查
  利用ModelSim SE6.0C实现...
  如何仿真IP核(建立mode...
  Modelsim 包会教程
  ModelSim仿真库问题
  Modelsim 的验证实例
  ModelSim SE操作指南

热点文章

更多相关链接

  Modelsim 教程
  Debussy 教程
  Verilog PLI教程 --- 第一部...
  Verilog PLI教程 --- 第二部...
  提高NC-Verilog仿真效率的技巧
  Verilog Pli的基本使用方法(...
  Verilog PLI教程 --- 第五部...
  Verilog PLI教程 --- 第七部...
  Verilog PLI教程 --- 第三部...
  Ncverilog 命令使用详解