4-bit table look-up

Hi

I have a simple question, whats the best way of designing a lookup table which is 16 bit wide in VHDL and for sythesis. It receives 4 input bits and depending of the values 1 bit will be selected for the output. As I have a 32 bit architecture, this kind of lookup table should have 32 instances in parallel. So I wonder what is the best option to implement this? I also need to configure these lookup tables before using them.

Is the following approach feasable? I have one register that is 16 bits wide and which holds the value of my lookup table. Now I use 32 Muxes and each receives the 16 bits that are stored in the lookup register. Each mux has its own 4-input selection signal, which consists of the corresponing bits of the registers, and outputs the the corresponding bit. So I would need quite a lot of muxes, it is maybe better to have 32 16-bit lookup tables in parallel and read there directly the value out?

Thanks for helpful tips!

Reply to
Klaus Mayer
Loading thread data ...

Thanks for the feedback Eric, but the problem is that the content is not fix. So I cant use a rom as u suggested, I need something that reads the actual content out of a register an applies then the current values

Reply to
Klaus Mayer

If the values are fixed, it's just a 16x1 ROM (for the single bit case), or 16x32 ROM (32-bit wide case). XST will synthesize something appropriate from any reasonable VHDL construct; see the examples in the XST manual. Here's one way of doing the 32-bit wide case with a concurrent assignment statement:

signal select: std_logic_vector (3 downto 0); signal foo: std_logic_vector (31 downto 0);

foo

Reply to
Eric Smith

Reply to
Mark McDougall

Personally I prefer to use case statements for constructs like this to avoid any accidental priority encoding by the synthesis tool.

signal sel: std_logic_vector (3 downto 0); signal foo: std_logic_vector (31 downto 0);

process (sel) case sel is when "0000" foo

Reply to
Ed McGettigan

Except when designing a 7-segment decoder ;-)

always @ (ibcd) begin case (ibcd) // abcdefg 0 : oseg = 7'b1111110; 1 : oseg = 7'b0110000; 2 : oseg = 7'b1101101; 3 : oseg = 7'b1111001; 4 : oseg = 7'b0110011; 5 : oseg = 7'b1011011; 6 : oseg = 7'b1011111; 7 : oseg = 7'b1110000; 8 : oseg = 7'b1111111; 9 : oseg = 7'b1111011; default : oseg = 0; endcase

Reply to
DJ Delorie

[...]

That's fine for synthesis, but since the type is std_logic_vector, many simulators will complain that you've left a lot of alternatives unspecified. I suppose adding when others => foo

Reply to
Eric Smith

So it's either a RAM, or a register with a mux. Here's a single-bit wide version of the register with mux.

use IEEE.numeric_std;

signal reg: std_logic_vector (15 downto 0); signal sel: std_logic_vector (3 downto 0);

signal foo: std_logic;

foo

Reply to
Eric Smith

Reply to
Peter Alfke

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.