Looking for design ideas to implement a ROM for quick lookup

Guest
Given a number between 0 and 255(8 bit input), I'd like my ROM module to respond with one of 16 different modes (4 bit output). Some modes will repeat multiple times.

So the ROM lookup would be something like :

0 -> MODE_0
1 -> MODE_1
2 -> MODE_6
3 -> MODE_9
4 -> MODE_6
5 -> MODE_12
..
..
128 -> MODE_15


Sounds like a 256x4 ROM would be the best way to go at this. It would be really nice to create a subtype for the outputs so I can just reference them directly as "MODE_9" and not "1001".

Any insight or guidance would be appreciated!

-V
 
On Friday, September 5, 2014 10:36:08 AM UTC-4, V. wrote:
Given a number between 0 and 255(8 bit input), I'd like my ROM module to respond with one of 16 different modes (4 bit output). Some modes will repeat multiple times.



So the ROM lookup would be something like :



0 -> MODE_0

1 -> MODE_1

2 -> MODE_6

3 -> MODE_9

4 -> MODE_6

5 -> MODE_12

.

.

128 -> MODE_15





Sounds like a 256x4 ROM would be the best way to go at this. It would be really nice to create a subtype for the outputs so I can just reference them directly as "MODE_9" and not "1001".



Any insight or guidance would be appreciated!



-V

Not sure if you're looking for guidance on how to create the subtype or something else. If for the subtype approach then

type t_MY_MODES is (MODE_0, MODE_1,... MODE_15);
type arr_t_MY_MODES is array(natural range <>) of t_MY_MODES;
constant MY_ROM_DATA: arr_t_MY_MODES(0 to 128) :(
0 => MODE_0,
1 => MODE_1,
...
128 => MODE_15
);

If you need to convert to/from hard index numbers you would use the 'pos or 'val attributes of the t_MY_MODES type.
Ex: t_MY_MODES'pos(MODE_1) would return the integer 2
t_MY_MODES'val(0) would return the t_MY_MODES MODE_0

If you're looking for a different approach, consider embedding the algorithm that you have for defining the various 'MODE_x' right into the VHDL instead. Typically that will compact the code, avoid fat fingering the various MODE_x numbers at all and typically maps itself back to higher level requirements in a clearer manner.

You would do this by creating a function that returns an integer array the size of your intended ROM table and then calling that function to initialize the ROM data.

Kevin Jennings
 
On Friday, September 5, 2014 2:12:37 PM UTC-4, KJ wrote:

If you need to convert to/from hard index numbers you would use the 'pos or 'val attributes of the t_MY_MODES type.

Ex: t_MY_MODES'pos(MODE_1) would return the integer 1

t_MY_MODES'val(0) would return the t_MY_MODES MODE_0

Corrected the value returned by the 'pos attribute above

KJ
 

Welcome to EDABoard.com

Sponsor

Back
Top