--- Quote Start ---
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???
--- Quote End ---
Yes. I may have put the wrong bit numbers. I'll check that
After the subtraction the result is shifted 11 bits. So bits
13, 12, and 11 get moved into bit positions 2 ,1 and 0.
This is then concatenated
with 0's to get a final 14 bit vector. Thus, I have:
final_result <= b"000" & x"00" & val(13 downto 11) + 1;
I have two statements that accomplish this but would like to have only
one statement because it's clocked and the second statement is
one clock later.
It seems to me that I should be able to do this entire operation in one statement as:
gain = (b"000" & x"00" & (unsigned(gain_in) - MIN_GAIN)) + 1;
So my question is how can I keep bits 13, 12, and 11 from the statement
(unsigned(gain_in) - MIN_GAIN) ?
Doing something like (unsigned(gain_in)-MIN_GAIN)(13 downto 11) doesn't work.
Right now this temporary variable "val" has to be used which I'm trying to get rid of
because it's off by 1 clock.
Is there something one would prefix or postifx to ??? (unsigned(gain_in)-MIN_GAIN) ???
to get just those bits 13, 12 and 11? I have had no luck finding it.
So, the single equation looks like: bits 13, 12, and 11 only
final_result <= (b"000" & x"00" & (unsigned(gain_in) - MIN_GAIN) ) + 1;
This statement as it stands doesn't tell me what bits the subtraction will keep!
Thank you for you reply.