我有一个基于verilog的测试平台,使用DPI连接到'C源代码.现在使用DPI我打算编写我的整个固件.要做到这一点,我需要3件事
我检查了大多数cadence文档,发现没有有用的提示.我还注册了cadence用户社区,但似乎在他们批准我的注册之前我不能提出问题.
万一有人意识到这一点,将不胜感激他们的帮助.
hardware verification verilog system-verilog system-verilog-dpi
如何从源代码中检测模拟中使用的时间刻度精度?考虑我有一个配置参数(cfg_delay_i),由用户以时间单位给出的一些延迟值作为fs。如果用户给出1000,我的代码在进一步执行之前必须等待1000fs 或 1ps。
#(cfg_delay_i * 1fs );//will wait only if timescale is 1ps/1fs
do_something();
Run Code Online (Sandbox Code Playgroud)
如果时间刻度精度为1fs,则不会有任何问题,但如果精度高于该精度,则不会等待,它将作为0 delay工作。所以我想编写一个代码来确定用户使用的时间刻度并相应地给出延迟。我预期的伪代码如下所示,
if(timeprecision == 1fs )#(cfg_delay_i * 1fs ) ;
else if(timeprecision == 1ps )#(cfg_delay_i/1000 * 1ps ) ;
Run Code Online (Sandbox Code Playgroud)
请帮助我确定内部时间刻度单位和精度的逻辑。
我的目标是用C++填充一个开放的数组.阶段如下.1. SV:定义一个大小的解压缩数组,并通过导入函数中的开放数组发送它.2. C++:填充打开的数组.3. SV:使用阵列.
对于大小的解压缩阵列,没有问题.但在实际情况下,数组大小经常更改,并且每次都必须重新编译已编译的C++函数.为了避免这种情况,我需要使用一个开放数组,以便C函数检查大小并相应地填充数据.
在下文中,简化了源,仅显示了基本部分.导入函数svcpp在SV调用并在C++中执行.参数是open数组i [],其句柄是C++方面的h.当我编译C++源代码时,会发生错误,"错误LNK1120:未解析的外部".
问题是什么?
SV方面:
module
import "DPI-C" context function void svcpp (inout byte unsigned i[]);
byte myarray[2];
initial
svcpp(myarray);
endmodule
Run Code Online (Sandbox Code Playgroud)
C++方面:
#include "svdpi.h"
#include "dpiheader.h"// This includes the data structure for the open array
void svcpp(const svOpenArrayHandle h){
//*(uchar *) x = *(uchar *) svGetArrElemPtr(h,0);
*(uchar *) svGetArrElemPtr(h,1) = 10; //I really want this operation.
}
Run Code Online (Sandbox Code Playgroud) System Verilog中的DPI功能总是提到您可以使用任何语言进行连接,最常见的是C/C++语言.我想用Ruby连接我的系统Verilog代码.是否有任何文档或支持此功能?有任何已知的方法吗?
我应该补充一点,我的主要目标是从我的系统Verilog uvm测试中调用ruby脚本.
谢谢
我有以下文件:
带有功能的C文件:
// funcs.c
#include <stdio.h>
void something() {
printf("something\n");
sayHello();
}
Run Code Online (Sandbox Code Playgroud)
系统verilog文件:
// hello_world.v
module kuku;
export "DPI-C" function sayHello;
import "DPI-C" function void something();
initial something();
function int sayHello ();
$display("hello world");
sayHello = 1;
endfunction
endmodule
Run Code Online (Sandbox Code Playgroud)
如何编译它并使其工作,所以当我something()从SV 调用时,它将调用C函数,当我sayHello()从C 调用时,它将调用SV函数?
uvm ×2
c ×1
c++ ×1
hardware ×1
modelsim ×1
ruby ×1
synopsys-vcs ×1
verification ×1
verilog ×1
visual-c++ ×1