I want to get binary std_logic_vector from integer inside the generate.
For example,
0 -> 0000
1 -> 0001
2 -> 0010
...
15 -> 1111
I could write 16 if-else statements for each integer number, but I don't like this idea. (What if I will have much more than 16 integer numbers?)
I've tried to use two methods, but neither of them works: address and hit are both std_logic_vector
G_1 : for i in 0 to 15 generate
address <= conv_std_logic_vector(i, 4) when hit(i) = '1';
end generate G_1;
G_2 : for i in 0 to 15 generate
address <= std_logic_vector(to_unsigned(i, 4)) when hit(i) = '1';
end generate G_2;
Also I noticed that if I use number instead of the i, it works. (Example: I get "0101" when I use conv_std_logic_vector(5, 4))
What am I doing wrong? Is there any possible way to do it using vhdl?