当前位置:   article > 正文

VIVADO仿真数据保存_vivado vio数据保存

vivado vio数据保存

在进行FPGA编程设计的时候,经常会将VIVADO仿真结果与MATLAB仿真结果对比的情况,这时就需要将VIVADO仿真数据保存下来,方法如下:

保存unsigned型无符号数据

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);    //使能信号有效,每来一个时钟,写入到所创建的文件中
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

路径部分需要自己修改
其中书写方式可以选择二进制“%b”或者十进制"%d"

保存signed型有符号数据

不默认情况下,%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));    //保存有符号数据
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

MATLAB读取txt文件

将生成的文件放在MATLAB当前目录下,在MATLAB命令行里直接用

vivado_data  =  importdata('data.txt');  %read files
  • 1

就可以读取txt文件了

相关连接:
https://blog.csdn.net/weixin_45475922/article/details/104903638

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/484496
推荐阅读
相关标签
  

闽ICP备14008679号