Mudanças entre as edições de "Inicialização de memória com arquivos .MIF e .HEX"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
Linha 27: Linha 27:
 
*Digite o texto seguindo as regras de sintaxe descritas abaixo.
 
*Digite o texto seguindo as regras de sintaxe descritas abaixo.
 
*No menu [File], clique em [Save as...] e na caixa de diálogo, salve o arquivo com a extensão .mif.
 
*No menu [File], clique em [Save as...] e na caixa de diálogo, salve o arquivo com a extensão .mif.
 
==To create a Memory Initialization File in the Quartus II Text Editor:==
 
*On the File menu, click New.
 
*In the New dialog box, click the + icon to expand the Other Files item.
 
*Under Other Files, select Text File, and then click OK.
 
*Enter text for the Memory Initialization File in the Quartus II Text Editor following the syntax rules described above.
 
*In the Quartus II Text Editor, on the File menu, click Save As.
 
*In the Save As dialog box, save the file with the extension .mif to designate it as a Memory Initialization File.
 
  
 
=Memory Initialization File (.mif)=
 
=Memory Initialization File (.mif)=

Edição das 20h55min de 28 de junho de 2012

Criando arquivos de inicialização de memória hexadecimal (Intel-Format)

O Editor de memória permite-lhe introduzir, ver e editar o conteúdo da memória de um bloco de memória do dispositivo Altera implementado em um arquivo de inicialização da memória (.mif) ou hexadecimal (.hex) arquivo no formato Intel. No Editor de memória, você pode preencher as células selecionadas com hexadecimal, binário, octal, ou valores decimais; editar células individuais, ou preencher um intervalo de endereços com uma seqüência de repetição de valores a partir de um ponto de partida. incrementando ou decrementando valores. Além disso, tanto no Editor de memória como no Editor de Texto, você pode associar aos bits "x" para indicar "don't care" e "u" para "never match". Quando você tem um número binário, por exemplo: 1x1u 1100, o "x" indica um bit "don't care" no qual tanto o valor "1" como o "0" são permitidos. Um endereço binário com bits do tipo "don't care" ou "never match" não pode totalmente convertido em endereço real. A porção do endereço que não pode ser convertido é preenchido com símbolos "x". No Editor de memória as palavras de dados que contêm bits do tipo "don't care" ou "never match" podem perder alguma precisão dos seus valores.

FONTE: http://quartushelp.altera.com/9.1/mergedProjects/design/med/med_pro_med_files.htm

Criação do arquivo .mif e .hex no Editor de Memória Quartus II

O procedimento para a criação de um arquivo de memória no Quartus II é descrita a seguir:

  • No menu [File], clique em [New].
  • Na caixa de diálogo [New], clique no ícone [+] para expandir o item [Memory Files].
  • Em [Memory Files], selecione o tipo desejado e clique em [OK].
  • Digite o número de palavras e o tamanho da palavra e clique em [OK].
  • O editor de memória apresentará a memória com os endereços todos preenchidos com zero.
  • No menu [File], clique em [Save] e na caixa de diálogo, salve o arquivo com a extensão .mif.

Configurando o editor de Memória. No menu [View] é possivel alterar a forma como os dados da memória são visualizados.

  • Para ver os equivalentes ASCII do conteúdo das memórias, clique em [Show ASCII Equivalents].
  • Para rearranjar a disposição, use [Cell per Row], [Address Radix] e [Memory Radix].
  • Usando o [Show Delimiter Spaces], você inserirá um espaço entre cada 4 (ou 2) digitos quando o radix é binário (ou hexadecimal).
  • Algumas das funções do menu [View] são acessíveis clicando com o botão direito do mouse no editor de memória.
  • Experimente as possíveis variações do menu [View]

Criação do arquivo .mif no Editor de Texto do Quartus II

  • No menu [File], clique em [New].
  • Na caixa de diálogo [New], clique no ícone [+] para expandir o item [Other Files].
  • Em [Other Files], selecione [Text File] e clique em [OK].
  • Digite o texto seguindo as regras de sintaxe descritas abaixo.
  • No menu [File], clique em [Save as...] e na caixa de diálogo, salve o arquivo com a extensão .mif.

Memory Initialization File (.mif)

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; </syntaxhighlight>

<html>

<colgroup><col> <col> <col class="whs15"> </colgroup><tbody> </tbody>

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

</html>

FONTE: http://quartushelp.altera.com/9.1/mergedProjects/reference/glossary/def_mif.htm

Hexadecimal (Intel-Format) File (.hex)

An ASCII text file (with the extension .hex). A Hexadecimal (Intel-Format) File can be used in the Quartus II software to store the initial memory values for a memory block, such as CAM, RAM, or ROM, that is implemented in an Altera device, or to build software project executables.

Hexadecimal (Intel-Format) Files are used as input files in the Quartus II software in the following ways:

The Memory Editor can create a Hexadecimal (Intel-Format) File for memory initialization in the Compiler and Simulator. You can also use a Memory Initialization File (.mif) to provide memory initialization data.

The In-System Memory Content Editor can use and create a Hexadecimal (Intel-Format) File to import and export data.

You can store configuration data for one or more Altera devices in an output file called a Hexadecimal (Intel-Format) Output File (.hexout). The Hexadecimal (Intel-Format) Output File format is an ASCII text file with the extension .hexout to avoid overwriting initial memory content files that have the extension .hex.

The data width of a Hexadecimal (Intel-Format) File is always a multiple of 8 bits. When you initialize a memory block that is not the same width as the Hexadecimal (Intel-Format) File, the Quartus II software wraps or pads the file as described below:

<html>

<colgroup><col class="whs15"> <col class="whs15"> </colgroup><tbody> </tbody>

File data width greater than memory width

File data width smaller than memory width

Memory size is a multiple of 8:

  • When the Hexadecimal (Intel-Format) File data width is a multiple of the memory width, the Quartus II software wraps the data to subsequent addresses.
     

  • When the Hexadecimal (Intel-Format) File data width is not a multiple of the memory width, the Quartus II software pads the data to a multiple of the memory width just greater than the Hexadecimal (Intel-Format) File data width.

    For example, with a memory width of 24 (Address: 040000002A124FFF72) and a Hexadecimal (Intel-Format) File data width of 32 (Address: 00000001FF), the Quartus II software pads the 32 bit Hexadecimal (Intel-Format) File data width to 48 bits (the multiple of 24 just greater than 32), and then wraps the 48 bits around the 24 bit memory width, resulting in:

    Address: 00002A
    Address: 124FFF

Memory size is not a multiple of 8:

 

The Quartus II software wraps the data to the memory width equal to the multiple of 8 and just greater than the actual memory width, and then truncates the memory block to the actual size of the memory width, which is not a multiple of 8.

  • RAM / ROM<symbol name="Em Dash">—The Quartus II software pads the memory block with zeroes next to the MSB (most significant bit).
     </symbol>

  • MAX II User Flash Memory (UFM)<symbol name="Em Dash">—The Quartus II software pads the memory block with ones next to the LSB (least significant bit).</symbol>

</html>

If the size of the Hexadecimal (Intel-format) File does not match the size of the memory you are initializing, the Quartus II software performs as described below:

<html>

<colgroup><col class="whs21"> <col class="whs21"> </colgroup><tbody> </tbody>

File data depth greater than memory depth

File data depth smaller than memory depth

Ignores extra data.

  • RAM / ROM<symbol name="Em Dash">—The Quartus II software initializes the addresses with no data to zero.</symbol>

  • MAX II User Flash Memory (UFM)<symbol name="Em Dash">—The Quartus II software initializes the addresses with no data to the hexadecimal value of <F...F>.</symbol>

</html>

Note: File data depth refers to the number of addresses that you are initializing. The Quartus II software fills addresses that you are not initializing with zeros or <F...F>, depending on whether it is UFM or not.

Note: In the Quartus II software, you have the option of reading or writing Hexadecimal (Intel-Format) Files in the byte addressable (Intel hexadecimal format) mode, or the word-addressable mode. You can choose between the two modes by changing the Read or write Hexadecimal Files (.hex) using byte addressing (Intel format) option in the Quartus II software. Setting this option in the More Compilation Process Settings dialog box in Settings dialog box applies only to the current project. Alternatively, you can apply this option to any Quartus II project with settings in the Memory Editor page in the Options dialog box. Turning on this option for the current project overrides the global setting.

The Quartus II software always reads word addressable Hexadecimal (Intel-Format) Files in the word addressable mode even if the Read or write Hexadecimal Files (.hex) using byte addressing (Intel format) option is turned on.

FONTE: http://quartushelp.altera.com/9.1/mergedProjects/reference/glossary/def_hexfile.htm