# kost623/nezalezhnyk architecture

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

- Interactive diagram: https://gitdiagram.com/kost623/nezalezhnyk
- Repository: https://github.com/kost623/nezalezhnyk

## Overview

Nezalezhnyk is an early-stage open CPU architecture project whose implemented product is a C++ instruction-set simulator, with command-line demonstrations and an optional Qt GUI. The main workflow is to provide encoded instructions, load them into simulated memory, then fetch, decode, and execute them while updating registers, memory, and the program counter. The graph includes the documented base-ISA definition and the sampled ALU, memory, and register layers. The encoder implementation and GUI header were not sampled, so their internal behavior is shown only where the available call sites support it.

Main entry points: [`src/gui/mainwindow.cpp`](https://github.com/kost623/nezalezhnyk/blob/main/src/gui/mainwindow.cpp) (Simulator GUI), [`src/cpu.cpp`](https://github.com/kost623/nezalezhnyk/blob/main/src/cpu.cpp) (CPU control), [`src/main.cpp`](https://github.com/kost623/nezalezhnyk/blob/main/src/main.cpp) (CLI demos), [`src/gui/register_model.hpp`](https://github.com/kost623/nezalezhnyk/blob/main/src/gui/register_model.hpp) (Register view model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_demo["CLI demos<br/>[main.cpp]"]
  node_gui["Simulator GUI<br/>[mainwindow.cpp]"]
  node_gui_entry["GUI entry<br/>[main.cpp]"]
  node_register_view["Register view model<br/>[register_model.hpp]"]
end

subgraph group_instruction["Instruction definition"]
  node_encoder["Instruction encoder<br/>[encoder.cpp]"]
  node_isa["ISA decode and definitions<br/>[isa.cpp]"]
end

subgraph group_execution["CPU execution"]
  node_cpu["CPU control<br/>[cpu.cpp]"]
  node_alu["ALU<br/>[alu.cpp]"]
end

subgraph group_state["Machine state"]
  node_registers["Register file<br/>[register_file.hpp]"]
  node_memory[("Simulated memory<br/>[memory.cpp]")]
end

node_user(("User"))
node_binary["Program binary"]

node_user -->|"runs demos"| node_demo
node_demo -->|"encodes instructions"| node_encoder
node_demo -->|"loads and runs"| node_cpu
node_user -->|"operates"| node_gui
node_gui_entry -->|"creates window"| node_gui
node_binary -->|"provides program"| node_gui
node_gui -->|"loads, steps, runs"| node_cpu
node_gui -->|"reads display words"| node_memory
node_gui -->|"decodes display words"| node_isa
node_gui -->|"refreshes"| node_register_view
node_register_view -->|"reads values"| node_registers
node_cpu -->|"fetches and accesses"| node_memory
node_cpu -->|"decodes fetched words"| node_isa
node_cpu -->|"executes ALU ops"| node_alu
node_cpu -->|"reads and writes"| node_registers

click node_demo "https://github.com/kost623/nezalezhnyk/blob/main/src/main.cpp"
click node_gui "https://github.com/kost623/nezalezhnyk/blob/main/src/gui/mainwindow.cpp"
click node_gui_entry "https://github.com/kost623/nezalezhnyk/blob/main/src/gui/main.cpp"
click node_register_view "https://github.com/kost623/nezalezhnyk/blob/main/src/gui/register_model.hpp"
click node_encoder "https://github.com/kost623/nezalezhnyk/blob/main/src/encoder.cpp"
click node_isa "https://github.com/kost623/nezalezhnyk/blob/main/src/isa.cpp"
click node_cpu "https://github.com/kost623/nezalezhnyk/blob/main/src/cpu.cpp"
click node_alu "https://github.com/kost623/nezalezhnyk/blob/main/src/alu.cpp"
click node_registers "https://github.com/kost623/nezalezhnyk/blob/main/include/nezalezhnyk/register_file.hpp"
click node_memory "https://github.com/kost623/nezalezhnyk/blob/main/src/memory.cpp"

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_demo,node_gui,node_gui_entry,node_register_view,node_user toneBlue
class node_encoder,node_isa toneAmber
class node_cpu,node_alu toneMint
class node_registers,node_memory toneRose
class node_binary toneIndigo
```

## Components

### User interfaces

- [CLI demos](https://github.com/kost623/nezalezhnyk/blob/main/src/main.cpp): `src/main.cpp`
- [Simulator GUI](https://github.com/kost623/nezalezhnyk/blob/main/src/gui/mainwindow.cpp): `src/gui/mainwindow.cpp`
- [GUI entry](https://github.com/kost623/nezalezhnyk/blob/main/src/gui/main.cpp): `src/gui/main.cpp`
- [Register view model](https://github.com/kost623/nezalezhnyk/blob/main/src/gui/register_model.hpp): `src/gui/register_model.hpp`

### Instruction definition

- [Instruction encoder](https://github.com/kost623/nezalezhnyk/blob/main/src/encoder.cpp): `src/encoder.cpp`
- [ISA decode and definitions](https://github.com/kost623/nezalezhnyk/blob/main/src/isa.cpp): `src/isa.cpp`

### CPU execution

- [CPU control](https://github.com/kost623/nezalezhnyk/blob/main/src/cpu.cpp): `src/cpu.cpp`
- [ALU](https://github.com/kost623/nezalezhnyk/blob/main/src/alu.cpp): `src/alu.cpp`

### Machine state

- [Register file](https://github.com/kost623/nezalezhnyk/blob/main/include/nezalezhnyk/register_file.hpp): `include/nezalezhnyk/register_file.hpp`
- [Simulated memory](https://github.com/kost623/nezalezhnyk/blob/main/src/memory.cpp): `src/memory.cpp`

### Other components

- **User**
- **Program binary**

## Connections

- User → CLI demos: runs demos
- CLI demos → Instruction encoder: encodes instructions
- CLI demos → CPU control: loads and runs
- User → Simulator GUI: operates
- GUI entry → Simulator GUI: creates window
- Program binary → Simulator GUI: provides program
- Simulator GUI → CPU control: loads, steps, runs
- Simulator GUI → Simulated memory: reads display words
- Simulator GUI → ISA decode and definitions: decodes display words
- Simulator GUI → Register view model: refreshes
- Register view model → Register file: reads values
- CPU control → Simulated memory: fetches and accesses
- CPU control → ISA decode and definitions: decodes fetched words
- CPU control → ALU: executes ALU ops
- CPU control → Register file: reads and writes
