A simple neural network that implements a subset of the 6502 instruction set. The 6502 was a very popular processor in the 1980s and 90s, and was used in various forms in many popular consumer electronics products from Apple, Nintendo, Sega, and many more. It boasts a relatively simple instruction set, and emulators have been around for decades, so why re-implement it using a neural network?

...for fun, of course!

The network will execute significantly slower than a generic (non-AI) emulator, since it performs many more floating operations per instruction than necessary. Also, the network only implements a subset of the 6502 instruction set: pure register and immediate mode instructions.

Train the network

python3 neural6502.py train

This will use a generic 6502 emulator to generate training samples which are then fed into the network. The network parameters are saved to disk after every 100 epochs. Complete this step before testing.


Generate test data

python3 neural6502.py generate

This will generate test samples using the generic 6502 emulator. Samples are randomly generated valid pairs of inputs (opcode, operand, processor state) and outputs (processor state).


Test the network

python3 neural6502.py test

This will load a previously trained model from disk and then test it against test data. Perform generate and train before testing, since they generate the necessary files for this step.



Downloads

  Neural 6502 Emulator Source (Github).