Writing Hardware Simulators?

Peter Hansen peter at engcorp.com
Thu Oct 9 07:17:06 EDT 2003


Miki Tebeka wrote:
> 
> I'll be writing a hardware simulator for one of our CPU's shortly.
> Any advices/links/... on the subject?

No links I'm aware of, although you can easily find an HC11 simulator
out there somewhere.

Kaval has written but not yet released (okay, not even completed) an
HC12 simulator (independent of the above effort).

Performance is roughly 1/60 of the actual CPU speed running at the
nominal clock speed (16MHz), when the code is run on the simulator 
on a PC of about 600MHz.

If performance is not your greatest concern (which presumably it isn't
or you wouldn't consider Python in the first place :-), you shouldn't
have much difficulty...

Advice?  Write *lots* of tests.  In fact, write dozens (literally!) 
of test cases for each opcode.

Make sure you have a clear idea of your priorities and don't try to
implement more than you really need, to begin with.  I didn't need
anything involving simulating the actual instruction cycle times
(i.e. simulating time was not important yet), and I haven't gotten
to the point where I care much about simulating hardware peripherals
such as the serial port.  I'm just doing the basic CPU and opcodes,
and obviously memory.  As a result of this narrow focus, it took 
only a few weeks to produce an effective, usable simulator, although
I still have a few opcodes to complete.  (Even the opcodes I'm
implementing only as I have code that requires them.  I suggest
implementing an UnimplementedOpcode exception for *all* opcodes,
then running your code.  Only implement the actual opcodes as you
need them...)

-Peter




More information about the Python-list mailing list