SPRUIE9D May 2017 – May 2024 DRA74P , DRA75P , DRA76P , DRA77P
Reverse a Bit Field Bounded by Two Register Values
REV src1, src2, dst
Functional unit = L
32 bit
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 16 | 15 | 13 | 12 | 10 | 9 | 7 | 6 | 0 |
x | x | x | x | x | x | x | x | x | x | x | 1 | 0 | 1 | 0 | 0 | dst | src2 | src1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
3 | 3 | 3 | opcode |
For src1[9:5] ≥ src1[4:0], the field in src2 as specified by src1[4:0] to src1[9:5] is bit reversed. The reversed bits are merged with the remaining (unchanged) bits in dst and are stored in dst. src2 is left unchanged. src1[4:0] is the LSB of the field and src1[9:5] is the MSB of the field to be bit reversed. In other words, src1[4:0] and src1[9:5] represent the beginning and ending bits, respectively, of the field to be bit reversed. The LSB location of src2 is bit 0 and the MSB location of src2 is bit 31.
Valid values of src1[9:5] and src1[4:0] are:
For src1[9:5] < src1[4:0], the result is undefined.
In the following example, src1[4:0] is 11 and src1[9:5] is 19.
CSR[2]EQ = (dst == 0)
dst = src2
pntr = src1[9:5];
for( i = 0; i < 32; i++) {
if ( i >= src1[4:0] && i <= src1[9:5]){
dst[i] = dst[pntr]
--pntr;
} else
dst[i] = dst[i];
}