Wednesday, March 20, 2013

Design goals (or, hold the electric pony)

In which our protagonist's dreams of an 8-bit supercomputer are cut down to size and he figures out how to make sane design choices.

When you start thinking about your own computer, you dream big. It just has to have that VGA output, a keyboard, an interface to SD-cards, a TCP/IP-stack, an Ethernet connection, and of course its own, a self-built Memory Management Unit (MMU) for all that virtual memory. And a pony. An electric pony, of course.

After studying other people's projects for a while, it not only starts to dawn on you that any computer like that is going to be an incredible amount of work. You also notice everybody keeps recommending one thing over and over again: Dude, start simple.

Which makes you go to the other extreme: Wanting to build the most basic computer possible. Just the CPU, one RAM chip, one EEPROM chip as ROM, a clock can, and some simple I/O such as the 65c51 ACIA to provide one single serial port as terminal access. No interrupts. Not even a power LED! And no electric horseshoes, let alone an electric pony. You can always build a second computer immediately afterwards, right?

Which takes you back to the part about all the work -- maybe too much work to do twice. So for a while you bounce back and forth between the extremes.

In a situation like this, bouts of insomnia are amazingly useful. You stare at the dark ceiling, listen to some song on your iPod -- say, "Suspended in Gaffa" by Kate Bush -- and figure out your real goals for the project. It's well and good to talk about "a childhood dream" and "bragging rights", but we need something more concrete than "make sure it actually works" to provide us with design parameters.

This is what I came up with.

  • Find out what parts of the project I enjoy. This is to explore what elements -- if any -- could develop into a long-term hobby. Programming in assembler is fun, of course. But what about digital electronics? The circuit design? The actual soldering? If I only enjoy some of this, there probably won't be a second computer. If it's mainly the circuit design, for instance, I might get serious about that homebrew CPU, but in VDHL on a FPGA. Cliché time: This computer is about the path, not the destination.
  • Test and experiment with basic features. Include interrupts, because any second computer will have to have them. Include the standard VIA 65c22 Versatile Interface Adapter chip so we get to know it.
  • Build a platform for building a second computer. This sounds like a Deep Thought joke in the making. Still, building an 8-bit computer is lot easier if you have already have one around -- a EEPROM programmer, for example, is not that hard to put together if you have a working machine with those VIA chips. You can use it to experiment with SD-card interfaces, LCD displays, and all the other far-out dreams we just dumped.
  • Make sure it actually works. And of course there is always that.

So now we have guidelines for the design process. In the next entry, we'll (finally) get down to the actual design.

Wednesday, March 6, 2013

Lists of Requirements (and some notes on the red wire)

In which our protagonist bravely faces his own ignorance and draws up a list of things to learn, do, and buy, which turns out to be longer than expected.

There's one small problem with my cunning plan to build a computer: I know jack about practical electronics. The theoretical basics, yes. Things like Ohm's Law, sure. But as for hands-on, build-that-circuit, I have to google to figure out if the red or the black wire is plus. Here lies the greatest danger to the project: Plugging wires and soldering resistors might turn out to be boring, and then everything could end up half-finished on a shelf in the garage. Wouldn't be the first time.

So before this went any further, I bought a digital electronics experiment kit for about 14 euros. It contains two ICs (4011 dual NAND and 4027 dual JK-flipflop), a few small parts such as resistors and LEDs, runs off a nine volt battery, and comes with a booklet of 20 simple experiments. The idea: If that turns out to be boring or frustrating, I abort the whole project and I go off and try to finally find the Amulet of Yendor or something.



The beginnings of an experiment from the kit. Note forceps on the right. Unfortunately, it produces too much pressure to be of much use.

Since you are reading this, it wasn't boring. In fact, it was fun, and I learned a bunch of basics. As a bonus, there were some mistakes in the manual. That forced me to build the circuits using the diagrams and gave me some first-hand experience with hardware debugging.

So, the red wire is plus. What else do you have to know, do, and buy to build a computer?

First and most importantly, you have to read. A lot. Starting with the 6502.org Website, especially the 6502 Primer. Then, pretty much everything else on that site. Basic electronics is a must: Reading teaches you to use a tantalum capacitor at the power jack, but more reading teaches you that they can blow up in your face if you put them in the wrong way around (which I guess is why the red wire thing is so important). You'll need to read datasheets, and then re-read them, until you know what the difference between a 65c22N and 65c22S is and what the BE pin of the 65c02 does. None of this, by the way, is the sort of knowledge that makes you a hit at cocktail parties.

Other things you need to know. Basic practical electronics (including how to solder), basic digital electronics (logic circuits, how to read a datasheet), boolean logic, 6502 assembler programming, how to use an assembler and an emulator. You also needs lots and lots of paper to jot down notes, ideas and designs. Get a very large recycling bin for said paper, because most of your ideas are going to be crap and the designs horribly wrong.

Since this is not nearly enough, you will also need a cheerful willingness to ask absolutely basic and downright embarrassing questions.

Then there is stuff you need to own or buy. A breadboard for testing, a stabilized 5 V power source, a soldering iron, a digital multimeter, tweezers, an EEPROM programmer (more on that in a later entry), an oscilloscope (if affordable), and a logic tester. Then, obviously, the chips and other electronic components for the computer itself, more chips and other electronic components for tests and experiments, wire, and tools such as stripping pliers. If you need six or more binary digits to write down your age, you might want to think about a magnifying glass. The parts are even smaller than they look on the photos.

Some of this stuff you'll already know or have. In my case, I know enough 6502 assembler to get a program up and running, and enough basic digital electronics to understand how to connect the logic stuff. On the other hand, I'm going to have to earn some serious skill points in basic electronics before this is done. Like, what is a "pull-up resistor" and why would I want one?

After the experience with the digital experiment kit, I went out and bought a large breadboard and a whole bunch of logic chips and small stuff for "freestyle" experiments. None of them really makes for exciting reading, so I'll post a summary entry at some point. For now, know that while we're discussing theoretical stuff here for the next few entries, I'm busy in the background reading datasheets and wiring discrete logic chips together to make little lights blink.

In the next entry, we'll start designing the computer. That's definitely fun.