FPGA中.mif文件的创建和使用
2013-01-02 09:51
429 查看
FPGA设计中ROM的应用时比较常见的,在调用ROM时经常要加载mif文件,对于初学者,无论mif还是hex都是很令人疑惑的东西,这里就对mif文件的格式及其创建做一点简单的说明。
mif在fpga设计中试memory initialization file 的缩写,中文意思就是存储器初始化文件。直接说就是给rom赋值的文件。先看一个简单的mif文件的内容(可以用记事本将mif文件打开,看到里面的代码):
DEPTH=256; %存储器的纵向容量,就是存多少个数据,本例中是256个
WIDTH=8 ; %存储器的横向宽度,就是每个数据多少位,8位宽
ADDRESS_RADIX=DEC ; %设置地址基值(实际就是地址用什么进制的数表示) 可以设为BIN(二进制),OCT(八进制),DEC(十进制),HEX(十六进制)
DATA_RADIX=DEC ; %设置数据基值 同上
%数据区里的地址和数据值要和这里设置的值一致,即这里如果设置了
%DEC那么,数据区的地址和数据都要用十进制来表示。
CONTENT %开始数据区
BEGIN
0:0; %前面是地址,后面是数据,都是用十进制表示(上面的DEC)
1:1;
……%如果表示成这样 [0..255]:10; 意思就是从0到255都是数据10.
255:255;
END; %结束
至于mif文件的创建,最简单的方法就是用记事本了。也可以在Quartus II 里新建,然后保存。
mif文件的使用,在bdf模块调用中找出lpm_ROM 在有一项设置中要添加文件那里加入就可以用了。
----------------------------
以下这些据说是Altera的官方说明;
Memory Initialization File (.mif) Definition
An ASCII text file (with the extension .mif) that specifies the initial content of a memory block (CAM, RAM, or ROM), that is, the initial values for each address. This file is used during project compilation and/or simulation. You can create a Memory Initialization File in the Memory Editor, the In-System Memory Content Editor, or the Quartus II Text Editor.
A Memory Initialization File serves as an input file for memory initialization in the Compiler and Simulator. You can also use a Hexadecimal (Intel-Format) File (.hex) to provide memory initialization data.
A Memory Initialization File contains the initial values for each address in the memory. A separate file is required for each memory block. In a Memory Initialization File, you must specify the memory depth and width values. In addition, you can specify data radixes as binary (BIN), hexadecimal (HEX), octal (OCT), signed decimal (DEC), or unsigned decimal (UNS) to display and interpret addresses and data values. Data values must match the specified data radix.
When creating a Memory Initialization File in the Quartus II Text Editor, you must start with the DEPTH, WIDTH, ADDRESS_RADIX and DATA_RADIX keywords. You can use Tab "\t" and Space " " characters as separators, and insert multiple lines of comments with the percent "%" character, or a single comment with double dash "--" characters. Address : data pairs represent data contained inside certain memory addresses and you must place them between the CONTENT BEGIN and END keywords, as shown in the following examples.
% multiple-line comment
multiple-line comment %
-- single-line comment
DEPTH = 32; -- The size of data in bits
WIDTH = 8; -- The size of memory in words
ADDRESS_RADIX = HEX; -- The radix for address values
DATA_RADIX = BIN; -- The radix for data values
CONTENT -- start of (address : data pairs)
BEGIN
00 : 00000000; -- memory address : data
01 : 00000001;
02 : 00000010;
03 : 00000011;
04 : 00000100;
05 : 00000101;
06 : 00000110;
07 : 00000111;
08 : 00001000;
09 : 00001001;
0A : 00001010;
0B : 00001011;
0C : 00001100;
END;
% multiple-line comment
multiple-line comment %
-- single-line comment
DEPTH = 32; -- The size of data in bits
WIDTH = 8; -- The size of memory in words
ADDRESS_RADIX = HEX; -- The radix for address values
DATA_RADIX = BIN; -- The radix for data values
CONTENT -- start of (address : data pairs)
BEGIN
00 : 00000000; -- memory address : data
01 : 00000001;
02 : 00000010;
03 : 00000011;
04 : 00000100;
05 : 00000101;
06 : 00000110;
07 : 00000111;
08 : 00001000;
09 : 00001001;
0A : 00001010;
0B : 00001011;
0C : 00001100;
END;
Address : Data Pairs Syntax Rules
Definition
Example
A : D
Addr[A] = D
2 : 4
Address: 01234567
Data: 00400000
[A0..A1] : D
Addr[A0] to [A1] contain data D
[0..7] : 6
Address: 01234567
Data: 66666666
[A0..A1] : D0 D1
Addr[A0] = D0,
Addr[A0+1] = D1,
Add [A0+2] = D0,
Addr[A0+3] = D1,
until A0+n = A1
[0..7] : 5 6
Address: 01234567
Data: 56565656
A : D0 D1 D2
Addr[A] = D0,
Addr[A+1] = D1,
Addr[A+2] = D2
2 : 4 5 6
Address: 01234567
Data: 00456000
转自:http://hi.baidu.com/chentao841117/item/3b924522a2ef21130975084b
mif在fpga设计中试memory initialization file 的缩写,中文意思就是存储器初始化文件。直接说就是给rom赋值的文件。先看一个简单的mif文件的内容(可以用记事本将mif文件打开,看到里面的代码):
DEPTH=256; %存储器的纵向容量,就是存多少个数据,本例中是256个
WIDTH=8 ; %存储器的横向宽度,就是每个数据多少位,8位宽
ADDRESS_RADIX=DEC ; %设置地址基值(实际就是地址用什么进制的数表示) 可以设为BIN(二进制),OCT(八进制),DEC(十进制),HEX(十六进制)
DATA_RADIX=DEC ; %设置数据基值 同上
%数据区里的地址和数据值要和这里设置的值一致,即这里如果设置了
%DEC那么,数据区的地址和数据都要用十进制来表示。
CONTENT %开始数据区
BEGIN
0:0; %前面是地址,后面是数据,都是用十进制表示(上面的DEC)
1:1;
……%如果表示成这样 [0..255]:10; 意思就是从0到255都是数据10.
255:255;
END; %结束
至于mif文件的创建,最简单的方法就是用记事本了。也可以在Quartus II 里新建,然后保存。
mif文件的使用,在bdf模块调用中找出lpm_ROM 在有一项设置中要添加文件那里加入就可以用了。
----------------------------
以下这些据说是Altera的官方说明;
Memory Initialization File (.mif) Definition
An ASCII text file (with the extension .mif) that specifies the initial content of a memory block (CAM, RAM, or ROM), that is, the initial values for each address. This file is used during project compilation and/or simulation. You can create a Memory Initialization File in the Memory Editor, the In-System Memory Content Editor, or the Quartus II Text Editor.
A Memory Initialization File serves as an input file for memory initialization in the Compiler and Simulator. You can also use a Hexadecimal (Intel-Format) File (.hex) to provide memory initialization data.
A Memory Initialization File contains the initial values for each address in the memory. A separate file is required for each memory block. In a Memory Initialization File, you must specify the memory depth and width values. In addition, you can specify data radixes as binary (BIN), hexadecimal (HEX), octal (OCT), signed decimal (DEC), or unsigned decimal (UNS) to display and interpret addresses and data values. Data values must match the specified data radix.
When creating a Memory Initialization File in the Quartus II Text Editor, you must start with the DEPTH, WIDTH, ADDRESS_RADIX and DATA_RADIX keywords. You can use Tab "\t" and Space " " characters as separators, and insert multiple lines of comments with the percent "%" character, or a single comment with double dash "--" characters. Address : data pairs represent data contained inside certain memory addresses and you must place them between the CONTENT BEGIN and END keywords, as shown in the following examples.
% multiple-line comment
multiple-line comment %
-- single-line comment
DEPTH = 32; -- The size of data in bits
WIDTH = 8; -- The size of memory in words
ADDRESS_RADIX = HEX; -- The radix for address values
DATA_RADIX = BIN; -- The radix for data values
CONTENT -- start of (address : data pairs)
BEGIN
00 : 00000000; -- memory address : data
01 : 00000001;
02 : 00000010;
03 : 00000011;
04 : 00000100;
05 : 00000101;
06 : 00000110;
07 : 00000111;
08 : 00001000;
09 : 00001001;
0A : 00001010;
0B : 00001011;
0C : 00001100;
END;
% multiple-line comment
multiple-line comment %
-- single-line comment
DEPTH = 32; -- The size of data in bits
WIDTH = 8; -- The size of memory in words
ADDRESS_RADIX = HEX; -- The radix for address values
DATA_RADIX = BIN; -- The radix for data values
CONTENT -- start of (address : data pairs)
BEGIN
00 : 00000000; -- memory address : data
01 : 00000001;
02 : 00000010;
03 : 00000011;
04 : 00000100;
05 : 00000101;
06 : 00000110;
07 : 00000111;
08 : 00001000;
09 : 00001001;
0A : 00001010;
0B : 00001011;
0C : 00001100;
END;
Address : Data Pairs Syntax Rules
Definition
Example
A : D
Addr[A] = D
2 : 4
Address: 01234567
Data: 00400000
[A0..A1] : D
Addr[A0] to [A1] contain data D
[0..7] : 6
Address: 01234567
Data: 66666666
[A0..A1] : D0 D1
Addr[A0] = D0,
Addr[A0+1] = D1,
Add [A0+2] = D0,
Addr[A0+3] = D1,
until A0+n = A1
[0..7] : 5 6
Address: 01234567
Data: 56565656
A : D0 D1 D2
Addr[A] = D0,
Addr[A+1] = D1,
Addr[A+2] = D2
2 : 4 5 6
Address: 01234567
Data: 00456000
转自:http://hi.baidu.com/chentao841117/item/3b924522a2ef21130975084b
相关文章推荐
- 文件服务器的配置与管理(3) 共享文件夹的创建与使用
- fatal error C1047: 对象或库文件“EDLib.lib”是使用比创建其他对象所用编译器旧的编译器创建的
- fpga rom 初始化mif文件生成
- .NET2005中使用XSD文件创建自定义DataSet
- git使用简记-git创建本地仓库及增删改文件操作
- 使用IO流创建文件并写入数据
- [原]使用Win API创建顶级菜单(不使用资源文件)
- Git使用教程2:版本库的创建和添加文件
- Laravel 使用autoload创建辅助函数文件
- 实例讲解.NET中资源文件的创建与使用
- 使用XmlTextWriter与XmlTextReader访问创建和读取XML文件
- 使用java自带的java.util.logging创建日志类,支持保存日志到文件和mysql
- Delphi中资源文件的创建与使用
- Linux动态链接库.so文件的创建与使用
- java中使用zip4j创建带密码保护的文件
- 多学一点(九)——使用touch命令创建指定时间的文件
- 使用xib文件创建UITableViewCell
- iOS开发技巧:PCH文件的创建于使用
- 静态、动态库的创建使用与makefile配置文件的编写