New, experimental, (hopefully) cycle-realistic version of the PiDP-8/I

384 views
Skip to first unread message

Steve Tockey

unread,
Nov 27, 2021, 1:06:04 PM11/27/21
to PiDP-8
All,
As many of you might already know, the existing SIMH implementation of the PDP-8 emulates whole instruction-level execution. Real PDP-8s run one to three memory cycles ("major states") per instruction, depending on the Op Code and the addressing mode. The Fetch, Defer, and Execute lights on the existing PiDP-8/I  front panel are only approximations of real behavior. As well, this is what made the Sing Step switch on the front panel useless so Oscar assigned it for other purposes.

Well, I have long missed the real behavior of the Sing Step switch (honestly, I'm not sure I could ever say why ...) so I decided to modify the SIMH PDP-8 and PiDP-8/I code to emulate and show the PiDP-8/I at the Fetch, Defer, and Execute major state level. I'm pretty close, just a couple of remaining issues to iron out. It seems to work well enough if others want to try it out. You can read all about the major states in the Small Computer Handbook. For example, the 1973 version  (http://20.69.243.200/pdf/dec/pdp8/handbooks/Small_Computer_Handbook_1973.pdf) talks about it on pages 3-17 through 3-22.

Don't worry, Oscar's reboot & mount USB media functions did not go away. They just got re-mapped to other switches. Use the front panel switches in the following order to access this functionality in this version:
     Sing Inst on
     While holding down Cont
     Toggle Sing Step
You'll almost certainly have to hit Cont after turning Sing Step back to off to get things running again. So it's not as convenient as toggling Sing Step alone but at least the functionality is still there. Also, Sing Inst + Sing Step + Start to reboot the Pi and Sing Inst + Sing Step + Stop to shut down the Pi still work as before.

If you want to try it, it involved modification of 5 source files (attached), as follows:

In /home/pi/src/pidp8i/trunk/src/SIMH/PDP8 replace the following file with the attached
     pdp8_cpu.c

In /home/pi/src/pidp8i/trunk/src/pidp8i replace the following four files with the attached
     pidp8i.h
     gpio-ils.c
     main.c.in

(HINT: Save back ups of the original versions of these files so you can revert if you need or want to later)

Then recompile the PiDP-8/I and you should be up and running. E.g., in a terminal window:

$ cd ~/pidp8i
./configure && tools/mmake && sudo make install

should do it.

There are two known issues
1) TSS-8 doesn't work with this version. I've successfully run several of the Maindec diagnostics (but not all) and even found an emulator defect using the Memory Extension & Time Share Control test. More tests are needed to figure out what's broken and get TSS-8 working again.

2) While Sing Step works the way it does on a real PDP-8, unfortunately in this version Sing Inst behaves exactly the same way. I need to figure out a way to have Sing Inst (and Stop, too) not stop executing until after a complete instruction has finished (i.e., next_Major_State == FETCH_state).

Performance wise, it looks like this version does run slower than the stock version (by as much as 50% in one benchmark) but since I always run throttled it's not an issue to me.

So if anyone else wants to play around with this, feel free. And do let me know if you find any problems. As well, help in resolving those two issues would be most appreciated.

Note also that this version incorporates HB's fix for Exam & Deposit outside of Field 0, his fix sits in several of these same files.

Once I can get those two issues resolved I will move everything into the official Fossil repository.


Enjoy,

-- steve


gpio-ils.c
main.c.in
gpio-common.c.in
pidp8i.h
pdp8_cpu.c

Steve Tockey

unread,
Nov 27, 2021, 5:29:07 PM11/27/21
to PiDP-8

All,
Just a quick follow-on to say that this version successfully passes all of these following diagnostics:
maindec-8e-d0ab Instruction Test 1
maindec-8e-d0bb Instruction Test 2
maindec-8e-d0db Random AND
maindec-8e-d0eb Random TAD
maindec-8e-d0fc Random ISZ
maindec-8e-d0gc Random DCA
maindec-8e-d0hc Random JMP
maindec-8e-d0ib Basic JMP JMS
maindec-8e-d0jc Random JMP JMS
maindec-8e-d1fb Extended Memory Address (EA8E)
maindec-8e-d1bc Extended Memory Checkerboard
maindec-8e-d0lb KE8-E (EAE) Instruction Test 1
maindec-8e-d0mb KE8-E (EAE) Instruction Test 2
maindec-8e-d1ha Memory Extension and Timeshare Control

If anyone has any other diagnostics that should be run, please let me know. I was hoping that one of the diagnostics would reveal what's keeping TSS-8 from running but that hasn't happened yet.


-- steve


Heinz-Bernd Eggenstein

unread,
Nov 27, 2021, 6:00:10 PM11/27/21
to PiDP-8
Wow , impressive stuff!!!

A few notes:

It seems like the EAE instructions are emulated to do everything in FETCH, is that accurate?

There is also a whole load of comments, variable names, and arithmetic (relative to throttling values of instructons per second etc) that assumed values of instruction counts but now has a different meaning: cycle counts, e.g. comments like "

    // Bump the instruction count.  This should always be equal to the
    // Fetch LED's value, but integers are too cheap to get cute here.
    [...]
    display* pd = pdis_update;
    ++pd->inst_count;
"
So in order not to confuse future generations of pidp8i programmers :-) those will need some cleaning up I guess,. and I'm absolutely willing to help once this is in fossil.

There was also the idea to make the code (at least optionally via the SIMH "boot" script) behave like a PDP-8I instead of an 8E (especially the EAE mode B thing) so that application code that autodetects the model would think it runs on an 8i and code that predates the 8E cannot be disturbed by previously executing code that switched to mode B . What do you think about that idea? After all it's an 8i front-panel.

Cheers
HB

Steve Tockey

unread,
Nov 27, 2021, 6:15:54 PM11/27/21
to PiDP-8

"It seems like the EAE instructions are emulated to do everything in FETCH, is that accurate?"

Good question, I don't know. I just assumed--maybe incorrectly--that with the exception of the PC, EAE would be running off its own set of internal registers.


"There is also a whole load of comments, variable names, and arithmetic (relative to throttling values of instructons per second etc) that assumed values of instruction counts but now has a different meaning: cycle counts,"

Correct, but those refer to how the PiDP-8/I front panel handles displaying status so I was glossing over all of that and only focusing on getting it to actually run. And there's still the issue of how to make Sing Inst work correctly. My point is that a fair amount of work remains, but it is to a point that it does execute reasonably well. By the way, I'm making progress on the TSS-8 issue, stay tuned.


"There was also the idea to make the code (at least optionally via the SIMH "boot" script) behave like a PDP-8I instead of an 8E (especially the EAE mode B thing) so that application code that autodetects the model would think it runs on an 8i and code that predates the 8E cannot be disturbed by previously executing code that switched to mode B . What do you think about that idea? After all it's an 8i front-panel."

I think it's an interesting idea but I'm not sure I'm willing to invest a lot of my own time into making it happen. We do have the PiDP11/70 as a model, it already does that (with some interesting issues). But the SIMH 11/70 is based on--I believe--a different framework (Blinkenbone) that might be incompatible. I haven't even started going down that path.


Cheers,

-- steve


Steve Tockey

unread,
Nov 27, 2021, 6:29:16 PM11/27/21
to PiDP-8

All,
Progress on the TSS-8 front. It has to do with interrupts and initialization but I haven't nailed it quite yet. I can at least get TSS-8 running if I modify the boot script. Change it from:

load /opt/pidp8i/share/media/tss8/tss8_init.bin
attach rf /opt/pidp8i/share/media/tss8/tss8_rf.dsk
attach ttix 4000

run 24200

to:

load /opt/pidp8i/share/media/tss8/tss8_init.bin
attach rf /opt/pidp8i/share/media/tss8/tss8_rf.dsk
attach ttix 4000

d 40200 6007
d 40201 6223
d 40202 5603
d 40203 4200
g 40200

;run 24200

This is a total hack that just injects a hard CAF (Clear All Flags, 6007) before jumping into TSS-8. I noticed I had a similar problem with some of the MAINDEC diagnostics that run with interrupts on. The SIMH startup sequence as well as the Start switch on the front panel don't seem to be doing the kind of initialization they should be expected to do--namely not actually clearing all of the IO device flags.


-- steve

Michael J. Kupec

unread,
Nov 27, 2021, 6:38:48 PM11/27/21
to Steve Tockey, PiDP-8
Just wonder, as this might be something to do with one of my other systems (Altair Duino, or IMSAI clone), is there some kind physical mod that needs to be done to the switches on the actual system? 
I seem to recall something that a switch on one of my clones actually works backwards and fll on LS have a mod to fix it.  

TIA! 

Sent from my iPhone

On Nov 27, 2021, at 6:29 PM, Steve Tockey <steve...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "PiDP-8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-8+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pidp-8/5e5e7848-a4bc-4189-9bf9-856b1b6ff538n%40googlegroups.com.

Steve Tockey

unread,
Nov 27, 2021, 6:46:53 PM11/27/21
to PiDP-8
Michael,

"Just wonder, as this might be something to do with one of my other systems (Altair Duino, or IMSAI clone), is there some kind physical mod that needs to be done to the switches on the actual system? 
I seem to recall something that a switch on one of my clones actually works backwards and fll on LS have a mod to fix it."

No. TSS-8 runs fine with the original SIMH PDP-8 implementation. Something got messed up in my translation. But thanks for the suggestion, it was worth considering.


-- steve


Rick Murphy

unread,
Nov 27, 2021, 9:13:03 PM11/27/21
to Steve Tockey, PiDP-8
Steve,
What you're describing is a stuck interrupt.  Some device is "done", which causes an interrupt. The TSS/8 skip chain isn't handling that device, so it's not clearing the done state, so as soon as you turn interrupts back on you're back in the same handler.
SIMH can display the interrupting device flags with the "examine int" command; If I'm reading the code right, the low order bits are assigned to specific devices.  

I'd make sure that you're only including necessary devices in the SIMH configuration to avoid spurious interrupts. (I'm pretty sure this isn't your problem, as you say the same configuration runs under standard SIMH.)
    -Rick

--
You received this message because you are subscribed to the Google Groups "PiDP-8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-8+un...@googlegroups.com.


--
Rick Murphy, D. Sc., CISSP-ISSAP, K1MU/4, Annandale VA USA

Mike Katz

unread,
Nov 27, 2021, 9:44:59 PM11/27/21
to Steve Tockey, PiDP-8
Steve,

This is fantastic to hear.  Thank you for your efforts.

         Mike
--
You received this message because you are subscribed to the Google Groups "PiDP-8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-8+un...@googlegroups.com.

Steve Tockey

unread,
Nov 28, 2021, 6:36:31 PM11/28/21
to PiDP-8
Re: the TSS-8 startup failure.

It turned out to have nothing to do with interrupts after all. I'm not sure how it works fine in the standard PiDP-8/I version but fails here. The root cause is that on TSS-8 start up which is at 24200, the IB (which holds the going-to IF between a CIF and a later JMS or JMP) is 0 and not the 2 that it needs to be. So, the JMS 0060 at address 24204 executed as a JMS to 00060 instead of the necessary JMS to 20060. I added a hopefully well-commented test for a "previously uninitialized" IB and TSS-8 now boots up as it should--just like the standard version. To be sure, IMHO the IB should have been properly initialized earlier in the SIMH startup sequence, before it ever got to sim_instr ().

The reason yesterday's workaround was successful was not the 6007 (CAF), it was the 6223 (CIF CDF 20) which forced the IB = 2 as it needed to be.

The revised code is attached.


-- steve

pdp8_cpu.c

Rick Murphy

unread,
Nov 28, 2021, 9:23:57 PM11/28/21
to Steve Tockey, PiDP-8
Steve,
I'm impressed.
Even if your improvements to the accuracy of the sim don't get upstreamed, this fix needs to be.

Well done.
    -Rick

--
You received this message because you are subscribed to the Google Groups "PiDP-8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-8+un...@googlegroups.com.

Steve Tockey

unread,
Dec 4, 2021, 3:08:08 PM12/4/21
to PiDP-8

Those two problems have been resolved. It appears to be working well at this point, at least as far as I was able to test it. Other people testing it in other ways would be useful. Same instructions as before if you want to try out this version (after, again, backing up the originals of these same files if you want to be able to easily revert to the current version):

In /home/pi/src/pidp8i/trunk/src/SIMH/PDP8 replace the following file with the attached
     pdp8_cpu.c

In /home/pi/src/pidp8i/trunk/src/pidp8i replace the following four files with the attached
     pidp8i.h
     gpio-ils.c
     main.c.in

Then recompile the PiDP-8/I and you should be up and running. E.g., in a terminal window:

$ cd ~/pidp8i
./configure && tools/mmake && sudo make install

should do the recompile and re-install. After that,

$ pidp8i start
$ pidpi8

will have you running.

The TSS-8 boot problem has been fixed, as well as SingStep and SingInst both behave as on a real PDP-8. Caveat: I'm not 100% sure that the MA & MB displays are correct in all major states when SingStep-ing but I am pretty confident of correctness based on my past experience and the DEC documents like the Small Computer Handbooks and handouts from a maintenance course. If someone could verify against a real machine, it would be helpful.

Mounting USB media and booting SIMH to other OS's does work, it's just a different switch sequence than before. Put the desired DF and IF same as before, only now (in this order):
     Sing Inst on
     While holding down Cont
     Toggle Sing Step
If you are mounting USB media, you will need to set both Sing Step and Sing Inst back off and then hit Cont to get running again. If you are booting SIMH to a different OS, you might not need to hit Cont. If you're too slow setting Sing Step and Sing Inst back off then you would need to hit Cont.

Rebooting the Pi is:
     Sing Inst on
     While holding down Start
     Toggle Sing Step

Shutting down the Pi is:
     Sing Inst on
     While holding down Stop
     Toggle Sing Step

A lot of the code comments in these source files are way out of date so effort needs to be spent cleaning that all up. I will be moving these into Fossil soon, so others can contribute if they want (help would be highly appreciated).


-- steve

 
main.c.in
gpio-common.c.in
pdp8_cpu.c
gpio-ils.c
pidp8i.h

Steve Tockey

unread,
Dec 4, 2021, 3:29:40 PM12/4/21
to PiDP-8

Sorry all, typo in the instructions above. After recompiling,

$ pidp8i start
$ pidp8i

will have you running.


Steve Tockey

unread,
Dec 4, 2021, 4:25:53 PM12/4/21
to PiDP-8

Fossil Repo owners,
Re:  "We’re pretty open about giving developer access to someone who’s provided at least one good, substantial patch to the software. If we’ve accepted one of your patches, just ask for a developer account on the forum."

I've made a local Fossil branch on my machine but can't push it to the Tangentsoft server without an account. Let me know what I need to do to make that happen.


Thanks,

-- steve


Steve Tockey

unread,
Jan 1, 2022, 6:34:30 PM1/1/22
to PiDP-8
HB and all,

"So in order not to confuse future generations of pidp8i programmers :-) those will need some cleaning up I guess,. and I'm absolutely willing to help once this is in fossil."

Thanks to help from Warren, the source is now in fossil on branch "cycle-realistic". Comments, improvements, additional testing by others, etc. are all appreciated.

As stated earlier, Oscar's reboot & mount USB media functions did not go away. They just got re-mapped to other switch combinations. Use the front panel switches in the following order to access this functionality in this version:
     Sing Inst on
     While holding down Cont
     Toggle Sing Step
     Sing Inst off
     Cont (if you mounted USB media via DF switches)
You may have to hit Cont if you were booting to a different system via IF switches, but I find that the time lag in the boot cycle is usually long enough that Sing Step and Sing Inst can be back off well before the boot gets to the point it matters. Worst case, if switching systems and it doesn't start running in a suitable time, just make sure both Sing Step and Sing Inst are off and hit Cont.

Also, Sing Inst on + hold down Cont + Sing Step on will reboot Pi OS and Sing Inst on + hold down Stop + Sing Step on shuts down the Pi.


Happy New Year everyone, hope it's healthy, happy, and prosperous for you,

-- steve

Steve Tockey

unread,
Jan 1, 2022, 6:38:51 PM1/1/22
to PiDP-8

Sorry.  Sing Inst on + hold down Start + Sing Step on will reboot Pi OS.


Michael J. Kupec

unread,
Mar 21, 2022, 4:30:50 PM3/21/22
to Steve Tockey, PiDP-8
Steve, 
Yes, one of the switches should be installed backwards or maybe later gen PCB corrects this. 
IIRC, it toggles upwards to do its function. 
I have the info in old emails identifying the switch and have to get on my home computer to search them. Hopefully someone speaks up or I’ll get back about it later tonite. 

Sent from my iPhone

On Nov 27, 2021, at 6:38 PM, Michael J. Kupec <michae...@gmail.com> wrote:

Just wonder, as this might be something to do with one of my other systems (Altair Duino, or IMSAI clone), is there some kind physical mod that needs to be done to the switches on the actual system? 

Mike Katz

unread,
Mar 21, 2022, 5:31:02 PM3/21/22
to Michael J. Kupec, Steve Tockey, PiDP-8
Subject:
PiPD-8/I Deposit Switch Reversal
From:
Mike Katz <justme...@gmail.com>
Date:
3/21/2022, 4:24 PM
To:
Robert Evans <evans.r...@gmail.com>

From Oscar:

Yup, the DEP switch on the original PDP-8/I is upside down (compared to the other momentaries). On the PiDP, it's not (it is in line with the other momentaries). It was a "Decision" way back when I made the kit: I feared too many people would forget that subtlety during soldering. If you want the original position, though, it is simple: cut the trace from diode (right-hand side of diode when seen from the front of the PCB) to the upper switch pin. Replace with a wire to the bottom pin. Mount switch upside-down.

From William Cattey:






Reply all
Reply to author
Forward
0 new messages