How eclipsu/mips-datapath-emu works
This is an educational MIPS32 emulator with a browser UI for decoding instructions and stepping a single-cycle datapath. A user selects or edits an instruction/program; the decoder presents fields and disassembly, while the datapath page loads words into a WebAssembly-backed machine, steps it, and visualizes the returned trace. The C++ core contains decoding, control, execution, ALU, register-file, and memory responsibilities. The README documents these capabilities; some internal CPU call details are not shown in the excerpts, so those links cite the README rather than implying inspected implementation details.
Main entry points: cpu.cpp Single-cycle CPU · bindings.cpp Embind API · datapath/main.ts Datapath page · probe/main.ts Decoder page
Components 13
C++ emulator core
- Instruction decoder
src/decode.cpp - Control signals
src/control.cpp - ALU
src/alu.cpp - Single-cycle CPU
src/cpu.cpp - Register file
src/regfile.cpp - Byte memory
src/memory.cpp
WebAssembly bridge
- Embind API
wasm/bindings.cpp
Browser experience
- Typed core client
web/src/shared/core.ts - Decoder page
web/src/pages/probe/main.ts - Datapath page
web/src/pages/datapath/main.ts - Datapath diagram
web/src/pages/datapath/diagram.ts - Page navigation
web/src/shared/frame.ts
Other components
- Learner
Connections 17
- Learner → Decoder page: enters instruction
web/src/pages/probe/main.ts - Learner → Datapath page: loads program
web/src/pages/datapath/main.ts - Decoder page → Typed core client: loads core
web/src/pages/probe/main.ts - Datapath page → Typed core client: loads and steps
web/src/pages/datapath/main.ts - Datapath page → Datapath diagram: renders trace
web/src/pages/datapath/main.ts - Decoder page → Page navigation: requests navigation
web/src/pages/probe/main.ts - Datapath page → Page navigation: requests navigation
web/src/pages/datapath/main.ts - Typed core client → Embind API: wraps module
web/src/shared/core.ts - Embind API → Instruction decoder: decodes words
wasm/bindings.cpp - Embind API → Control signals: computes control
wasm/bindings.cpp - Embind API → Single-cycle CPU: steps machine
wasm/bindings.cpp - Embind API → Register file: reads names
wasm/bindings.cpp - Single-cycle CPU → Instruction decoder: decodes instruction
README.md - Single-cycle CPU → Control signals: selects signals
README.md - Single-cycle CPU → ALU: executes operation
README.md - Single-cycle CPU → Register file: reads and writes
README.md - Single-cycle CPU → Byte memory: fetches and accesses
README.md