I want to do something like this:
variable a, b (both signed)
variable error (signed also)
if (a is positive)
b = error
else
b = -error
So far I have something like this:
if (a(a'high) = '0') then
b <= error;
else
b <= -1 * error;
end if;
But this doesn't work because the multiplication makes the RHS a larger width.
What is the best way to attack this? I could write a function to do a 2's complement negation and use this, but I'm also rather worried about the effect on timing requirements.

