Altera_Forum
Honored Contributor
14 years agoHandling large arrays in VHDL
I have a constant array of integers (2^8 words deep) declared in VHDL. Each entry is a random number in the range 0-65535. There is a nonlinear mapping between the random numbers and the index of the array. For instance if the array is
0: 1 1: 4 2: 19 3: 54 ... and my random number generator generates the value 24, the output is 2. If the number is 10, the output is 1 and so on. For now I have a for loop that goes through the whole array to determine the index for which the Random_Number >= Array(I). I was wondering whether there is an alternative to this implementation since I want to reduce the amount of combinational logic used by the design. I have thought about a ROM but this is not a ROM in the traditional sense since the random number is not an "address" into the array. Alternatively, I could declare an array that is 2^16 words deep and can be indexed using the random number. This would essentially synthesize a ROM block in Quartus. But in case I have multiple such arrays, I'm going to run out of internal memory very quickly. Any thoughts/insights on this will be appreciated. Thanks!