# eclipsu/mips-datapath-emu architecture

> Architecture diagram of the GitHub repository eclipsu/mips-datapath-emu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eclipsu/mips-datapath-emu
- Repository: https://github.com/eclipsu/mips-datapath-emu

## Overview

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: [`src/cpu.cpp`](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/cpu.cpp) (Single-cycle CPU), [`wasm/bindings.cpp`](https://github.com/eclipsu/mips-datapath-emu/blob/main/wasm/bindings.cpp) (Embind API), [`web/src/pages/datapath/main.ts`](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/datapath/main.ts) (Datapath page), [`web/src/pages/probe/main.ts`](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/probe/main.ts) (Decoder page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["C++ emulator core"]
  node_decoder["Instruction decoder<br/>[decode.cpp]"]
  node_control["Control signals<br/>[control.cpp]"]
  node_alu["ALU<br/>[alu.cpp]"]
  node_cpu["Single-cycle CPU<br/>[cpu.cpp]"]
  node_registers[("Register file<br/>[regfile.cpp]")]
  node_memory[("Byte memory<br/>[memory.cpp]")]
end

subgraph group_bridge["WebAssembly bridge"]
  node_bindings["Embind API<br/>[bindings.cpp]"]
end

subgraph group_web["Browser experience"]
  node_coreclient["Typed core client<br/>[core.ts]"]
  node_probe["Decoder page<br/>[main.ts]"]
  node_datapath["Datapath page<br/>[main.ts]"]
  node_diagram["Datapath diagram<br/>[diagram.ts]"]
  node_frame["Page navigation<br/>[frame.ts]"]
end

node_user(("Learner"))

node_user -->|"enters instruction"| node_probe
node_user -->|"loads program"| node_datapath
node_probe -->|"loads core"| node_coreclient
node_datapath -->|"loads and steps"| node_coreclient
node_datapath -->|"renders trace"| node_diagram
node_probe -->|"requests navigation"| node_frame
node_datapath -->|"requests navigation"| node_frame
node_coreclient -->|"wraps module"| node_bindings
node_bindings -->|"decodes words"| node_decoder
node_bindings -->|"computes control"| node_control
node_bindings -->|"steps machine"| node_cpu
node_bindings -->|"reads names"| node_registers
node_cpu -->|"decodes instruction"| node_decoder
node_cpu -->|"selects signals"| node_control
node_cpu -->|"executes operation"| node_alu
node_cpu -->|"reads and writes"| node_registers
node_cpu -->|"fetches and accesses"| node_memory

click node_decoder "https://github.com/eclipsu/mips-datapath-emu/blob/main/src/decode.cpp"
click node_control "https://github.com/eclipsu/mips-datapath-emu/blob/main/src/control.cpp"
click node_alu "https://github.com/eclipsu/mips-datapath-emu/blob/main/src/alu.cpp"
click node_cpu "https://github.com/eclipsu/mips-datapath-emu/blob/main/src/cpu.cpp"
click node_registers "https://github.com/eclipsu/mips-datapath-emu/blob/main/src/regfile.cpp"
click node_memory "https://github.com/eclipsu/mips-datapath-emu/blob/main/src/memory.cpp"
click node_bindings "https://github.com/eclipsu/mips-datapath-emu/blob/main/wasm/bindings.cpp"
click node_coreclient "https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/shared/core.ts"
click node_probe "https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/probe/main.ts"
click node_datapath "https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/datapath/main.ts"
click node_diagram "https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/datapath/diagram.ts"
click node_frame "https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/shared/frame.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_decoder,node_control,node_alu,node_cpu,node_registers,node_memory toneBlue
class node_bindings toneAmber
class node_coreclient,node_probe,node_datapath,node_diagram,node_frame toneMint
class node_user toneIndigo
```

## Components

### C++ emulator core

- [Instruction decoder](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/decode.cpp): `src/decode.cpp`
- [Control signals](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/control.cpp): `src/control.cpp`
- [ALU](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/alu.cpp): `src/alu.cpp`
- [Single-cycle CPU](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/cpu.cpp): `src/cpu.cpp`
- [Register file](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/regfile.cpp): `src/regfile.cpp`
- [Byte memory](https://github.com/eclipsu/mips-datapath-emu/blob/main/src/memory.cpp): `src/memory.cpp`

### WebAssembly bridge

- [Embind API](https://github.com/eclipsu/mips-datapath-emu/blob/main/wasm/bindings.cpp): `wasm/bindings.cpp`

### Browser experience

- [Typed core client](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/shared/core.ts): `web/src/shared/core.ts`
- [Decoder page](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/probe/main.ts): `web/src/pages/probe/main.ts`
- [Datapath page](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/datapath/main.ts): `web/src/pages/datapath/main.ts`
- [Datapath diagram](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/pages/datapath/diagram.ts): `web/src/pages/datapath/diagram.ts`
- [Page navigation](https://github.com/eclipsu/mips-datapath-emu/blob/main/web/src/shared/frame.ts): `web/src/shared/frame.ts`

### Other components

- **Learner**

## Connections

- Learner → Decoder page: enters instruction (evidence: `web/src/pages/probe/main.ts`)
- Learner → Datapath page: loads program (evidence: `web/src/pages/datapath/main.ts`)
- Decoder page → Typed core client: loads core (evidence: `web/src/pages/probe/main.ts`)
- Datapath page → Typed core client: loads and steps (evidence: `web/src/pages/datapath/main.ts`)
- Datapath page → Datapath diagram: renders trace (evidence: `web/src/pages/datapath/main.ts`)
- Decoder page → Page navigation: requests navigation (evidence: `web/src/pages/probe/main.ts`)
- Datapath page → Page navigation: requests navigation (evidence: `web/src/pages/datapath/main.ts`)
- Typed core client → Embind API: wraps module (evidence: `web/src/shared/core.ts`)
- Embind API → Instruction decoder: decodes words (evidence: `wasm/bindings.cpp`)
- Embind API → Control signals: computes control (evidence: `wasm/bindings.cpp`)
- Embind API → Single-cycle CPU: steps machine (evidence: `wasm/bindings.cpp`)
- Embind API → Register file: reads names (evidence: `wasm/bindings.cpp`)
- Single-cycle CPU → Instruction decoder: decodes instruction (evidence: `README.md`)
- Single-cycle CPU → Control signals: selects signals (evidence: `README.md`)
- Single-cycle CPU → ALU: executes operation (evidence: `README.md`)
- Single-cycle CPU → Register file: reads and writes (evidence: `README.md`)
- Single-cycle CPU → Byte memory: fetches and accesses (evidence: `README.md`)
