Page 1 of 3

Building your own CPU from TTL chips

Posted: Fri Aug 04, 2006 2:12 pm
by ku7485
This might sound crazy...

I'm thinking about building my own homebrew computer and also want the CPU to be homebrewed. I have heard of CPUs being built from TTL chips from computers such as the DATAPOINT 2200 CTC. The 8008 CPU in that computer is built from TTLs.

Anyway, I have almost no experience in designing TTL circuits (using this project to learn about TTLs), so is there any schematics for this type of stuff? Does anyone have advice on building a TTL CPU?

Posted: Fri Aug 04, 2006 2:30 pm
by MrAl
Hello there!

This might sounds crazy now, but back in the mid to late 70's
when we designed them at my company for the heart of
digital weigh scales used by pharmaceutical companies around
the world, it was far from that i can tell ya, as everyone wanted
Now, it's only a little crazy i guess ha ha, but the speed depends
on how up to date you want this thing to be, and the number
of possible instructions will have to be limited to a small sub set.
The math, and how fast that is, depends on how many chips you
are willing to through into (or onto) the pile that will make up the
board (or boards) that will become the CPU.
The boards we made took up a good 4 x 7 inches or so.

You start with the program counter, and work up, adding functionality
as you go. You have to use 'presetable' binary counters if you want
to include 'jumps' and 'calls' to your instruction set, and you had
better do this for sure or your computer wont be doing much.
You should use static memory so you wont have to design
refresh circuitry.
You'll also need to use some sort of PROM to allow your computer
to boot up either on it's own boot code or by a boot loader in the
PROM. This means you have to do some initial programming
into the PROM to get started.
You'll need to design an instruction decoder too, with possibly
some 1 of 15 decoders or something like that.

You'll have to decide how far you are willing to take this project,
to decide what bus width you want to use, how much memory you
want to address, etc.

We can talk about it more if you want right here...just reply with
more questions. Im sure others will jump in with ideas too.

I wouldnt expect to build one that emulates the current 386 based
machines though, and certainly not the Pentium, unless you have
got a LOT of board space, a big pocketbook, and a small brain
(hee hee, just kidding about that last part, but it wouldnt be
practical really).

Add some math chips for an accumulator.

If you want more interesting info, just look at a block diagram
of an 8008, 8080, or Z80 CPU chip and you'll see the basic
things you will need to build in TTL.

I can tell you it's not that hard, but functionality will be limited,
and speed will be too because it's very hard to design this stuff
over 100MHz with descreet chips that have to be connected with
some sort of wiring or PCB.

A very reasonable starting point would be a 20MHz CPU with
limited instruction set (just the basics).
It's also a good idea to use low power TTL chips.

Posted: Fri Aug 04, 2006 2:58 pm
by jimandy
After fiddling around with an EPROM, connecting it's data-out lines back into it's address lines via a clocked latch, I managed to build some simple sequential logic circuits. I discovered the beauty of using Finite State Machine diagram techniques to conceptualize the logic and I used a spreadsheet to calculate the numeric "micro code". A friend of mine, home on vacation from MIT, looked at my efforts and said – "you have just discovered what lies at the heart of a CPU".

Posted: Fri Aug 04, 2006 4:42 pm
by haklesup
If you goal is education I suggest you limit yourself to a 4 bit hex calculator like computer. Add a few registers and some control logic to shift the data amongst the registers. Even an 8 bit CPU can have many thousands of gates. I hope you don't also want to develop an SRAM or ROM array out of nand gates, you'll be wiring forever. In any case, it should theoretically be possible to do this with nothing but 7400 (quad nand) gates but then you really would be crazy (or at least OCD).

Start with a good digital text book that goes through the concepts you need to design a CPU and then go from there. You may find doing it on paper and implementing in a low end digital simulator will give you just as much experiance sans the actual mechanical assembly skills. A good college lever text will bring you from boolean algebra and logic maps all the way to ALU and CPU design

I wonder if there are any schematics of UNIVAC or ENIAC around that could be translated into TTL (from tubes).

Posted: Fri Aug 04, 2006 5:09 pm
by philba
check out the concept of microprogramming. Here's a decent treatment of it: basically, the machine you are programming is about resources: arith units, busses, storage registers, a program counter and so on. Each higher level instruction is implimented via a low level program. the microcode storage holds the micro programs.

For my master's project centuries ago, I built something like that. You will, indeed, have a much deeper understanding of how computers work.

Posted: Fri Aug 04, 2006 5:19 pm
by ku7485

Found this really cool site: Homebrew CPU. It has a schematic of his CPU design and you can actually even try out and use his CPU that he built though telnet!

I have seen compatibles of Z80, 8008, and 8085 in TTL chip form, but can't find schematics or info on these type of projects. I have looked at the user manuals, looked at the block diagrams, but then what? How would you lay it out with TTLs? Maybe I need to do more research. Do you guys have any recommendations on books or websites that explain CPU design?

Oh yeah, about the ENIAC. I thought it would have been hard to put a ENIAC together with transistors, since the original ENIAC used a system of 10 states (base 10 number system), while todays electronics used a system of 2 states (on/off - binary system). But then I found this site: ENIAC-on-a-Chip. There is also a ENIAC simulator on that site.

Posted: Fri Aug 04, 2006 6:28 pm
by Chris Smith
Keep in mind the modern CPU holds over 400 million transistors in the surface area of a postage stamp. Trying to compare anything close to this is impossible. Even the ancient things of past had tens or thousands of logic switches in tiny spaces, so reinventing the wheel is not a great idea.

However there is nothing wrong with using some of the old, even as over kill because they have it all and more in one tiny package, something you will never achieve.

I used to build logic alarms out of transistors and SCRs until they put thousand of logic circuits into just one chip, and at a price to die for? LSI put a lot of people out of business and then came the CPU.

Posted: Fri Aug 04, 2006 7:00 pm
by stevech
I built a computer from TTL chips at home as a hobby project. This was around 1977 or so. I think Wozniak was building one too. I used TTL because at the time, an 8008 (pre 8080 as I recall) was too expensive for me as a hobby.
I kept the guts of the thing.
8 bit CPU; ALU was the TI ALU chip -big deal then.
Memory - dynamic RAMs were costly and complex timing. So I used 1024 bit shift register chips. One chip per bit. Had to constantly shift to keep memory alive. Program had to wait for bits to shift by to access. Kind of like a drum memory. slow but cheap.

I defined an instruction set for this computer- load, store, add, subtract, branch if zero/non-zero/carry/always and some in/out instructions.

I/O was originally just switches and lights.
Then I found a cheap paper tape punch and reader. clunkity-clunkity.
Then I built an audio cassette tape input-output thing for data. Like 300bps. Was a big improvement. Later I found a digital tape deck - like 2400 bps. Then came a keyboard salvaged from an old keypunch machine. And the coup was an old IBM 360 or earlier output typewriter. Actually, an old typewriter with solenoids. I built an interface for all these solenoids to my CPU. Oh man, 6 chars/sec. Wow. Except carriage return took a couple of seconds.

Then I wrote an assembler in FORTRAN for my computer at work. With that I wrote a native assembler that would run on my CPU. Used paper tape to get program home.

Around this time a 24 x 16 char video generator became available - so I could use a TV set instead of the typewriter. Now came an editor that I wrote. So then I had a self-contained computer.

Around this time I heard about the MITS - but too expensive for me. Besides, I was learning, wire by wire, line of code by line of code.

I think I wrote 10 or so programs that actually calculated and displayed and so on. This was before dial-up modems were popular. In this time frame, we had TYMSHARE and others with big mainframes, but their monthly access fees were beyond my means.

And then I decided I could afford a store-bought kit computer. The Soutwest Technical Products Corp. 6800 based MITS-alike. It got so much easier. But I sure had a good foundation on computers.

The last thing I did with that FLEX-OS computer was to splurge for a 5MB hard disk. Big. cost several week's pay. But I learned how to write a disk driver and manage the media.

It was all fun. Today, I'm amazed at the overhead in Microsoft's operating system and applications software. It's appalling that it eats the CPU speed faster than the chip wizards can innovate under Moore's law/

Posted: Sat Aug 05, 2006 1:38 am
by rshayes
You might try looking for information on the minicomputers of the late 1960s. The PDP-8 (Digital Equipment Corporation) was originally built with transistors and diodes. A lower cost version, the PDP-8s, used serial arithmetic processing to reduce the cost of the machine. Eventually, the computer was converted to TTL logic and designated the PDP-8i. DEC published a programming guide for the PDP-8 which also discussed the machine architecture. Some of the repair manuals might also be on the internet, as this was a very popular machine.

Another, and less well known machine, was the Varian 620i, which was also built with TTL logic.

These machines were usually built using a "bit slice" type of organization, where the processing circuits for 4 bits would be placed on one board. Several of these boards would be combined to make up a 12 or 16 bit computer. A separate board would control the sequence of operations.

Posted: Sat Aug 05, 2006 5:47 am
by MrAl
Hi again,

You start with the Program counter. This should be something like
binary counters strung end to end to make a large counter of
at least 16 bits (four x 4 bit counters end to end).
You should use syncronous type counters so you avoid glitches
caused by fast address changes.
You also need an oscillator to drive the counters, to make them
keep counting and counting...

That's a good starting point if you have never used TTL before.
Get the counters working with the oscillator. Check for pulses on
all the outputs of the binary counter chips.

Once you get that done, you will have your program counter,
the heart of the CPU. Remember to use the synchronous type
that are also presettable.

This is interesting in itself because you can use this program counter
as a frequency counter too if you provide a gate and a gating

If you want to be able to see the state of the program counter at
any time, connect LED's to the outputs in series with large value resistors.
Maybe 4.7k or even 10k. If you use a very slow oscillator you will
be able to see the program counter change state and the 16 bit
binary count progress. Later, when your program counter reaches
a jump instruction, you will see the outputs of the program counters
(which can be now called the 'address lines') change state quickly out
of sequence, which of course means the CPU jumped from one
address to another due to a jump instruction in the program.

This program counter should be very interesting for you if you have
never done this before.
If you want to do this i could draw up a schematic.

BTW, how much previous electronics experience have you had?

Posted: Sat Aug 05, 2006 12:23 pm
by ku7485
Thanks MrAl. It would be really helpful if you could post up the schematic. Is there some computer software where I can design and simulate and see if my design would work? I think I don't have a breadboard big enough for this right now. For now, I'm gonna do more research on CPU design.
BTW, how much previous electronics experience have you had?
I'm a electronics student. Electronics has been my hobby for about two years. Mostly using microcontrollers such as the PICs, AVRs and the 8052(DS89C420) for my projects. But I have never done a project like this involving this many logic chips. I'm using this project as an oppurtunity to get comfortable with logic chips and to have a better understanding on how a CPU works.

Building your own CPU from TTL chips

Posted: Sat Aug 05, 2006 5:36 pm
by homebrewcpu
I'd recommend that you locate an old Forrest Mims book: "Understanding Digital Computers." It's out of print, but easy to find and cheap on Amazon's used book search. It's the book that I started out with when I built my Magic-1 homebrew micro:

The Mims book will give you a good start, and shows how to build some very simple 4-bit cpus. Once you read and understand those, you shouldn't find it too difficult to design and build something a little more powerful. See my "links" page for more resources.

Best of luck,
...Bill Buzbee

Posted: Sat Aug 05, 2006 6:23 pm
by rshayes
You might consider using CPLD chips for breadboarding and simulation. These have about 100 cells that consist of a multiple input AND-OR structure with a latch. They can be programmed to emulate practically any TTL chip.

Three suppliers of this type of part are Xilinx, Lattice, and Altera. I have mainly used Xilinx, since they are available from Digi Key and the programming software can be downloaded from their web site. The programming interface uses a parallel port and consists of a couple of TTL chips and a few other parts.

Programming can be done from either a VHDL file or a captured schematic. The schematic is drawn with logic symbols that can easily be interpreted as TTL gates and flip-flops.

Changing the circuit is done by changing the schematic and then recompiling it, and then reprogramming the chip. This takes about 15 minutes for small changes. That is a lot easier than rewiring chips manually.

Posted: Sat Aug 05, 2006 9:17 pm
by Will
This is a big project - I went through this about twenty years ago - planned it all out but never built it. Just about when I got ready to solder some parts the 6402 cam out so I switched to that.
If I were you, in order not to get too depressed through not seeing intermediate results - I would start out by configuring a four bit adder (An extra bit to catch the carries/overloads would help) fed by two four bit shift registers with the result fed into a fourth shift register which could read out parallel or shift out serial. Then configure a small memory and arrange logic so that you can read numbers from the memory into either of the shift registers, add the two together (Or subtract them by twos complement addition) and read the result from the third shift register into another memory location or back into one of the locations from which the numbers were read (That would be two different instructions) To be able to add two such numbers would be your first instruction so that you would have to design and build the logic to achieve it. Once you have got that down then you can start multiplying and dividing the two numbers. That will require using the shift facility of the shift registers. Once you are done with that then you can investigate sequentially down loading instructions from memory and exceuting them. That is when you will need the program counter. I would also read up on the simple (machine language ) instructions of a simple micro-processor and emulate them - then you will not be re-inviting the wheel. (You might also want to consider holding data and instructions in separate memory banks (Harvard Architecture) instead of the most common which is to mix instructions and data in the same memory block (Van Neumann) Have fun

Posted: Sat Aug 05, 2006 9:23 pm
by jimandy
Let's go back to what you said in you original post...
The 8008 CPU in that computer is built from TTLs.
Yes, the 8008 might have been built on TTL logic but it was a single "integrated" circuit and what I think you may be thinking about is how to build one from discrete logic, i.e. a number of simple chips with basic gates, clocks, latches and ROM. Maybe it's a poor choice of words but I think you're talking about a "disintegrated" CPU design. If so, re-visit my mention of "Finite State Machine" (FSM) design and do a bit of googling on it and the term "Microcode". Stevech mentioned Wozniak who used a FSM circuit for the disk drive controller of the Apple II and it was considered brilliant since microcontrollers were not then readily available or cheap.

Also for the history buffs, I believe there was a 4004 that preceeded the 8008. The story goes that Busicom contracted with Intel for it's design for a calculator but it proved too slow and Intel was stuck wondering what to do with the chip.