rvcodec.js is a RISC-V instruction encoder/decoder available at https://luplab.gitlab.io/rvcodecjs/.
rvcodec.js conveniently shows how each token of the assembly instruction is encoded as part of the binary representation.
In the search box, type in a RISC-V instruction. You can input instructions in
their (decoded) assembly form (such as addi x2, x10, 897) or their
(encoded) numerical form (such as 0x38150113). For assembly instructions, a
helpful drop-down menu can perform some auto-completion and/or show you their
canonical forms.
Once you press Enter, the instruction you typed in will be converted in all possible formats. You can use your mouse cursor to hover over the different colored fields to see how the assembly and binary representations match.
The settings wheel inside the search box gives you access to a couple of parameters:
- The
ABItoggle makes the converted assembly representation use either the numerical register names or the ABI register names (e.g.,x2vssp). - The
ISAmenu allows you to force a certain RISC-V ISA. For example, selecting ISARV32Iwill make certain instructions fail since they don't exist for that particular ISA (e.g.,addiw x2, x10, 897).
Supported instruction sets and extensions:
- RV32I instruction set
- RV64I instruction set
- RV128I instruction set
- Rest of GC extensions
- Zifencei instruction set
- Zicsr instruction set
- M (multiplication/division) instruction set
- A (atomic) instruction set
- F (single-precision floating point) instruction set
- D (double-precision floating point) instruction set
- Q (quad-precision floating point) instruction set
- C (compressed) instruction set
- Privileged instruction set (partially)
- Clone this repo:
$ git clone git@gitlab.com:luplab/rvcodecjs.git - Install dependencies:
$ npm install - Make changes
- The encoding/decoding logic is in directory
core - The web user interface is in directory
web-ui
- The encoding/decoding logic is in directory
- Run testsuite to avoid any regressions:
$ npm test - Open website locally to test UI:
$ npm run open
This project is now in semi-maintenance mode. The support for all base
instruction sets (32I/64I/128I) and the most common extensions
(MAFDQC_Zifencei_Zicsr) were added, and the UI/UX currently feels fairly
stable.
If you'd like to contribute something new, or see opportunities for improvements, please contact us.
rvcodec.js is developed by the LupLab at UC Davis.
rvcodec.js is released under the GNU Affero General Public License v3.0.
