This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pseudocode for saturation (Oh no, not again)

In some instruction descriptions there are calls to SignedSatQ (directly or indirectly).

The pseudocode for SignedSatQ:

(bits(N), boolean) SignedSatQ(integer i, integer N)

if i > 2^(N-1) - 1 then

result = 2^(N-1) - 1; saturated = TRUE;

elsif i < -(2^(N-1)) then

result = -(2^(N-1)); saturated = TRUE;

else

result = i; saturated = FALSE;

return (result<N-1:0>, saturated);

What's the idea with 'result<N-1:0>' in the return (shifting the result one bit left)?

Parents Reply Children
No data