How it works

TinyCPU is a 32-bit RISC-V (RV32I) processor written in SystemVerilog. It has two cores that share one instruction set: a single-cycle reference core, which finishes one instruction per clock, and a 5-stage pipelined core, which overlaps instructions and handles the hazards that creates.

Everything on this site runs the real hardware. The SystemVerilog is compiled by Verilator into C++, the C++ is compiled by Emscripten into WebAssembly, and the browser steps that WebAssembly one clock edge at a time. Nothing is simulated in JavaScript.

The chain, from source to screen

Try it: a program on the single-cycle core

The program below prints a greeting one byte at a time through the console register, then reports PASS. On the single-cycle core every instruction takes exactly one cycle, so the cycle count equals the instruction count. Step through it.

Hello, on the single-cycle coresingle-cycle

Loading the core…

Where to go next