赞
踩
在进行FPGA编程设计的时候,经常会将VIVADO仿真结果与MATLAB仿真结果对比的情况,这时就需要将VIVADO仿真数据保存下来,方法如下:
integer dout_file;
initial begin
dout_file=$fopen("路径/test.txt"); //打开所创建的文件
if(dout_file == 0)begin
$display ("can not open the file!"); //创建文件失败,显示can not open the file!
$stop;
end
end
always @(posedge clk)
if(data_valid) //使能
$fdisplay(dout_file,"%d",data); //使能信号有效,每来一个时钟,写入到所创建的文件中
路径部分需要自己修改
其中书写方式可以选择二进制“%b”或者十进制"%d"
不默认情况下,%d是unsigned型
如果想要保存signed型,可以将打印代码改为:
integer dout_file;
initial begin
dout_file=$fopen("路径/data.txt"); //打开所创建的文件
if(dout_file == 0)begin
$display ("can not open the file!"); //创建文件失败,显示can not open the file!
$stop;
end
end
always @(posedge clk)
if(abs_dout_valid)
$fdisplay(dout_file,"%d",$signed(num)); //保存有符号数据
将生成的文件放在MATLAB当前目录下,在MATLAB命令行里直接用
vivado_data = importdata('data.txt'); %read files
就可以读取txt文件了
相关连接:
https://blog.csdn.net/weixin_45475922/article/details/104903638
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。