-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added all instructions to bitmanip chapter.
Added all instructions in alphabetical order to bitmanip chapter.
- Loading branch information
Showing
52 changed files
with
2,768 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[#insns-add_uw,reftext=Add unsigned word] | ||
==== add.uw | ||
|
||
Synopsis:: | ||
Add unsigned word | ||
|
||
Mnemonic:: | ||
add.uw _rd_, _rs1_, _rs2_ | ||
|
||
|
||
Pseudoinstructions:: | ||
zext.w _rd_, _rs1_ → add.uw _rd_, _rs1_, zero | ||
|
||
Encoding:: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{ bits: 7, name: 0x3b, attr: ['OP-32'] }, | ||
{ bits: 5, name: 'rd' }, | ||
{ bits: 3, name: 0x0, attr: ['ADD.UW'] }, | ||
{ bits: 5, name: 'rs1' }, | ||
{ bits: 5, name: 'rs2' }, | ||
{ bits: 7, name: 0x04, attr: ['ADD.UW'] }, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction performs an XLEN-wide addition between _rs2_ and the zero-extended least-significant word of _rs1_. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
let base = X(rs2); | ||
let index = EXTZ(X(rs1)[31..0]); | ||
|
||
X(rd) = base + index; | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
|Zba (<<#zba>>) | ||
|0.93 | ||
|Frozen | ||
|=== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[#insns-andn,reftext="AND with inverted operand"] | ||
==== andn | ||
|
||
Synopsis:: | ||
AND with inverted operand | ||
|
||
Mnemonic:: | ||
andn _rd_, _rs1_, _rs2_ | ||
|
||
Encoding:: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{ bits: 7, name: 0x33, attr: ['OP'] }, | ||
{ bits: 5, name: 'rd' }, | ||
{ bits: 3, name: 0x7, attr: ['ANDN']}, | ||
{ bits: 5, name: 'rs1' }, | ||
{ bits: 5, name: 'rs2' }, | ||
{ bits: 7, name: 0x20, attr: ['ANDN'] }, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction performs the bitwise logical AND operation between _rs1_ and the bitwise inversion of _rs2_. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
X(rd) = X(rs1) & ~X(rs2); | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
|Zbb (<<#zbb>>) | ||
|0.93 | ||
|Frozen | ||
|
||
|Zbkb (<<#zbkb>>) | ||
|v0.9.4 | ||
|Frozen | ||
|=== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[#insns-bclr,reftext="Single-Bit Clear (Register)"] | ||
==== bclr | ||
|
||
Synopsis:: | ||
Single-Bit Clear (Register) | ||
|
||
Mnemonic:: | ||
bclr _rd_, _rs1_, _rs2_ | ||
|
||
Encoding:: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{ bits: 7, name: 0x33, attr: ['OP'] }, | ||
{ bits: 5, name: 'rd' }, | ||
{ bits: 3, name: 0x1, attr: ['BCLR'] }, | ||
{ bits: 5, name: 'rs1' }, | ||
{ bits: 5, name: 'rs2' }, | ||
{ bits: 7, name: 0x24, attr: ['BCLR/BEXT'] }, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction returns _rs1_ with a single bit cleared at the index specified in _rs2_. | ||
The index is read from the lower log2(XLEN) bits of _rs2_. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
let index = X(rs2) & (XLEN - 1); | ||
X(rd) = X(rs1) & ~(1 << index) | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
|Zbs (<<#zbs>>) | ||
|0.93 | ||
|Frozen | ||
|=== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
[#insns-bclri,reftext="Single-Bit Clear (Immediate)"] | ||
==== bclri | ||
|
||
Synopsis:: | ||
Single-Bit Clear (Immediate) | ||
|
||
Mnemonic:: | ||
bclri _rd_, _rs1_, _shamt_ | ||
|
||
Encoding (RV32):: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{ bits: 7, name: 0x13, attr: ['OP-IMM'] }, | ||
{ bits: 5, name: 'rd' }, | ||
{ bits: 3, name: 0x1, attr: ['BCLRI'] }, | ||
{ bits: 5, name: 'rs1' }, | ||
{ bits: 5, name: 'shamt' }, | ||
{ bits: 7, name: 0x24, attr: ['BCLRI'] }, | ||
]} | ||
.... | ||
|
||
Encoding (RV64):: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{ bits: 7, name: 0x13, attr: ['OP-IMM'] }, | ||
{ bits: 5, name: 'rd' }, | ||
{ bits: 3, name: 0x1, attr: ['BCLRI'] }, | ||
{ bits: 5, name: 'rs1' }, | ||
{ bits: 6, name: 'shamt' }, | ||
{ bits: 6, name: 0x12, attr: ['BCLRI'] }, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction returns _rs1_ with a single bit cleared at the index specified in _shamt_. | ||
The index is read from the lower log2(XLEN) bits of _shamt_. | ||
For RV32, the encodings corresponding to shamt[5]=1 are reserved. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
let index = shamt & (XLEN - 1); | ||
X(rd) = X(rs1) & ~(1 << index) | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
|Zbs (<<#zbs>>) | ||
|0.93 | ||
|Frozen | ||
|=== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[#insns-bext,reftext="Single-Bit Extract (Register)"] | ||
==== bext | ||
|
||
Synopsis:: | ||
Single-Bit Extract (Register) | ||
// Should we describe this as a Set-if-bit-is-set? | ||
|
||
Mnemonic:: | ||
bext _rd_, _rs1_, _rs2_ | ||
|
||
Encoding:: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{ bits: 7, name: 0x33, attr: ['OP'] }, | ||
{ bits: 5, name: 'rd' }, | ||
{ bits: 3, name: 0x5, attr: ['BEXT'] }, | ||
{ bits: 5, name: 'rs1' }, | ||
{ bits: 5, name: 'rs2' }, | ||
{ bits: 7, name: 0x24, attr: ['BCLR/BEXT'] }, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction returns a single bit extracted from _rs1_ at the index specified in _rs2_. | ||
The index is read from the lower log2(XLEN) bits of _rs2_. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
let index = X(rs2) & (XLEN - 1); | ||
X(rd) = (X(rs1) >> index) & 1; | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
|Zbs (<<#zbs>>) | ||
|0.93 | ||
|Frozen | ||
|=== | ||
|
Oops, something went wrong.