What encoding field distinguishes SRA from SRL?
They share opcode=0110011 and funct3=101; SRA uses funct7=0100000, while SRL uses funct7=0000000.
Shift rs1 right arithmetically by the low log2(XLEN) bits of rs2, result in rd
SRA is an R-type arithmetic right shift. It shifts rs1 right by the amount in the low log2(XLEN) bits of rs2: rs2[4:0] on RV32 and rs2[5:0] on RV64. High bits are filled with the original most-significant bit of rs1, low bits shifted out are discarded, and rd receives the result. opcode=0110011, funct3=101, funct7=0100000; with the same funct3, funct7=0000000 selects SRL.
Uses the same rhythm as the ADDI page: machine-code fields, fixed-field identification, operand reads, instruction-specific execution, and ISA-visible state update.
The machine code is split by the current instruction format; the animation starts from encoding/decode.
This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.
SRA takes a variable shift amount from the low bits of rs2, arithmetically shifts rs1 right, and fills new high bits with the original most-significant bit. It preserves two's-complement sign shape, but is not identical to signed division in every language context.
Understand this scenario with real code like «sra x5, x6, x7 # x5 = x6 >> (x7[4:0] on RV32, x7[5:0] on RV64) (arithmetic)».
Understand this scenario with real code like «sra x5, x6, x7 # x5 = x6 >> (x7[4:0] on RV32, x7[5:0] on RV64) (arithmetic)».
They share opcode=0110011 and funct3=101; SRA uses funct7=0100000, while SRL uses funct7=0000000.
Not unconditionally. For negative values, arithmetic right shift copies the sign bit and typically rounds toward negative infinity, while integer division in many software semantics truncates toward zero.