aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/vnclipu_wv.h
diff options
context:
space:
mode:
authorChih-Min Chao <chihmin.chao@sifive.com>2019-11-20 01:42:45 -0800
committerChih-Min Chao <chihmin.chao@sifive.com>2019-12-20 09:58:46 -0800
commit47c0eb64c81f3eb49ecfe903ee45a827cc169315 (patch)
tree213884f256e8b709856879dafc1c1f2566b5ebfa /riscv/insns/vnclipu_wv.h
parent8d50b2ff666fdf3e448f666d1741d21a90730bab (diff)
downloadspike-47c0eb64c81f3eb49ecfe903ee45a827cc169315.zip
spike-47c0eb64c81f3eb49ecfe903ee45a827cc169315.tar.gz
spike-47c0eb64c81f3eb49ecfe903ee45a827cc169315.tar.bz2
rvv: replace vn suffic by 'w'
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/insns/vnclipu_wv.h')
-rw-r--r--riscv/insns/vnclipu_wv.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/riscv/insns/vnclipu_wv.h b/riscv/insns/vnclipu_wv.h
new file mode 100644
index 0000000..217e82f
--- /dev/null
+++ b/riscv/insns/vnclipu_wv.h
@@ -0,0 +1,21 @@
+// vnclipu: vd[i] = clip(round(vs2[i] + rnd) >> vs1[i])
+VRM xrm = P.VU.get_vround_mode();
+uint64_t int_max = ~(-1ll << P.VU.vsew);
+VI_VVXI_LOOP_NARROW
+({
+ uint128_t result = vs2_u;
+ unsigned shift = vs1 & ((sew * 2) - 1);
+
+ // rounding
+ INT_ROUNDING(result, xrm, shift);
+
+ result = result >> shift;
+
+ // saturation
+ if (result & (uint64_t)(-1ll << sew)) {
+ result = int_max;
+ P.VU.vxsat = 1;
+ }
+
+ vd = result;
+}, true)