Altera_Forum
Honored Contributor
11 years agoRandom number generation and indexing into RAM/ROM block
Altera Gurus,
I am developing a random pulse generator based on certain external inputs. The pulse generator will be implemented on a Cyclone III device and coded in VHDL using Quartus. The amplitude of these pulses are controlled by an external amplitude spectra. This will be stored in .mif files which will be used to initialize ROM/RAM blocks. I have implemented a 2^16 pseudo-random number generator based on the LFSR method. These random numbers map to a certain amplitude. These mappings are stored in the .mif file. The mapping is many-to-one; many random numbers map to the same amplitude. An example is shown below to explain the logic: x[0] = 1 x[1] = 5 x[2] = 10 In my code, if I generate a random number between 1 and 5, then my amplitude will be 1. Similarly if a random number is generated between 5 and 10, the amplitude will be 2. So the amplitude is the index+1. I am having trouble implementing this logic in VHDL. It's not a true ROM/RAM in the sense that the "address" being input to the ROM/RAM block is not the index, but is used to determine the index. For now I have for-loop which basically runs through the entire array, compares the random number to the values in the array, and outputs the index. However, Quartus will no longer synthesize a ROM/RAM block with this logic. Plus I would have to declare a massive constant array (256 values) to implement this since I didn't see a way to initialize a constant array from a .mif file. Any ideas/thoughts as to how I can implement this logic by using RAM/ROM blocks and for-loops? I've drawn a crude picture of what I want to implement. https://www.alteraforum.com/forum/attachment.php?attachmentid=9328