-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
Przemyslaw Rachwlal edited this page May 4, 2026
·
1 revision
The simulator follows a clean architecture with strict one-way dependency flow. Each layer depends only on layers below it.
CmosCpu.Core (no dependencies)
↓
CmosCpu.Bus ──────────────→ Core
CmosCpu.Memory ───────────→ Core, Bus
CmosCpu.Cpu ──────────────→ Core, Bus
CmosCpu.Devices ──────────→ Core, Bus
CmosCpu.Assembler ────────→ Core
↓
CmosCpu.Runtime ─────────→ Core, Bus, Memory, Cpu, Devices, Assembler
↓
CmosCpu.Computer ────────→ Core, Bus, Memory, Cpu, Devices, Runtime
↓
Symulator.Application ───→ Core, Cpu, Bus, Memory, Devices, Assembler, Runtime, Computer
↓
Symulator.Machines.* ────→ Core, Computer, Runtime, Devices, Application
↓
Symulator.Avalonia ──────→ Application, Machines.*, Computer, Core
Core interfaces and value types with zero dependencies:
-
ICpuCore,IBus,IBusDevice,IMachine,IMachineProfile,IMachineBuilder -
IMemoryMap,IClockedDevice,IResettable,IAssembler,ISimulator,IDebugger -
CpuRegisters,Opcode,CpuFlags,MemoryRegion,InstructionInfo
System bus that routes read/write operations to registered devices by address range.
RAM and ROM implementations with load/store and memory map lookup.
CPU cores:
- CpuCore: Educational 17-opcode ISA for learning CPU internals
- Mos6502Cpu: Full MOS 6502 emulation (56 official opcodes, decimal mode, interrupts)
- Z80Cpu: In-progress Z80 emulation (MVP stage)
Memory-mapped I/O devices:
-
LedDevice— simple LED at memory address -
TimerDevice— countdown timer -
RtcDevice— DS3231 RTC emulation
SimpleAssembler — text-to-bytecode assembler with label support.
Machine assembly and DI wiring: Machine, MachineBuilder, adapters between CPU/bus and the core interfaces.
High-level computer abstractions:
-
ComputerMachine,ComputerMemoryBus,ComputerRunController - Device emulations:
Pia6821,Hd44780Lcd, I2C controller, UART/Serial -
Apple1PiaTerminalDevice,Kim1Riot6530IoDevice
Application orchestration:
-
EmulatorController— session lifecycle management -
IMachineCatalog— available machine discovery -
IMachineModule— pluggable machine modules -
SolutionDefinition— program manifest loader
Machine-specific modules:
- Apple-1: Terminal, PIA adapter, boot workflow, Woz Monitor + BASIC
- KIM-1: Keypad, 7-segment LED display, RIOT/6530 I/O
- Minimal Blink: Experimental dynamic hardware platform
- Retro70: Simple educational 6502 computer
Cross-platform desktop UI using Avalonia 11.2 with MVVM:
- Machine selector, workspace hosting via DataTemplates
- Emulator controls (run, pause, step, reset)
- Machine-specific panels (terminal, keypad, LED, CPU state)
IMachineModule
├── Id (string, e.g. "apple1", "kim1")
├── DisplayName
├── CreateSession() → IMachineSession
└── PanelDescriptors → IReadOnlyList<IMachinePanelDescriptor>
IMachineSession
├── StartAsync(), StopAsync()
├── SendInputAsync(string)
├── OutputReceived event
└── Snapshot → EmulatorStateSnapshot
- Memory-mapped I/O: All devices communicate through the system bus
- Cycle accuracy: Devices tick in sync with CPU cycles
-
DI-first: Everything wired through
Microsoft.Extensions.DependencyInjection -
Nullable enabled: All projects use
<Nullable>enable</Nullable> - No blocking waits: Async/await throughout
-
Avalonia threading: UI updates marshaled via
Dispatcher.UIThread.Post