aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/pnclipr_hs.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/pnclipr_hs.h')
-rw-r--r--riscv/insns/pnclipr_hs.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/riscv/insns/pnclipr_hs.h b/riscv/insns/pnclipr_hs.h
new file mode 100644
index 00000000..3755a641
--- /dev/null
+++ b/riscv/insns/pnclipr_hs.h
@@ -0,0 +1,13 @@
+require_rv32;
+P_NARROW_RD_RS1_LOOP(16, 32, {
+ uint32_t shamt = P_FIELD(RS2, 0, 16) & 0x1F;
+ sreg_t result;
+ if (shamt == 0) {
+ result = p_rs1;
+ } else {
+ sreg_t shifted = (sreg_t)p_rs1 >> shamt;
+ sreg_t roundbit = ((sreg_t)p_rs1 >> (shamt - 1)) & 1;
+ result = shifted + roundbit;
+ }
+ p_rd = P_SAT(16, result);
+}) \ No newline at end of file