当前位置:网站首页>How to save modelsim simulation data as a file
How to save modelsim simulation data as a file
2022-07-30 07:35:00 【FPGA - Signal Processing】
目的
如何将modelsimThe simulated data is stored as a filematlab分析,In practical engineering applications, we often need to analyze the newly generated data in the simulation process,When the naked eye cannot directly observe the data, it is necessary to save the data as a file and use third-party software for more intuitive analysis.下面分别使用matlab和modelsim联合仿真,将modelsimThe simulation data is saved as a file for usematlab对数据进行分析.
verilog代码
`timescale 1ns/1ps
module testbench();
localparam LEN = 8192 ;
reg [15:0] adc_dat[8191:0] ;
reg clk ;
reg rst ;
reg [12:0] cnt ;
reg [15:0] sim_dat ;
reg [15:0] wr_cnt ;
initial begin
$readmemh("./adc_dat.bin", adc_dat, 0, LEN-1);
end
initial begin
clk = 0;
rst = 1;
cnt = 0;
sim_dat = 0;
#1000;
rst = 0;
end
always #2.00 clk = ~clk ;
[email protected](posedge clk)
begin
if(rst) begin
cnt <= 0;
end
else begin
cnt <= cnt + 1;
sim_dat <= adc_dat[cnt];
end
end
integer fp;
initial begin
fp =$fopen("adc_export_dat.bin", "w");
end
[email protected](posedge clk)
begin
if(rst) begin
wr_cnt <=0;
end
else begin
if(wr_cnt < 8192) begin
wr_cnt <=wr_cnt + 1;
end
if(wr_cnt < 8192) begin
$fwrite(fp, "%d\n", $signed(adc_dat[wr_cnt]));
end
end
end
endmodule
It can be seen from the code that we directly store the data read from the file as a file(The reading process of the file is described in the previous article如何将matlabGenerate data importmodelsim进行仿真)
matlabAnalysis data code
clc;
clear all;
close all;
adc_dat = load('adc_export_dat.bin');
len = length(adc_dat);
subplot(211);
plot(adc_dat);
subplot(212);
fft_data = abs(fft(adc_dat, len));
fft_data = 20*log10(fft_data);
fft_data = fft_data - max(fft_data);
plot(fft_data);
matlab分析数据结果

边栏推荐
- 图扑软件数字孪生民航飞联网,构建智慧民航新业态
- 矩阵键盘
- 事件传递和响应者链条
- QT serial port dynamically displays a large number of data waveform curves in real time (5) ======== "Final perfect solution version"
- xxx is not in the sudoers file.This incident will be reported error
- Unity Shader 空间坐标系
- Unity Gizmos扩展:线框圆
- 用于标记蛋白质和抗体的Biotin-LC-Sulfo-NHS|CAS:191671-46-2
- PC DBCO-PEG3-Biotin|PC-生物素-PEG3-DBCO可用于使用无铜点击化学
- 2021-05-26
猜你喜欢
随机推荐
VSCode hides the left activity bar
掌握JESD204B(一)–AD6676的调试
[Quick MSP430f149] Notes on learning MSP430f149 during the game
Unity Shader 标准光照模型——漫反射
网络协议03 - 路由和NAT
memset()函数的使用总结和细节
(*(void (*)())0)() Interpretation
04-加壳和脱壳
D-Desthiobiotin Amine_D-脱硫生物素-胺相关的产品性质
顺序二叉树---实现数组的二叉树前序遍历输出
C language, usage of qsort in library function, and explanation
instantDrag for Maya脚本 (移动模型时沿目标模型移动)
Cas 80750-24-9,去硫代生物素 N-羟基琥珀酰亚胺,淡黄色固体
爬楼梯C语言
C#最优二叉树----哈夫曼树
THREEJS导入外部OBJ+MTL后内存优化
为数字政府构建智能化网络安全管控体系
Azide-SS-biotin|CAS:1620523-64-9|生物素-二硫键-叠氮可降解 (cleavable) 的 ADC linke
FPGA parsing B code----serial 2
单向链表的操作(带头结点)









