coobird.net icon

projects.coobird.net

projects.coobird.net - Processor Emulator

Processor Emulator

The idea behind an emulator is to simulate the operation of an processor to test programs before the actual program is written and run on hardware.

The emulator was written as an Java application to allow graphical output of the processor and memory states rather than using the command-line interface for displaying the information.

emulator
See Flash animation of Emulator in action. (Opens new window)
Created using Wink.

Basic design

The emulator consists of three classes: EmuGUI, Processor and Memory.

Processor class

The Processor class, as the name suggests, is the class which simulates the processor. It is an static class with a list of constants for the instructions to make the programming from the other classes easier to accomplish.

All the processor logic is within the Processor class. Also the flags and registers such as carry flag and the accumilator resides in the class.

Although the class contains all the logic needed to execute instructions held in memory, the Processor class does have a method which runs code persistently, rather, only a method which executes one instruction at a time. The "running" of the processor must be implemented by the user, which in this emulator is the EmuGUI class.

Memory class

The Memory class contains an array of short to simulate the code ROM, static RAM, and I/O ports. Along with the array, the class contains a method to initialize the contents of the memory (basically zero out the whole array) and two methods to dump the contents of the memory.

EmuGUI class

The graphical interface for the emulator is implemented in the EmuGUI class using plain-old AWT. The EmuGUI class is also responsible for the

Performance

On a Windows XP PC with an Athlon 64 3700+ using Java SE 5 environment, the emulator runs at around 30 million instructions per second without any of the state updates displayed on the graphical interface.