tonyr
Posts: 33
Joined: Mon Aug 29, 2016 2:24 pm

Build your own CPU out of transistors

Mon Dec 12, 2016 8:46 pm

I'm (slowly) building a CPU from transistors. To copy my page from nanocpu.org:
Computers are everywhere and virtually nobody understands how they work at all levels. We all know that they are built from transistors, but how do you get from a bunch of transistors to a machine that runs useful software? I see a real need to come up with a CPU design that anyone could understand, build and adapt, particularly schools and universities.

The goals are:
* Simple enough so that everyone can see how it works, that means lots of LEDs
* Complex enough to demonstrate the main ideas of a CPU
* Small enough to be affordable by anyone with the time to build it
* Quick enough to build and keep my (and those that follow me) family life
* Fast enough to run some complex software (at least a game written in Forth, hopefully C later).
* Slow enough so that everyone can see it running and understand it step by step
* Flat enough so that the entire state can be seen in one go

The CPU is Raspberry Pi hosted which will:
* Be the main memory
* Run the compiler
* Run the job queue
* Host the webpage and webcam so you can submit a job and see it see it running
This is just an invitation to connect if you are interested or you are a school teacher/lecturer who wants an interesting project (I'm quite experienced at supervising).

The website and associated forum have zero visitors to date, so if you want to share in the fame of an open source educational project then now is the time to jump in! Only joking, it's really early stage, I'll post back when I've carved out school/uni projects - but if you have my warped mindset then let's talk.


Tony

User avatar
jojopi
Posts: 3316
Joined: Tue Oct 11, 2011 8:38 pm

Re: Build your own CPU out of transistors

Mon Dec 12, 2016 11:04 pm

You need several transistors per bit of memory, and per gate of logic.

Why not use 74HC series logic chips? You get several gates per chip. They are cheaper and use less power.

You can restrict yourself to a single type of chip, if you wish to be purist.

tonyr
Posts: 33
Joined: Mon Aug 29, 2016 2:24 pm

Re: Build your own CPU out of transistors

Wed Dec 14, 2016 8:10 pm

jojopi wrote:You need several transistors per bit of memory, and per gate of logic.

Why not use 74HC series logic chips? You get several gates per chip. They are cheaper and use less power.

You can restrict yourself to a single type of chip, if you wish to be purist.
As soon as it gets to a black box I think "well why not just put a 6502 in there". I want everything to be understandable from basic -> forth -> assembler -> architecture -> memory/bus/instructiondecoder -> transistor -> led.

Yes, I need several transistors to get a bit of memory. I have a design I've not seen elsewhere. Similarly for the ALU. I think it important that these things are explained at the transistor level.

But this is just what I want to do. Other people have different goals and there are several very wonderful 74 series based designs at http://members.iinet.net.au/~daveb/simp ... ghome.html. There are also people who chose to go the other way and build relay computers - and I really admire them - I just don't have the time right now.

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Build your own CPU out of transistors

Fri Dec 16, 2016 7:51 pm

Somewhere back in the late 70's, early eighties, I was a shift leader working in a computer room containing these :
http://www.computinghistory.org.uk/det/ ... -FM1600-B/ at Ferranti in Bracknell. My boss a few years after that actually said that I would "always have a job at Ferranti because the Navy would always use Ferranti computers"!! There is one in the "Sheffield" under the south atlantic, somewhere (still running?). Ferranti was wiped out by some scam, many people lost their pensions.
In those days 8-hole punched mylar tape was used to load in the "fire control" system (the reel of mylar could be at least 9" across). Look for the tape reader and bin. We had to rewind those tapes for re-use!!!
I think that there were a few "gates" per board, one engineer would locate faults (usually dry joints) by running a pencil along the ends of the boards.
A few years later the IBM PC on 8088/8086 was to change everything.
Nowadays I guess they use some variant of the PC and if it goes wrong they throw it overboard and get a new one out of stores.

User avatar
Michiel O.
Posts: 178
Joined: Mon Dec 12, 2016 12:06 pm

Re: Build your own CPU out of transistors

Fri Dec 16, 2016 8:59 pm

Prepare to use at least 2000 to 3000 transistors to get some instruction-logic going (the 6502 has 4000 transistors). I like the idea of putting LED everywhere, the blinkenlights should be spectacular, although the busier parts of the circuit will switch logic levels so fast that the LEDs will seem to burn at a continuous low level, at least for our eyes.
"You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes

tonyr
Posts: 33
Joined: Mon Aug 29, 2016 2:24 pm

Re: Build your own CPU out of transistors

Fri Dec 16, 2016 10:20 pm

Oh thank you. I started with a 4004 based machine and only really dug into the real detail with the 6502 so I do love these stories. The 24 bit instruction with 3 address resonates with me, I've followed through a few links and learned a lot. I am tempted to increase my instruction width from 16 bits to 24 bits, so many things would be easier (and of course it could then address 16m words instead of just 64k - although 64k is much more in keeping with the era).

I soon ended up at http://www.chilton-computing.org.uk/acl ... erview.htm which is just amazing. Many thanks, I think I'll learn a lot.

Cheers,

Tony

User avatar
Newton
Posts: 8
Joined: Thu May 31, 2012 4:24 pm
Location: Somerset West, South Africa
Contact: Website

Re: Build your own CPU out of transistors

Mon Dec 19, 2016 7:23 am

You don't really need transistors. Matches, a sheet of paper and a pen will do:

https://web.archive.org/web/20140523212 ... age_id=293

Have fun computing from the ground up.

peterlite
Posts: 720
Joined: Sun Apr 17, 2016 4:00 am

Re: Build your own CPU out of transistors

Mon Dec 19, 2016 9:37 am

To avoid something as high tech as LEDs, wire up an abacus with robot arms to flick the bits back and forth along the register wires.

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Build your own CPU out of transistors

Wed Dec 21, 2016 8:06 pm

The Ferranti F1600 series had a 24 bit instruction code (Fixpac3 Autocode was the low level language) - the instruction set had 3 address fields, v0 to v31. v1 to v23 were registers. v0 (hazy?), v24 thru v31 had special uses (Hazy). I think v24 was "input from tape reader"?? There were also "index registers" that could be pointed at memory and .... indexed. N1, N2 ... VN1 Value of register, etc. I remember a few codes ->
7004 was goto (!) location in memory, 7014 x y z was stop (!! yes they did stop....).
0100 1 2 20 would add v1 to v2 and store in v20.....
Some instructions used data in next "word" of memory. e.g set N1 to value of address.

To start a program in the computer, you had to bootstrap using the 24 switch panel, by manually inserting about 6 instructions (it felt like more!). (Later systems had a rotary bootstrop injector knob to save the human error at the beginning). These started a punched tape inputting to a punched tape reader, with the rest of the bootstrap code - they used to put the bootstrap on the front of a full reel system, so it read straight in . . . . How long does it take to read a full reel of punched mylar tape? 5 minutes? (Navy Fire Control System !)
Found these: -
http://www.computinghistory.org.uk/det/ ... -FM1600-B/
http://discovery.nationalarchives.gov.u ... 230f08cb98

RaspISteve
Posts: 100
Joined: Wed Oct 24, 2012 9:15 pm
Location: Cheltenham, UK

Re: Build your own CPU out of transistors

Sat Dec 24, 2016 1:46 am

Tony,
You might want to start building the basic blocks like AND, OR and XOR gates out of transistors/diodes then move on to NAND, NOR simple flip-flops. Then look at JK flip-lops and on to simple registers. By this time you would have used up an enormous number of components but only brushed against the enormity of what you are aiming for.

Once you are happy with the basics move on to half adders, then full adders to make a simple one or two bit arithmetic/logic unit (ALU). Trying for anything other than very simple one or two bit logic is going to get you into an awesome number of components and still not be able to do much.

The first computer I played with was a CDC160. It was a great big desk of a thing rammed with little boards each with a load of transistors but had fairly modest computing power. Anything you are likely to get going will be largely impenetrable in terms of anyone else understanding it.

Large numbers of transistors will take loads of current, as will any indicators to add for visualisation. Your power supply could end up very big. Consider building the thing in software using a circuit emulator of some kind and make it graphical allowing you to zoom into a module at a time to explore the operation. If you pull it all off it will be easily repeatable and explorable.

If you investigate some form of graphical object based computer language to emulate the basics then build more complex modules using the language. If you do want to complete the hardware follow your working software simulation. Either way try to complete a software emulation/design BEFORE you get anything going. Maybe go count the number of valves in Colossus to get a handle on what you need.

Good luck on this one...
Share and Enjoy.

tonyr
Posts: 33
Joined: Mon Aug 29, 2016 2:24 pm

Re: Build your own CPU out of transistors

Sat Dec 24, 2016 8:55 am

RaspISteve wrote: You might want to start building the basic blocks like AND, OR and XOR gates out of transistors/diodes then move on to NAND, NOR simple flip-flops. Then look at JK flip-lops and on to simple registers. By this time you would have used up an enormous number of components but only brushed against the enormity of what you are aiming for.

Once you are happy with the basics move on to half adders, then full adders to make a simple one or two bit arithmetic/logic unit (ALU). Trying for anything other than very simple one or two bit logic is going to get you into an awesome number of components and still not be able to do much.

The first computer I played with was a CDC160. It was a great big desk of a thing rammed with little boards each with a load of transistors but had fairly modest computing power. Anything you are likely to get going will be largely impenetrable in terms of anyone else understanding it.

Large numbers of transistors will take loads of current, as will any indicators to add for visualisation. Your power supply could end up very big. Consider building the thing in software using a circuit emulator of some kind and make it graphical allowing you to zoom into a module at a time to explore the operation. If you pull it all off it will be easily repeatable and explorable.

If you investigate some form of graphical object based computer language to emulate the basics then build more complex modules using the language. If you do want to complete the hardware follow your working software simulation. Either way try to complete a software emulation/design BEFORE you get anything going. Maybe go count the number of valves in Colossus to get a handle on what you need.

Good luck on this one...
Thanks Steve - I think you think like I think. You can see the state of the project at nanocpu.org.

To pick up on some of your points:

* I agree that mapping transistors to logic gates is the standard way of doing this (e.g. see the megaprocessor) but I'm being a bit more creative in my design. I have a 4T memory cell and a 2T XOR which you don't get if you start with NAND and build everything out of that.

* I've just bought 1000 transistors for £5 - but that won't stop me building this in a very small number of transistors. I'm aiming for under 2000, maybe it'll be much less. Have a look at the instruction set, there's no branch you just write to the program counter.

* There will be lots of LEDs for visualisation. I'm not worried about the power consumption.

* I'm going for the opposite of "Anything you are likely to get going will be largely impenetrable in terms of anyone else understanding it." as you can see by my goals at the top of this thread.

Return to “Other projects”