Matlab VCS 联合仿真

算法工程通常会用Matlab来建模,Digital designer会将Matlab model 作为golden model 进行设计和验证。 面临的问题时VCS不用能直接调用.m文件。 这就需要先将.m文件生成System Verilog的DPI或转成Cpp文件,之后就可以在SystemVerilog 中直接调用了

(1) Matlab 生成DPI

下面是两个matlab function,分别在两个独立文件中

function y = fun(x)

y = x * 2;

end

 

function sample=fun_tb

% Testbench should not require input, however you can give an output.

% Define a test vector

tVecIn = [1,2,3,4,5];

% Exercise fun.m and plot results to make sure function is working correctly

tVecOut = arrayfun(@(in) fun(in),tVecIn);

plot(tVecIn,tVecOut);

grid on;

% Get my sample input to use it with function dpigen.

sample = tVecIn(1);

end

 

生成DPI的命令

dpigen fun -args {int8(0)}  -testbench fun_tb

若不需要生成test_bench,则用命令

dpigen fun -args{int8(0)}

在run_tb_vcs.sh中可看到生成的DPI库

 

 

(2)用coder 将.m 转成Cpp或C 有VCS 统一编译

coder

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值