optimizing lookup table?

Status
Not open for further replies.

Ye2x

Newbie level 4
Joined
May 2, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,328
hi,

i got a problem
can we group similar entry that give the same output in look up table

for example,
B <= "0000" when a = "0000" else
"0000" when a = "0001" else
"0000" when a = "0010" else
"0000" when a = "0011" else
"0001" when a = "0100" else
"0001" when a = "0101" else
"1111"

can we group the first four line into one command because the value of B will be the same for any input from 0 to 3?

thanks
 

The question hasn't to do with optimization, which is performed by the synthesis tool anyway. It's just a matter of typing effort.

You can combine the first four compares to
Code:
"0000" when a(3 downto 2) = "00"
similarly combine the next two lines.
 

i see, so we can combine till the last bit that will be same?

for example,
B <= "00000000" when a = 1 until 18
B <= "00000000" when b = 19 until 24

can we do the same like before?
 

assuming a is a signed or unsigned type, you could use comparitors:

Code:
C <= "0000" when a >= 1 and a <= 18 else
  <= "0001" when b >= 19 and b <= 24 else
...
--etc

Remember, with 2 on the right hand side, this will build a priority encoder.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…