Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Addressing a look-up table (LUT)

Status
Not open for further replies.

symlet

Member level 1
Joined
Oct 12, 2012
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,616
Hai all,

I try to make a basic design using DA technique. I have two LUT with 2-bits value and input vector with 8-bits (array of 8 (7 downto 0)). My question is how to addressed the LUT with 8-bits input value, as the LUT address only has 2bits? And how to select between the two LUTs?
Table 1:
addressdata
000
01h0
10h2
11h0+h2
Table 2:
addressdata
000
01h1
10h3
11h1+h3
The requirement of the task is I need to split the constant (LUT's values) into odd and even. The LUT address is '00'-'11' with 4 data values. If I want to set '0' go to table 1 and '1' go to table 2, is it possible? How to access the LUT based on the input data? Need helps,thanks in advance
 

Are you still talking about this? why have you split it into two tables? why not just have 1 table of 8 values? and anyway, your input vector is too wide to address the tables. You only need 3 bits. 2 bits to address the LUTs and 1 bit to select which LUT. The other 5 bits are just wasted.

So, assuming odd and even, then bits (2 downto 1) are the LUT address, and bit(0) is the table select address.

Unless your input is 1 hot. And in that case you can just build a priority encoder.
 

Hai TrickyDicky,

Sorry if I asking the same question. I split the ROM because of a mathematical equation,where xodd will convolved with hodd and godd, xeven convolved with heven and geven.
**broken link removed** ,


where;
input, x(n)=(x0,x1,x2,x3,x4,x5,x6,x7)
constant, h(n)=(h0,h1,h2,h3)
constant, g(n)=(g0,g1,g2,g3)
your input vector is too wide to address the tables. You only need 3 bits. 2 bits to address the LUTs and 1 bit to select which LUT. The other 5 bits are just wasted.

The input x(n) is std_logic_vector(7 downto 0) data type. If I shorten it to (2 downto 0), the input range will be smaller since my input data is integer of range 0-255. I do not know if you understand what I' saying. I have study several similar project and try to apply to my task,but still stuck here. I hope some advices. Thanks in advance
 

So if you have an input of 8 bits, why havent you built a 256 entry LUT?
 

So if you have an input of 8 bits, why havent you built a 256 entry LUT?

Hai TickyDicky,

If I design 256 entry LUT, the address should be from 00000000 until 11111111. However, how to build the 256 entry LUT with only two constant value (00,01,10,11)?
One more thing, if I build a 256 entry LUT with 8 constant values (h0-h3,g0-g3) the input data of 8 bits will used as an address to access the LUT contents. What I confuse is, is it this way is correct? :|Because in the LUT will have value of h0+g0+g1,h2+g3,h2+g0+g3,etc..instead my equation will multiply the input with the h0-h3 and g0-g3 only. Sorry if I ask basic question,I really stuck here. I try to hand-write the LUT many times, but still not get the right one. Thanks in advance
 
Last edited:

symet,


You can build easily a LUT throught comands switch...case, just working with desired data.

+++
 

symet,


You can build easily a LUT throught comands switch...case, just working with desired data.

+++
Hai andre_teprom,

Can you give example how to build LUT using switch,case function? Thanks in advance
 

Hai TickyDicky,

If I design 256 entry LUT, the address should be from 00000000 until 11111111. However, how to build the 256 entry LUT with only two constant value (00,01,10,11)?
One more thing, if I build a 256 entry LUT with 8 constant values (h0-h3,g0-g3) the input data of 8 bits will used as an address to access the LUT contents. What I confuse is, is it this way is correct? :|Because in the LUT will have value of h0+g0+g1,h2+g3,h2+g0+g3,etc..instead my equation will multiply the input with the h0-h3 and g0-g3 only. Sorry if I ask basic question,I really stuck here. I try to hand-write the LUT many times, but still not get the right one. Thanks in advance

If you build an 8 entry LUT (or 2 4 entry LUTs) you only need 3 bits to get the data out. I dont care about the values, and I have no idea what all these constants are you keen talking about are. They are irrelavent to the design. Whats important is how you address this data.

You say you have an 8 bit input. So, with your new table, do you want a repeating pattern, so that that tha values 0-7 on X get the LUT values for the multiply, and then the next values 8-15 would have the same set of constants again repeated, or would you want 0-31 all having the same constant, with 32-63 having the next constant etc?

for the first case, you would use the LSBs (2 downto 0) as the address, or the 2nd case you would use the MSBs (7 downto 5). You cannot use all 8 bits to address into your LUT, because you have 8 entries, not 256.

- - - Updated - - -

Hai andre_teprom,

Can you give example how to build LUT using switch,case function? Thanks in advance

For VHDL, there is no swtich, just case (Im assuming VHDL because of your previous VHDL threads.

Using the case statement is fine for small ROMs, but, it gets a bit cumbersome for larger ones, and the array method (like you already did) is prefered.

Below is the code to read from a ROM using case statement:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
process(clk)
begin
  if rising_edge(clk) then
    case addr is
      when "000" => op <= 0;
      when "001" => op <= 1;
      when "010" => op <= 2;
      --etc
    end case;
  end if;
end process;

 

You say you have an 8 bit input. So, with your new table, do you want a repeating pattern, so that that tha values 0-7 on X get the LUT values for the multiply, and then the next values 8-15 would have the same set of constants again repeated, or would you want 0-31 all having the same constant, with 32-63 having the next constant etc?

for the first case, you would use the LSBs (2 downto 0) as the address, or the 2nd case you would use the MSBs (7 downto 5). You cannot use all 8 bits to address into your LUT, because you have 8 entries, not 256.

- - - Updated - - -

Hai TrickyDicky,

I want a repeating pattern, so that that tha values 0-7 on X get the LUT values for the multiply, and then the next values 8-15 would have the same set of constants again repeated. Why you said I cannot use all 8 bits to address the LUT? What I undertsand is 8 entries means 8 LUT data with 8 address?.:|
 

yes, it has 8 addresses, but 8 addresses means the address bus is only 3 bits wide. a 8 bit address bus would have 256 entries.
From what you've said, you just need to connect the 3 LSBs of X to the table you already have. That will repeat the pattern.
 

yes, it has 8 addresses, but 8 addresses means the address bus is only 3 bits wide. a 8 bit address bus would have 256 entries.
From what you've said, you just need to connect the 3 LSBs of X to the table you already have. That will repeat the pattern.

Hai TrickyDicky,

I will write back the LUT based on your explanation above. If I get any problem, I will come back. Thank you very much :smile:
 

Hai TrickyDicky,

I build 2 4-entry LUT. As you said, I use the LSB (3 downto 0) of the input data (7 downto 0). How to select either LUT1 or LUT2? Can use bit (4) of the input data to make the selection? Thanks in advance
 

I would use bit 2:1 for the address and bit 0 as the odd/even select. I still dont understand why you've split it into two tables though. why not just have 1 table?
 

I would use bit 2:1 for the address and bit 0 as the odd/even select. I still dont understand why you've split it into two tables though. why not just have 1 table?

Hai TrickyDicky,

Did you mean (4 downto 1) for address and bit (0) for even/odd select? I split the table due to the mathematical equation as I show at the previous thread. I'm not sure if I combine all the 8 constant into one table I will get the right results. Thanks in advance
 
Last edited:

you get the right results if you put the right values into the right parts of the table.
You use bits (2 downto 1) for address and 0 for odd/even.

Using bits (4 downto 1) would mean you have a 16 entry table, which you dont - you have 4.
 

you get the right results if you put the right values into the right parts of the table.
You use bits (2 downto 1) for address and 0 for odd/even.

Using bits (4 downto 1) would mean you have a 16 entry table, which you dont - you have 4.

Yes, I have 16 entries (with 4 constant). Btw, how to put a right values into a right parts of the LUT? I know the general steps/ways to build the ROM as what I do now (split to 2 LUTs), but I don't know the complex LUT. Hope you can advices.Thanks in advance
 

You just fill every odd entry with values from the odd table, and even entries with ones from the even table. It doesnt really matter how you do it. its just affected by how you address it. As long as the entries match the addressing, you're fine.

Now, please be clear about what you have. Your first post shows you have 2x 4 entry LUTs. Now you're talking about 1 16 entry LUT (and you're getting yourself confused with constant values). It doesnt matter how many constants you have. You could have 1024 constants for all I care, but the important thing is how many entries there are in the LUT.

The important thing is the number of address bits. With N address bits, you get a LUT with 2^N entries. It really doesnt matter how you split it up (odd even, day of the week, time of day), because the first rule still applies.
 

Hai TrickyDicky,

I have build a LUT as shown below (based on your advise).
AddressData
00000
0001h0
0010h2
0011h0+h2
01000
0101g0
0110g2
0111g0+g2
10000
1001h1
1010h3
1011h1+h3
11000
1101g1
1110g3
1111g1+g3

The input data is 8bits (7 downto 0), so I used bit 0,1,2 and 3 to address the LUT. Is it I'm doing in a right way? One more thing, if combine all the constant (h0,h1,h2,h3,g0,g1,g2,g3) in a LUT with eight data bus (256 entries), how to address them? How to know I select the right LUT data? Thanks in advance
 

Using the 4 LSBs will give a repeating pattern, so an input of 16 will give the same LUT value as an input of 0.

For an 256 entry table, you just need 256 entries. You need to build the table yourself. ANd then just connect all 8 bits of the X input as the address.
 

Using the 4 LSBs will give a repeating pattern, so an input of 16 will give the same LUT value as an input of 0.

Hai TrickyDicky,

Did you mean an input 0-16 will give a same LUT value? Then 17-24 will give another LUT value?

For an 256 entry table, you just need 256 entries. You need to build the table yourself. ANd then just connect all 8 bits of the X input as the address.

I already build the LUTs (256 entries) and connect all the 8bits of the X as the address. It successfully run in ModelSim for testbench. However, I don't know how to check whether my output is right or wrong. For example, I set the input as an array of 8 data (1,2,3,4,5,6,7,8). The output should be a computation of the input with the LUT constants. But, from the waveform in ModelSim, it shows the final output not same as manual calculation. What I miss? Thanks in advance
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top