用matlab为modelsim生成数据源(VHDL)
来源:互联网 发布:华为网络机顶盒插上u盘 编辑:程序博客网 时间:2024/05/22 22:14
测试驱动开发,测试先行。
matlab可以很方便的为modlesim生成仿真数据,也可以非常方便的观察仿真的结果。
一、用matlab生成数据源的方法:
len=1024;
fs=50000000;
fc=1000000;
dfi=2*pi*fc/fs;
sig=sin((1:1:len)*dfi);
sig=int16(sig*1000);
fid=fopen('sigin.txt','wt');
fprintf(fid,'%d\n',sig);
fclose(fid);
二、在modelsim读取仿真数据以及输出仿真结果
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio;
use std.textio.all;
entity tb_datainout is
constant INPUT_FILE : string := "sigin.txt";
constant OUTPUT_FILE : string :="sigout.txt";
constant DATA_WIDTH : natural := 16;
end entity tb_datainout;
architecture rtl of tb_datainout is
signal data_inout : std_logic_vector (DATA_WIDTH-1 downto 0) := (others => '0');
signal clk : std_logic := '0';
constant tclk : time := 10 ns;
begin
clkgen : process
begin -- process clkgen
clk <= '0';
wait for tclk/2;
clk <= '1';
wait for tclk/2;
end process clkgen;
inoutmodel : process(clk) is
file in_file : text open read_mode is INPUT_FILE;
file out_file : text open write_mode is OUTPUT_FILE;
variable data_in : integer;
variable indata : line;
variable outdata : line;
variable data_out:integer;
begin
if rising_edge(clk) then
if not endfile(in_file) then
readline(in_file, indata);
read(indata, data_in);
data_inout <= std_logic_vector(to_signed(data_in, DATA_WIDTH)) after tclk/4;
else
data_inout <= data_inout after tclk/4;
end if;
data_out:= to_integer(signed(data_inout));
write(outdata, data_out);
writeline(out_file, outdata);
end if;
end process inoutmodel;
end architecture rtl;
- 用matlab为modelsim生成数据源(VHDL)
- 用matlab为modelsim生成数据源的方法
- 学习modelsim对vhdl仿真(10月9日)
- 使用Doxygen为VHDL工程生成文档模板
- 用fastjson为Ztree生成多级树形菜单JSON数据源
- 应用matlab&modelsim设计FPGA算法(1)
- vhdl实现寄存器的代码(生成的元件更少)
- matlab和modelsim联合仿真
- Matlab和Modelsim联合仿真
- matlab 联合modelsim 调试图片
- DDS-正弦-Modelsim和MATLAB
- Verilog转换为VHDL注意事项
- 【转】ModelSim生成fsdb文件
- Modelsim打开、生成VCD文件
- Modelsim打开、生成VCD文件
- 生成数据源
- PowerBuilder 11.5 以WebService为数据源生成数据窗口
- 用matlab生成样本
- Text Justification
- Sqrt(x)
- struts2的登录和退出
- 操作bytea类型
- Have Vim check automatically if the file has changed externally
- 用matlab为modelsim生成数据源(VHDL)
- cocos2d-x 实战 Dots ( 一 ) – 搭建主界面
- 小测Hyper Estraier性能
- 熬之滴水穿石:Servlet--Web万物之源(6)
- 黑马程序员-七千面试题交通管理系统
- 程序员:选择效率,还是选择质量?
- struts2生成session的方法:ActionContext.getContext().getSession()
- struts2值栈
- 检查点详解