![](https://csdnimg.cn/release/download_crawler_static/86637484/bg1.jpg)
用 MATLAB 生成*.mif、*.hex(QUARTUS II)文件简介(v1.1)
macro_qian@yahoo.com.cn
以前写过一个“用 MATLAB 生成*.mif、*.hex(QUARTUS II)文件简介”,由于时间和
水平原因很粗糙,并且有一些错误。现在修改一下,升级到 v1.1。以前的称为 v1.0 吧。
做 FPGA 设计时经常要调用芯片内存。特别对于 ROM,内存的初始化就显得比较重要。
当然你完全可以手工在 QUARTUS II 打开 mif 文件的表格里逐个输入,几十项或许你还可以
接受,但上千项估计能累的人吐血!
一般内存的初始化数据都是有规律的,符合一定的函数,我们完全可以用 MATLAB 来
完成(如果没规律只能逐项手工输入了)。
1. 使用 MATLAB 直接生成*.mif 文件
首先,我们应该知道*.mif 文件的格式。它是文本格式。随便打开一个 mif 文件,你会
发现它具有如下的格式:
-- Copyright (C) 1991-2008 Altera Corporation
-- Your use of Altera Corporation's design tools, logic functions
-- and other software and tools, and its AMPP partner logic
-- functions, and any output files from any of the foregoing
-- (including device programming or simulation files), and any
-- associated documentation or information are expressly subject
-- to the terms and conditions of the Altera Program License
-- Subscription Agreement, Altera MegaCore Function License
-- Agreement, or other applicable license agreement, including,
-- without limitation, that your use is for the sole purpose of
-- programming logic devices manufactured by Altera and sold by
-- Altera or its authorized distributors. Please refer to the
-- applicable agreement for further details.
-- Quartus II generated Memory Initialization File (.mif)
WIDTH=8;
DEPTH=256;
ADDRESS_RADIX=UNS;
DATA_RADIX=DEC;
CONTENT BEGIN
[0..3] : 127;
[4..6] : 126;
[7..8] : 125;
9 : 124;
评论1