Newbie strugling with a lookup (look-up) table in VHDL (or A

S

Shannon

Guest
hello all. Big time newbie here.

Hardware: Cyclone
Software: Quartus II
Problem: I have to implement a lookup table of sorts and I have no
idea what I'm doing.

A counter is counting the duration of an external event. When the
event ends I need to take the final count and retreive a value from a
lookup table and assign it to another variable.

A) I assume I will use the 'table' construct. but what if the table
is huge?
B) It's a 24bit counter so the possilbe values are quite large. The
table will contain the same value for large ranges of counts. I.E. if
count is anywhere between 10 and 100 the lookup value is the same. Is
there a way to minimize the table so that I only have to list index
ranges? In other words it would be nice if the index isn't found, to
take the 'nearest' index.
C) Is there some entirely different way to code the lookup table?

Thanks in advance for any help you can give,
Shannon
 
Hello,
Shannon schrieb:
Problem: I have to implement a lookup table of sorts and I have no
idea what I'm doing.

A counter is counting the duration of an external event. When the
event ends I need to take the final count and retreive a value from a
lookup table and assign it to another variable.

A) I assume I will use the 'table' construct. but what if the table
is huge?
Then you need more devices to fit the table in *g*

B) It's a 24bit counter so the possilbe values are quite large. The
table will contain the same value for large ranges of counts. I.E. if
count is anywhere between 10 and 100 the lookup value is the same. Is
there a way to minimize the table so that I only have to list index
ranges? In other words it would be nice if the index isn't found, to
take the 'nearest' index.
C) Is there some entirely different way to code the lookup table?
You need to google for "hash".
I guess a hash function and a small table will suit.
Another way would be something like

signal cnt : integer range 0 to 2**24-1;
....
process
....
case cnt is
when 0-9 =>....
when 10-100 => ....
when others => ...
end case

bye Thomas
 
Hello

You may want a "ROM". You can use for-generate (as many as your
intervals) to build the table. Also you must have a classical memory
signal (an array-type of std_logic_vector, for example) to do this.
Your counter generates the address, the output is your value.

If your device has memory blocks, you may use them. I do not now about
Altera, but xilinx block-ram probably would do the job. For xilinx, a
"data out" must receive a value according to the address (in this case,
your counter). If this is synchronous to a clock, then you probably is
using a block ram, else you will use distributed.

Can't tell about altera ram usage.

Regards,

Ricardo


Shannon escreveu:

hello all. Big time newbie here.

Hardware: Cyclone
Software: Quartus II
Problem: I have to implement a lookup table of sorts and I have no
idea what I'm doing.

A counter is counting the duration of an external event. When the
event ends I need to take the final count and retreive a value from a
lookup table and assign it to another variable.

A) I assume I will use the 'table' construct. but what if the table
is huge?
B) It's a 24bit counter so the possilbe values are quite large. The
table will contain the same value for large ranges of counts. I.E. if
count is anywhere between 10 and 100 the lookup value is the same. Is
there a way to minimize the table so that I only have to list index
ranges? In other words it would be nice if the index isn't found, to
take the 'nearest' index.
C) Is there some entirely different way to code the lookup table?

Thanks in advance for any help you can give,
Shannon
 
You may be able to use only the upper bits of the counter.

case counter / 2**16 is -- take the upper 8 bits (24 -16)
when 0-9 =>
var := this;
when 10-100 =>
var := that;
when others =>
var := the_other;
end case;

Andy

Thomas Stanka wrote:
Hello,
Shannon schrieb:
Problem: I have to implement a lookup table of sorts and I have no
idea what I'm doing.

A counter is counting the duration of an external event. When the
event ends I need to take the final count and retreive a value from a
lookup table and assign it to another variable.

A) I assume I will use the 'table' construct. but what if the table
is huge?

Then you need more devices to fit the table in *g*

B) It's a 24bit counter so the possilbe values are quite large. The
table will contain the same value for large ranges of counts. I.E. if
count is anywhere between 10 and 100 the lookup value is the same. Is
there a way to minimize the table so that I only have to list index
ranges? In other words it would be nice if the index isn't found, to
take the 'nearest' index.
C) Is there some entirely different way to code the lookup table?

You need to google for "hash".
I guess a hash function and a small table will suit.
Another way would be something like

signal cnt : integer range 0 to 2**24-1;
...
process
...
case cnt is
when 0-9 =>....
when 10-100 => ....
when others => ...
end case

bye Thomas
 
Thanks everyone. I knew I'd get some great answers!

I think there would be too many (hundreds) of case statements to use
that method however.

I guess I'll have to keep digging. There must be a way to write some
logic to find the nearest value. Something like:

Find index where index<count and next index>count then take the value
at table(next index).

or the HDL equivalent of:

temp=count
while notFound
index==temp++
end while
result=table(temp)


On Tue, 27 Jun 2006 16:09:52 -0700, Shannon
<lglcc-electronics.removethis@yahoo.com> wrote:

hello all. Big time newbie here.

Hardware: Cyclone
Software: Quartus II
Problem: I have to implement a lookup table of sorts and I have no
idea what I'm doing.

A counter is counting the duration of an external event. When the
event ends I need to take the final count and retreive a value from a
lookup table and assign it to another variable.

A) I assume I will use the 'table' construct. but what if the table
is huge?
B) It's a 24bit counter so the possilbe values are quite large. The
table will contain the same value for large ranges of counts. I.E. if
count is anywhere between 10 and 100 the lookup value is the same. Is
there a way to minimize the table so that I only have to list index
ranges? In other words it would be nice if the index isn't found, to
take the 'nearest' index.
C) Is there some entirely different way to code the lookup table?

Thanks in advance for any help you can give,
Shannon
 
Shannon wrote:

I think there would be too many (hundreds) of case statements to use
that method however.
If there are hundreds of bins, they have to be described somehow.
A big case statement is as good a way as any unless the function
is known.

I would declare the function to start with:

subtype rom_adr_t is unsigned(8 downto 0); -- hundreds of bins
subtype count_t is unsigned(23 downto 0); -- millions of counts

function count2bins (arg_cnt : count_t)
return bin_t; -- bin 0 to 511


-- Mike Treseler
 

Welcome to EDABoard.com

Sponsor

Back
Top