Home
Cycle-accurate emulators for 8-bit CPUs.
OakCpu is a collection of .NET emulators for CPUs. The Z80 and 6502 are currently supported. Each comes in two variants: a step level emulator that advances a single T-state at a time, and an instruction level emulator that advances a single instruction at a time.
Installation
dotnet add package MrKWatkins.OakCpu.Z80
The 6502 is available in a separate package:
dotnet add package MrKWatkins.OakCpu.M6502
Using the Emulator
Create either a step emulator for cycle-accurate integration or an instruction emulator when you only need to handle each external bus action one instruction at a time.
Execution Model
The emulator reports external bus activity with ActionRequired. The host supplies or consumes data through the emulator's Address and Data properties.
Code Generation
The Z80 and 6502 implementations are generated from YAML instruction definitions. Generated source is checked in, and the same generator is used by the source generator package.
API Documentation
Reference documentation is generated from the release assemblies:
Z80:
6502:
Future Plans
More CPUs will be supported. I intend to create emulators for other languages too, using the shared YAML definitions as the source of truth for emulator behaviour.
Use of AI
My general rule is I'll write the interesting bits and use AI for the boring bits. The step level Z80 emulator and instructions was created by hand. AI was then used to help with tidying up the code, performance improvements, adding the instruction level emulator and the documentation. The 6502 emulator was done entirely by AI, mainly to test the validity of adding a new set of definitions for another chip.
Licencing
Licensed under GPL v3.0.