Application Note on ROM

 

Background:

ROM can be used for storing and retrieving nonvolatile information in the Flex 10 K chips. This information is particularly helpful, when you are using a considerable number of constants, such as for a LCD display. ROM also does not require many logic cells.

This tutorial will guide you through the code, help you obtain hex numbers of the letters that you wish, help you set up an initialization file, and then simulate the code.

 

Step #1: The VHDL code for ROM

 

Since a lpm_rom function is to be used for ROM, the following code can be used for ROM.

Insert the following code into the Maxplus 2 text editor. Remember to save the file as ROMtest.vhd.

 

ROMtest.html 

This code requires an initialization file (step #2), which establishes the initial values. Upon simulation and giving the correct memory address, the code will output the associated values.

 

Step #2: Doing the initialization file

 

For this file, you can insert the following code into a romtest.mif file. This file will initialize the memory. The actual hex numbers that will be used in memory are described in step #3.

 rommif.html

 

Step #3: Obtaining hex numbers for ROM

 

For every letter or number that you wish to write into ROM, you will require a hex equivalent number. Since it can be cumbersome to calculate these hex numbers, Excel can easily do it for you. The attached Excel spreadsheet and text will demonstrate how these numbers can be calculated.

The sample spreadsheet is as follows:

Excelrom.html

 

Unfortunately, in the conversion from the Excel document to the html version, the Excel formulas are lost. Thus the following text will show you how to quickly and easily do the Excel calculations.

letter.html

Once you have done the steps mentioned in the letterconv.htm description, write the word temperature in cell A1. Your Excel spreadsheet should now look like the sample spreadsheet (Excelrom.htm).

 

Step #4: Inserting hex numbers into the initialization file

 

Once you have the hexadecimal numbers, you now need to insert the numbers into the romtest.mif file. Open the romtest.mif file and insert the appropriate numbers into the second column. You can use the hexadecimal number 20 for a space between the different words. The number 00 can be used as a delimiter. You can store up to 256 characters in memory.

Once you are done entering the numbers, save the romtest.mif file.

 

Step #5: Compiling and simulating

 

In this final step, you need to do the following items:

Compile the romtest.vhd code.

Create a new Waveform Editor file in Maxplus2.

Insert nodes from the Romtest.vhd code and set the following items:

Outclock and inclock to 40 ns periods Set the memenab to 1 and set the address to a 80 ns period.

Run the simulation and the result (q) should give the same hexadecimal numbers as the ones that were input into the initialization file.

The ROM results can now be used for other code.

 

You have now successfully worked with ROM.

 

Written by Erika Peter

If you have any questions or comments, please email me at epeter@ualberta.ca

 

Acknowledgements: I did receive help for figuring out ROM (from the Maxplus2 software, textbooks, and people