Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

LPM rom

Altera_Forum
Honored Contributor II
1,859 Views

hi, im new in quartus and vhdl. im trying to use the rom from the megafunction for my project. can i store real number in the rom? or it has to be hex? if it has to be hex, is it hav to be the ieee hex format?

0 Kudos
12 Replies
Altera_Forum
Honored Contributor II
882 Views

When you create the MIF (Memory initialization file) for the ROM, you will need to enter unsigned decimal numbers.

0 Kudos
Altera_Forum
Honored Contributor II
882 Views

thanks for the reply ! 

 

but if i have to use hex? is it the same? by the way, wats the different between hex and mif file?  

 

u mean unsigned decimal input...does that refer to integer only? what about real number with fraction??  

 

and the address to the rom..is it compulsory to be 16bit (4 hex)?
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

I tried creating a HEX file form Quartus II and it still says I need to use unsigned decimal numbers. You do not need to key in HEX for HEX file. You still use unsigned decimal. It has to be integer in this case. It's up to your design to interprete the fraction.

0 Kudos
Altera_Forum
Honored Contributor II
882 Views

thank you very much. 

 

but how do you create hex file with decimal number? i mean if hex i just do like: 

 

:03800000028100FA 

 

but if using decimal how? and if using decimal so the output of the rom shd be declared as integer? 

 

sorry for the trouble....
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

 

--- Quote Start ---  

thank you very much. 

 

but how do you create hex file with decimal number? i mean if hex i just do like: 

 

:03800000028100FA 

 

but if using decimal how? and if using decimal so the output of the rom shd be declared as integer? 

 

sorry for the trouble.... 

--- Quote End ---  

 

.mif and .hex are simply different file formats used to store the initialization data. 

 

A mif file looks like this 

 

WIDTH=8; 

DEPTH=256; 

 

ADDRESS_RADIX=UNS; 

DATA_RADIX=UNS; 

 

CONTENT BEGIN 

0 : 100; 

1 : 101; 

2 : 0102; 

[3..255] : 0; 

END; 

 

You can see the Address and data radix are set to UNS (Unsigned). This can be changed to HEX/Decimal etc. 

 

To make one of these Use the Quartus File menu->New->Other Files->Memory Initialization File 

 

and follow the prompts to build the size you want 

 

You can change the radix by right clicking on the data columns of the editor. 

 

You can also manually edit the generated mif file with text editors etc 

 

Hope this helps 

 

Vern
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

thank alot vernmid!  

seems like using mif is more convenient than hex file!  

i will try it out! thanks alot!!
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

hi, i have a question. 

it is possible the data for rom in signed number?
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

the data in a rom is just a load of bits, so it can represent anything you want.

0 Kudos
Altera_Forum
Honored Contributor II
882 Views

yes it is possible

0 Kudos
Altera_Forum
Honored Contributor II
882 Views

 

--- Quote Start ---  

When you create the MIF (Memory initialization file) for the ROM, you will need to enter unsigned decimal numbers. 

--- Quote End ---  

 

 

what its mean? i try to make a look up table content pre compute data... the data set in signed number... i try to using that MIF file, but it fail.. :confused: 

thank you with response from all...
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

The numbers in the MIF file is an unsigned binary number. That number has a signed equivolent, which is what you mean. You have to work out what the signed number is and in the mif file you put the unsigned equivolent. In the hardware it can mean whatever you want (because its just a load of bits). 

 

Its easier just to create a constant and write behavioural VHDL to instantiate the ROM, then you can write it however you want.
0 Kudos
Altera_Forum
Honored Contributor II
882 Views

tq tricky, 

i have 6 set of data n 256 word per set...  

so i think its much more easy for to using MIF file...
0 Kudos
Reply