[Simh] Representative Instruction Execution Timing

Mark Garlanger garlanger at gmail.com
Tue Apr 5 11:58:26 EDT 2011


I haven't looked at the SIMH code, but the way I handled this problem on an
Heathkit H89, should is fairly straight forward and was quite accurate. On
the H89, it runs a Z80 processor at 2.048 MHz and had a 2 mSec timer. A real
H89 would be able to run 4096 cycles between each timer interrupt. The Z80
code keeps track of the number of cycles each instruction takes to run. I
gave the CPU thread 4096 cycles to run, when it ran out, the thread would
sleep until the next timer interrupt. At the next timer interrupt another
4096 cycles would be given to the thread to run through. It would quickly
run through it's cycles for the time slice, but then that allows the CPU to
be idle most of the time (and doesn't require high overhead for each
instruction).

Depending on how accurate you want the timing to be, you could just count
instructions instead of clock ticks.

Mark


On Tue, Apr 5, 2011 at 9:47 AM, Dalby, Jeremy R (GE Power & Water) <
jeremy.dalby at ge.com> wrote:

> I am trying to figure out how to slow down the SIMH PDP-8 simulator such
> that the instructions are executed with similar timing to that of a real
> PDP-8.  I have found that that even with throttling set very low, the
> PDP-8 simulator executes much, much faster than a real PDP-8.
>
> From what I have read, I believe the execution of a single PDP-8
> instruction can take anywhere from 1.2 - 4.6 microseconds, depending on
> the type of instruction and I/O device to which the instruction applies.
>
> I am running the PDP-8 simulator on a Windows XP host, which I
> unfortunately cannot change to a real-time environment.
>
> Some things I have considered:
>
> 1.  Inserting a sleep() function after execution of each PDP-8
> instruction, but this won't work since the minimum sleep time is 1
> millisecond, and even a 1 ms sleep request is not likely to return for
> at least 20 ms due to Windows non-real-time scheduling.
>
> 2. Inserting a loop that cycles for some number of times after execution
> of each PDP-8 instruction, in order to kill some time. The exact number
> of cycles required would depend on the host processor speed, so I would
> have to come up with some sort of calibration method to determine the
> number of cycles.  I don't really like this method because I would have
> to disable throttling and tie up the processor 100%, and I'm really not
> sure how I would go about calibrating the number of cycles.
>
> I am kind of thinking at this point that representative instruction
> timing on a Windows host is pretty much impossible, but I thought it
> might be worthwhile to throw the question out there to you guys and see
> what comes back.  Any thoughts or ideas would be much appreciated.
>
> Thanks,
> Jeremy Dalby
>
> _______________________________________________
> Simh mailing list
> Simh at trailing-edge.com
> http://mailman.trailing-edge.com/mailman/listinfo/simh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20110405/8a158b6a/attachment-0002.html>


More information about the Simh mailing list