D
David Perry
Guest
I'm having an issue with a simple if statement:
if ClampIn_u + DMD_u < x"FFFF" then --this doesn't work
ClampIn_u := ClampIn_u + DMD_u;
else
ClampIn_u := x"FFFF";
end if;
What happens is the addition always occurs, I end up overflowing and I get the wrong result.
I tried making the right hand side of the if bigger in attempt to make it work:
if ClampIn_u + DMD_u < x"0FFFF" then
but that fails in the same way.
If I rearrange the maths (subtract DMD_u from both sides):
if ClampIn_u < x"FFFF" - DMD_u then
this works.
DMD_u is an unsigned 16 bit signal, ClampIn_u is an unsigned 16 bit variable.
I'm struggling to find an explanation, I can see why my original might fail but I would have expected "0FFFF" to work.
Any insight would be appreciated
Dave
if ClampIn_u + DMD_u < x"FFFF" then --this doesn't work
ClampIn_u := ClampIn_u + DMD_u;
else
ClampIn_u := x"FFFF";
end if;
What happens is the addition always occurs, I end up overflowing and I get the wrong result.
I tried making the right hand side of the if bigger in attempt to make it work:
if ClampIn_u + DMD_u < x"0FFFF" then
but that fails in the same way.
If I rearrange the maths (subtract DMD_u from both sides):
if ClampIn_u < x"FFFF" - DMD_u then
this works.
DMD_u is an unsigned 16 bit signal, ClampIn_u is an unsigned 16 bit variable.
I'm struggling to find an explanation, I can see why my original might fail but I would have expected "0FFFF" to work.
Any insight would be appreciated
Dave