invert saturation min/max pseudocode (thanks lauri)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 10:03:10 +0000 (11:03 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 10:03:13 +0000 (11:03 +0100)
openpower/sv/overview.mdwn

index bce4af85aab07df4b51d816feb82f7c3efa5c54f..81d5b9aa90ac6dda251e0bf228914a21d3c7cdd9 100644 (file)
@@ -641,8 +641,8 @@ truncating down to 8 bit for example.
        # logical op, signed has no meaning
        result = op_xor(src1, src2, opwidth)
        # now saturate (signed)
-       sat = max(result, (1<<destwid-1)-1)
-       sat = min(result, -(1<<destwid-1))
+       sat = min(result, (1<<destwid-1)-1)
+       sat = max(result, -(1<<destwid-1))
        set_polymorphed_reg(rd, destwid, i, sat)
 
 Overall here the rule is: apply common sense then document the behaviour