当前位置:网站首页>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分析数据结果

边栏推荐
猜你喜欢

Biotin-Dadps-azide|CAS:1260247-50-4|生物素-DADPS-叠氮

原力计划微服务实战|集中配置中心Config非对称加密与安全管理

This beta version of Typora is expired, please download and install a newer; workaround

测试第一题

快速开发 GraphScope 图分析应用

xxx is not in the sudoers file.This incident will be reported error

Unity 渲染流水线

Biotin-PEG4-SS-Alkyne_1260247-54-8_生物素-PEG4-SS-炔烃

【已解决:el-input标签无法输入或不显示文字】

【Exhibition of some projects】
随机推荐
(*(void (*)())0)() Interpretation
Graph analysis like NetworkX with GraphScope
[Common usage of markdown]
Desthiobiotin-PEG4-Acid|脱硫生物素-PEG4-酸| 供应商和制造商
How to import matlab data into modelsim simulation
实现二叉树--实现删除
【部分项目展示】
基于STM32F103的消防系统之驱动电机风扇
Knowledge of the day: handwritten deep copy and shallow copy (solves the problem of circular references)
This beta version of Typora is expired, please download and install a newer;解决方法
Biotin-SS-NHS ester|生物素-二硫键-活性酯|CAS:122266-55-1具有良好的水溶性
阿里京东“喜提”国电投,顶流互联网和能源大厂为何合作?
c语言编程练习
memset()函数的使用总结和细节
[Quick MSP430f149] Notes on learning MSP430f149 during the game
GAIA-IR:GraphScope 上的并行化图查询引擎
sizeof和strlen最全区别,以及指针和数组运算解析
PC DBCO-PEG3-Biotin|PC-生物素-PEG3-DBCO可用于使用无铜点击化学
数码管动态显示及模块化编程
Biotin-PEG4-SS-Alkyne_1260247-54-8_生物素-PEG4-SS-炔烃