A rounded shift right by one more than the rounding's place, the same number: (v + 2^(n - 1)) >> n, a floor, is ((v >> (n - 1)) + 1) >> 1, whose sum needs one bit more than v however far the shift goes
val RShr : forall ('round : Bool) 'shift 'value_name. (int('value_name), int('shift), bool('round)) -> int
function RShr (value_name, shift, round) = {
if round then {
return(((value_name >> (shift - 1)) + 1) >> 1)
} else {
return((value_name >> shift))
}
}
Made from ScarletNX's Sail at 166ad3910f80. sail-arm's definitions are Arm's ASL in Sail (BSD 3-Clause Clear, license); ScarletNX's fixups are GPL-3.0-or-later.