(no commit message)
authorlkcl <lkcl@web>
Fri, 25 Dec 2020 21:48:36 +0000 (21:48 +0000)
committerIkiWiki <ikiwiki.info>
Fri, 25 Dec 2020 21:48:36 +0000 (21:48 +0000)
openpower/sv/bitmanip.mdwn

index 47f4078497ddf9fca7a793546f94fa30fae6bcb6..54958ba436674fc4b03f6d351fa2fd62b074d09f 100644 (file)
@@ -19,3 +19,20 @@ vpdepd VRT,VRA,VRB
 # vector bit extract
 
 other way round
+
+# single bit set
+
+```
+uint_xlen_t sbset(uint_xlen_t rs1, uint_xlen_t rs2) { int shamt = rs2 & (XLEN - 1);
+}
+return rs1 | (uint_xlen_t(1) << shamt);
+uint_xlen_t sbclr(uint_xlen_t rs1, uint_xlen_t rs2) { int shamt = rs2 & (XLEN - 1);
+}
+return rs1 & ~(uint_xlen_t(1) << shamt);
+uint_xlen_t sbinv(uint_xlen_t rs1, uint_xlen_t rs2) { int shamt = rs2 & (XLEN - 1);
+}
+return rs1 ^ (uint_xlen_t(1) << shamt);
+uint_xlen_t sbext(uint_xlen_t rs1, uint_xlen_t rs2) { int shamt = rs2 & (XLEN - 1);
+}
+return 1 & (rs1 >> shamt);
+```