--- Quote Start ---
I have a basic question about the following:
MIN_GAIN : unsigned(13 downto 0) := b"10000000000000"; -- 0x2000
gain_in : in std_logic_vector(13 downto 0);
val : unsigned(13 downto 0); -- 14 bits
gain : std_logic_vector(15 downto 0); -- 16 bits
IN MY CODE I HAVE:
1.) val <= unsigned(gain_in)-MIN_GAIN;
2.) gain(13 downto 0) <= std_logic_vector((b"000"&x"00"& val(13 downto 11)) + 1); -- concatenation
How do you get rid of the second assignment? It seems reasonable that one should be able to
extract the bits in the first assignment statement. However I get an error when I do the following:
val <= (unsigned(gain_in-MIN_GAIN)(2 downto 0);
The code is subtracting a value MIN_GAIN and then shifting right by 11. One should be able to
do that shift in the first statement so that the second statement is not needed. The goal is to get
rid of that second statement and do the entire operation with one statement.
Anyone know what I'm doing wrong?
Thanks.
--- Quote End ---
your topic and discussion is not helpful.
It seems you want this
result <= unsigned(gain_in) - MIN_GAIN; -- ok
final_result <= result(13 downto 11);
but you are adding 1 as well.
Note that 2 bits + 1 needs 3 bits yet your final output is 14 bits???