Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


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
  • In pseudocode integers and bitstrings are different things. Integers are arbitrary precision and bitstrings are, well, strings of bits...

    In this function, "result" is an integer. To convert an integer to a bitstring, you can apply the bit splice operation. Hence "result<N-1:0>" is just converting the integer to an N-bit string (i.e. extracting bits N-1 to 0). It's not shifting the result.

Reply
  • In pseudocode integers and bitstrings are different things. Integers are arbitrary precision and bitstrings are, well, strings of bits...

    In this function, "result" is an integer. To convert an integer to a bitstring, you can apply the bit splice operation. Hence "result<N-1:0>" is just converting the integer to an N-bit string (i.e. extracting bits N-1 to 0). It's not shifting the result.

Children