views:

127

answers:

3

I have programmed an emulator, but I have some doubts about how to organizate it properly, because, I see that it has some problems about classes connection (CPU <-> Machine Board). For example: I/O ports, interruptions, communication between two or more CPU, etc.

I need for the emulator to has the best performance and good understanding of the code.

PD: Sorry for my bad English.

EDITED:

Asking for multiple patterns.

+3  A: 

You have two closely-related things going on here.

  1. The emulator is a collection of Command definitions. Each thing the emulator can do is a command. Some commands are nested sequences of commands.

  2. The emulator has a number of internal State definitions. Each thing the emulator does updates one or more state objects.

S.Lott
Thank you very much ;)
Facon
+1  A: 

Build your software without regard to "patterns." The patterns will fall naturally out of your work if they are intended to be there. Building your software to fit preconceived notions of what patterns they will tend to make it bulkier and more resistant to change.

(If you haven't yet, download a unit testing framework for your language and use it to guide your development!)

dash-tom-bang
I've no idea of have to use a unit testing framework.
Facon
Find and download UnitTest++ (assuming you're coding in C or C++), read the documentation, and enjoy freedom.
dash-tom-bang
+1  A: 

First have a look at wiki. It seems to give some entry point to art of emulation. Second I would look how QEMU or DOSBox are structured. Also have a look at SourceForge. Simple query gives following software emulators:

In general there is no single pattern for such complicated task. You will definitely need State Machine pattern and you might use Command pattern for dispatching actions. But I really suggest that you will look on other peoples work.

Michal Sznajder