VLSI_Toolkit

Interactive chip-design tools for beginners

Number conversion, MOSFET, RISC-V, pipeline, timing and FSM tools for chip design. Free, and it all runs in your browser.

☕ Buy us a chai
Word width

C to RISC-V (RV32IMC) Compiler, Assembler and Simulator Online

✓ Verified in Icarus Verilog Simulator output matches a Verilog RV32IM core on 12 of 12 example programs; the disassembler passes 200,000 random round trips.

Program

RV32IMC instructions

Register status

Export for your RTL testbench

Load the program into your own RV32 core and check it against this simulator. Code starts at address 0. Globals live at 0x2000 and are written by the startup code, so the image below is all your instruction memory needs. The stack pointer starts at 0x10000.


      

Disassembler

Paste machine code from a waveform, a memory dump or a .hex file. 8 hex digits is a 32-bit instruction, 4 digits a 16-bit compressed one. 0x, @address lines and // comments are fine.

Instruction trace
Data memory at this step
How this works

C source goes through a small built-in compiler that targets RV32IM, then an assembler encodes every instruction. With the C extension on, instructions that have a 16-bit form (c.addi, c.li, c.mv, c.lwsp, c.beqz and so on) are stored in 2 bytes and the code shrinks. Branch offsets are recomputed for the shorter layout.

The simulator runs the program and records the register file after every instruction. Drag the slider to see the registers at any step. Changed registers are highlighted. x0 always reads 0. The stack starts at 0x10000 and the program ends when main returns or runs ecall with a7 = 93.

The C compiler supports int, unsigned, arrays, pointers, globals, functions, if, while, do, for, break and continue. It does not do floating point, structs, strings, or optimization beyond simple immediates. Output is easy to read but not what an optimizing compiler such as GCC would produce.