rakeshk.r
Member level 2
- Joined
- Nov 12, 2013
- Messages
- 47
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 421
Hi, Lets say, I have a 6 bit rounded result (4 Int,2 Frac) from a signed multiplication. But i need a 4 bit output (2 int and 2 frac). So now I will have to check if the result overflows when i remove some integer bits. From this point could you check if i am doing the following logic correctly.
Assume 'x' is the 6 bit rounded result. and 'res' is the 4 bit output needed.
Assume 'x' is the 6 bit rounded result. and 'res' is the 4 bit output needed.
Code:
if x(5 downto 4) /= (x(3)&x(3)) then
if x(5) = '1' then
res <= (3=>'0', others=>'1');
else
res <= (3=>'1', others=>'0');
end if;
else
res <= x (3 downto 0);
end if;