From f0c4b40443f74ffbe8410b1ec5d024b1772c474a Mon Sep 17 00:00:00 2001 From: lkcl Date: Wed, 2 Oct 2019 12:16:27 +0100 Subject: [PATCH] --- simple_v_extension/specification/bitmanip.mdwn | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/simple_v_extension/specification/bitmanip.mdwn b/simple_v_extension/specification/bitmanip.mdwn index 1af47e749..fb47df634 100644 --- a/simple_v_extension/specification/bitmanip.mdwn +++ b/simple_v_extension/specification/bitmanip.mdwn @@ -95,6 +95,19 @@ This instruction is present in BitManip. finds the first bit set as an index. +Pseudocode: + + + uint_xlen_t clz(uint_xlen_t rs1) + { + for (int count = 0; count < XLEN; count++) + if ((rs1 << count) >> (XLEN - 1)) + return count; + return XLEN; // -1 + } + +This is similar but not identical to BitManip "CLZ". CLZ returns XLEN when no bits are set, whereas RVV returns -1. + ## sbf - set before first bit Sets all LSBs leading up to where an LSB in the src is set. If the second @@ -142,6 +155,8 @@ Pseudo-code: ## sif - set including first bit +Similar to sbf except including the bit which ends a run. + # Example 7 6 5 4 3 2 1 0 Element number -- 2.30.2