Saturday, July 25, 2015

How to Build a 1965 Computer in 2015

In my last post I introduced my latest project, a replica of the PDP-8e.  I have been quite busy doing research and writing code.  The code is the easy part!  The hardest part is making it look authentic.  But, thankfully, I am not the only crazy person out there that wants to build a fifty year old computer.  There seem to be quite a few of us.  A few stand out. Oscar at Obsolescence Guaranteed has done much of what I'm working on.  His approach is a bit different.  First, he has re-created an 8i instead of an 8e.  Second, he was smart and used an emulator already written and hardware already built to make much of his reproduction.  He has done a great project and created a kit.  I highly recommend you check it out.
picture from http://vandermark.ch/pdp8/index.php?n=Hardware.Processor

Oscar has also done a lot of research that will help me.  Fonts and colors for the front panel, for instance.  Have you ever thought about how to go about reproducing a replica of a 50 year old piece of equipment and have all the colors and letters look just right?

There is also Spare Time Gizmos with the SBC 6120.  That project/product uses The Harris 6120 PDP-8 microprocessor as the CPU for a sort-of genuine PDP-8.  Alas, the 6120 and its predecessor the 6100 are rarer than gold-plated hens' teeth.  But it's a really cool project with lots of good information and inspiration, much like PiDP-8 from Oscar.

Our approach will be a bit different.  The front panel will be as authentic as I can reasonably make it, in looks and operation.  So will the CPU, with a bit of a twist.  I don't really want to build a few boards of TTL logic to create the CPU.  The 6100 and 6120 are really hard to find and expensive when you do find one.  Replacements and spares are just as rare and expensive. An FPGA would be good, but my verilog and VHDL skills as well as fine pitch SMD soldering skills aren't up to it yet.  Not to mention I want to make this easily reproducible for others. So I have decided to take a 21st century 32 bit microcontroller with flash and RAM onboard and nice input output devices and create a new PDP-8 on a chip.

The PDP-8 instruction set is really simple.  There are eight basic instructions.  Two of those, Operate and IO Transfer can actually have several "microprogrammed" instructions to do various operations.  But overall, it's quite simple.  To emulate the instructions, at least two approaches can be used.  First, you can write code that simply ends up with the same result as each instruction.  That's fine for most uses and tends to be more efficient.  Let the new processor work the way it is intended and get the results you need.  As long as the final state at the end of each instruction is exactly what it would be with the real computer, everything is fine.  No matter how you got there.  The other way, though, is more suitable to our purpose.

What we are going to do is essentially emulate the same hardware as used in the PDP-8 in our program.  It will, of course, end up with the same results.  But how we get there matters. The PDP-8 cpu has three "major states" with four clock cycles in each major state.  Our code will follow that, doing the same processing in each state and cycle as the real hardware does.  It won't be as efficient, but since we are running a very fast 32 bit modern processor to emulate a 12 bit system from 50 years ago, it should be plenty fast.    This begs the question, "why?"

The answer simple: we want to build an entire PDP-8, not just a program that emulates one.  The real PDP-8 can be stepped through individual cycles and the front panel show what is inside the CPU at each step.  We can only do that if we follow the same steps.  Plus, if we decide to add an external bus to add peripherals (like the Omnibus of the real PDP-8e) we will need those individual cycles to make the real hardware respond properly.

The first step is to write the emulator program and put it into a microcontroller.  I have started with a NXP LPC1114.  I have them and I'm familiar with them and they are plenty powerful enough to make this work.  They come in a 28 pin DIP package for easy prototyping.  The biggest downfall is the DIP version only has 4K Bytes of RAM, so we won't be able to emulate even a full 4K word PDP-8.  I think I can fit 2K words in it, though.  And that should be fun to play with.  Eventually I will use a somewhat larger chip that can hold the entire 4K words or maybe even the full blown 32K words.  The plan is to create a chip that has a fixed program inside in the flash that emulates a real PDP-8 as accurately as possible.  I will add the front panel hardware and any other IO devices to that.  Others can take the same chip, much as they might with a (hard to get) 6100 or 6120 chip, and use it as the CPU for their own PDP-8!

Currently, the CPU emulation is about 90% coded.  Once the basic coding is complete, testing for real will begin.  I've run a couple simple programs on it so far and the results are encouraging.  There is still a lot of work to do.  Mostly IO stuff.  But I hope to soon be able to post the initial version of a 21st century PDP-8 cpu chip.  Get your soldering irons warm and take that paper tape reader out of storage!


1 comment: