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!


Thursday, July 16, 2015

A Mini Project -- BDK-8e

Today we take personal computers for granted.  They are everywhere.  But of course that wasn't always true. In the 1950s a "small" computer would fill a room and typically take as much power as a household (or more!)    A few lucky people got to work on small machines, like the IBM 650 where they had free and total access to the machine for a time. But mostly the machines were too big and expensive to allow one person total access.  They were typically locked away and the only access was by passing a deck of program cards to an operator with your new program to run and getting a printout back sometime later.  If there was an error in your program you had to start over.

Then the transistor got common and (relatively) cheap, and like skirts at the same time, computers started getting smaller. Digital Equipment Corporation (DEC) was founded in 1957 with the intention of making computers. The founders had just come from MIT and Lincoln Labs where they had played important roles in developing some early small computers.  But the venture capitalists wouldn't let them build computers right away, insisting they build logic modules like they had used in the earlier computers.  It was perceived that the market was too small, but the logic modules were in demand.

After two years they finally built their first computer, the PDP-1, using those same logic modules.  Indeed, the logic modules sold well and were used in several DEC computers.  The name PDP comes from Programmed Data Processor; again, the venture capitalists thought the term computer was too menacing.

The PDP-1 was well received.  It was much more affordable than other computers at only $120,000.  Most others cost $1,000,000 or more.  But more importantly it was "friendly."  A user could sit down at it and have it to himself (women were rare.)  It had some interesting devices attached, like a video monitor, that could be used for nifty stuff.  Perhaps the first video game, Spacewar, was created on the PDP-1.

With this first success, DEC moved forward with a series of new machines.  Inspired by their own success and some other interesting machines, especially the CDC-160 and the Linc, they decided to build  a really small and inexpensive machine: the PDP-8. The PDP-8 was a 12 bit computer, where all their previous machines except the PDP-5 were 18 bits.  It would be another four or five years before making the word size a power of 2 (8, 16, 32 bits) would become common.  Computer hardware was expensive and a minimum number of bits would cut the cost dramatically.  It also created limitations.  But the PDP-8 was the right machine at the right time, probably from the right company.  It sold for a mere $18,000.  Up to then a production run of 100 machines was considered a success.  The PDP-8 would go on to sell around 300,000 over the next fifteen to twenty five years.

The original PDP-8 led to successors.  The PDP-8L (lower cost), the PDP-8S (serial), the PDP-8I (integrated circuits), and then the PDP-8e.  There were more models after that, but it seems the PDP-8e was the defining machine.  It was considerably higher performance than its predecessors and much smaller.  It was offered in a tabletop cabinet that would fit on a researcher's lab table.  Many were used for just such purposes.  It was more reliable as well, being made from newer Medium Scale Integration (MSI) integrated circuits that fit many more functions on a chip.  Reliability is directly linked to the number of parts and pins used, and the 8e made both much smaller.  There were very few new features added to later models.  The 8e was in some ways the epitome of the 8 series.  To some degree it defined the minicomputer class.

As I mentioned, the 8 was a 12 bit computer.  That sounds odd today, but wasn't then.  Twelve bit, 18 bit, and 36 bit computers were rather common, and there was even a 9 bit machine that was one of the inspirations for the PDP-8.  Twelve bits allowed it to directly address 4 Kilowords of RAM ( 4096 12 bit words, or 6 Kilobytes.)  That was the normal amount sold with the PDP-8.  It was magnetic core memory and horrendously expensive.  With a memory controller it could be expanded to 32 KWords.  The processor recognized eight basic instructions: AND, TAD (two's complement add),  DCA (deposit and clear accumulator),  ISZ (increment and skip on zero), JMP (jump to new address), JSR (jump to a subroutine and save the return address),  IOT (input output transfer), and OPR (operate).  The last one is really interesting and is actually a whole family of instructions that didn't access memory directly.  OPR was "microprogrammed" meaning that several bits in the instruction had specific meanings and caused different operations to happen.  They could be combined to effectively execute several operations with one instruction.

So the PDP-8 was a very interesting, if minimal, machine.  And it was very popular and very important in the history of computers.  Many individuals collect them and keep them.  Alas, I do not have one.  Some people have re-created them either from original schematics or by using FPGAs or the 6100 or 6120 single-chip PDP-8 microprocessors.  Even those chips are hard to find now.  And that leads me to my new project.

I am creating a new PDP-8 implementation.  The heart of it will be a small microcontroller (ARM) that is programmed to emulate the PDP-8 as accurately as I can make it.  That means with the same input and output system and devices, as well as instruction set.  I intend it to run at the same performance level normally.  I hope to create an Omnibus (the PDP-8e bus) interface that will allow connecting actual PDP-8 peripherals.  I'm not sure exactly what all features it will include, but I plan to make it as complete as reasonably possible.  I will make all the code and schematics available in case anyone else wants to build one.

So, go and Google the PDP-8 to see what a wide array of stuff is on the web about this machine.  Then come back and follow along my journey creating this new relic.  It should be fun...

My PDP-8 project page.

Friday, July 3, 2015

Backups

By now I am sure we all have heard how important backups of our important data are.  I certainly know this lesson well.  But still, I got bit.  Being a "computer professional" I know better.  My daughter told me a few days ago that her laptop quit working.  That laptop and I have a long history.  I have patched it together several times.  But this time it was a different problem.  It wouldn't boot.

Ugh.  My heart sank.  I had meaning to back it up, but just never had.  All her papers and, most importantly, pictures and videos are on that hard drive.  I tried a few of my best ideas, like booting Linux from a CD and trying to read the drive.  Even took the drive out and put it into my main Linux machine and tried copying using "dd" but to to avail.  Horrendous read errors all over the disk.  That's actually the good news.

Why is that the good news?  Because since it reads sometimes but has read errors all over the place, that is a strong indication that it is NOT the data corrupted.  Instead, it seems more like an electronics / controller board problem.  If it were the data on the drive it would likely be more consistent.  I have, a long, long time ago, fixed drives with similar problems by replacing the controller board with an identical one from another drive.  I don't have one like hers easily available, but there is a service that advertises exactly that sort of thing online: Outsource Data Recovery in Cleveland Ohio.

Before I go any further let me tell you what I did wrong.  Trying to access the drive myself could have caused further damage.  If you ever find yourself in a similar situation, shut off the computer and remove the drive and don't do anything with it until you consult a professional.  Every bit of use after the first problem decreases the chances of successful data recovery.

OK, on with the story.  Outsource advertises "$60 hard drive repairs."  If the problem is as simple as mine appears to be, they advertise they can repair the electronics for essentially a $60 flat fee.  If the problem is more in depth they will let you know and let you decide what to do.  I looked around online for more information and reviews of their service.  There are not a lot.  I found about 8 good reviews, pretty much all giving five stars, and one bad one.  The one bad one did sound a bit flaky, like someone who didn't really know what they were talking about.  Over half the good ones were on either the company's own web site or their Google plus page.  So the details are a bit sketchy.  The Better Business Bureau in Cleveland Ohio has them listed, and has no complaints lodged against them.  They are not a member of the BBB.

So, I have decided to give them a try.  I will file a ticket with them and send the drive to them.  I am hopeful.  I think there is a good chance of success.  I will report back with the results.

The lesson here is: don't put off your backups.  Find a good backup strategy and stick to it.  Back up your phone or tablet too.  These days we carry our lives around in our pocket and it only takes a second to lose everything.  I bought a new 4 terabyte external drive to do my backups on.  I'm going now to continue backing up all my important data.  Maybe you should too.