From 4aa38df0abcc1fae4d9337e0c8a72c37b13f81aa Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 3 Oct 2019 09:53:00 +0100 Subject: [PATCH] clarify and add better pseudocode --- .../specification/bitmanip.mdwn | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/simple_v_extension/specification/bitmanip.mdwn b/simple_v_extension/specification/bitmanip.mdwn index a6d8dcb9b..32d228e07 100644 --- a/simple_v_extension/specification/bitmanip.mdwn +++ b/simple_v_extension/specification/bitmanip.mdwn @@ -110,9 +110,13 @@ This is similar but not identical to BitManip "CLZ". CLZ returns XLEN when no bi ## sbf - set before first bit -Sets all LSBs leading up to where an LSB in the src is set. If the second -operand is non-zero, this process begins each time (including the first time) from where 1s are set in the -second operand. +Sets all LSBs leading up to (excluding) where an LSB in the src is set. +If the second operand is non-zero, this process begins each time +(including the first time) from where 1s are set in the second operand. + +A side-effect of the search is that when src is zero, the output is all ones. +If the second operand is non-zero and the src is zero, the output is a +copy of the second operand. # Example @@ -137,6 +141,35 @@ second operand. Pseudo-code: + def sof(rd, rs1, rs2): + rd = 0 + setting_mode = rs2 == x0 or (regs[rs2] & 1) + + while i < XLEN: + bit = 1<