Skip to content

Instantly share code, notes, and snippets.

@aaronjanse
Created May 18, 2018 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjanse/72a851d61b08b5c6f2b40ee5972f6505 to your computer and use it in GitHub Desktop.
Save aaronjanse/72a851d61b08b5c6f2b40ee5972f6505 to your computer and use it in GitHub Desktop.
RISC-V 32-bit machine code breakdown
31        26        21        16        11   9     6           0
vv        vv        vv        vv        vv  vv    vv          vv
'F'E'D'C'B'A'9'8'7'6'5'4'3'2'1'0 F E D C B A 9 8 7 6 5 4 3 2 1 0
[ jump target                                  25][ opcode    7]  J-type
[ rd    5][ upper immediate                    19][ opcode    7]  U-type
[ rd    5][ rs1   5][ immhi 5][ immlo     7][fun3][ opcode    7]  I-type
[ immhi 5][ rs1   5][ rs2   5][ immlo     7][fun3][ opcode    7]  B-type
[ rd    5][ rs1   5][ rs2   5][ funct          10][ opcode    7]  R-type
[ rd    5][ rs1   5][ rs2   5][ rs3   5][ funct 5][ opcode    7]  R4-type

based on http://www-inst.eecs.berkeley.edu/~cs250/fa13/handouts/lab2-riscv.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment