Close
0%
0%

NanoCPU.org

An educational 16-bit CPU made from < 1000 transistors with lots of LEDs that anyone can build and learn from

Similar projects worth following
The main web site is http://www.nanocpu.org/ - below is extracts from the home page on 11Jan17

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
* 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 and any memory mapped IO
* Control the clock, so you can single step in software
* Run the compiler
* Run the job queue
* Host the webcam so you can submit a job and see it see it see it running

All the details, including all of my mistakes, are on http://www.nanocpu.org. When I finish something big then I post it to a project log here.

  • DIY PCB - the problem of cheap visible circuit construction

    Tony Robinson03/08/2017 at 10:20 0 comments

    The biggest problem in this project has always been to create a processor that others can see what is going on, build it themselves and adapt it themselves.

    This is quite a design challenge for me. I want all the components and wiring to be visible and I'd like the costs to come in at about £100 so that I don't put off others building and adapting. I believe this rules out standard PCBs.

    I'm developing the idea or printing onto paper, sticking the paper on matrix board and mounting all components though the paper. All wiring is then visible on the front surface. I am allowing myself power supply wiring on the reverse, using map pins (or similar) on the visible side.

    So far I like the idea. The white background gives good contrast and the finished circuit does look like the schematic, so making electronics visible, my main goal. Here is my first "PCB":

    What I haven't got right yet is (a) what to print (b) I need whiter heavier paper (maybe plasticised) and (c) it's fiddly getting 4 legs down one hole. Oh, and it has to work of course, what you see above isn't soldered on the reverse, this is very much work in progress.

    More detail at http://www.nanocpu.org/leds-and-wiring

  • A 2 transistor 9 diode memory cell

    Tony Robinson03/01/2017 at 15:53 0 comments

    Here is (hopefully) the final memory cell architecture for my processor.

    It uses two transistors as a flip-flop to store the state, S. There is also: IN - data in, WE - Write enable, OUT - data out and RE, Read enable.

    Write is:

    S = (S AND NOT WE) OR (WE AND IN)

    (the NOT comes for almost free as it's shared across all 16 memory cells in a register).

    Read is:

    OUT = S AND RE

    Both AND and OR may be implemented with two diodes and a resistor (e.g. http://electronics.stackexchange.com/questions/131860/diode-logic-gates). This is the simplest memory cell I can think of, if you double the write logic you can write to both halves of the flip-flop at the same time which improves speed - but I value simplicity over speed.

    So, after fighting http://circuits-cloud.com/ all day (most saves fail and force a reload of the last successful save making progess painfully slow - I'm not using them again), here is the circuit diagram:

    The left hand side does the write, the right hand side does the read (to two buses, 2T 9D is for only one read). Let's say we want to write, then we set WE high and the left AND circuit has the value of IN, where as the next AND circuit is low (as !WE is low). The OR of these two AND circuits is therefore the value of IN. Hence the base of NPN1 is set to IN, if it's high then the transistor conducts and the LED light is lit. R3 sends a low to NPN2 which is then off. When WE is low, !WE is high, so the output of NPN2 is fed back into NPN1 and a bit is stored.

    The right hand side does the read and is considerably easier. Both OUT0 and OUT1 are AND functions of the relevant read enable signal (RE0 and RE1 respectively).

    If anyone knows of a decent circuit layout for matrix board I really need it.

  • Fast carry propagation for a new ALU

    Tony Robinson02/23/2017 at 07:19 0 comments

    I decided to redesign my ALU, the old one worked but it wasn't easy to see how it worked. It was too clever, I think people expect an ALU to compute everything (AND, OR, XOR, ADD/SUB, ASR) in a way they can see and then select the right output - that is much easier to understand.

    Minimal ALUs are limited by the ripple-carry propagation time, so the first thing to do was to get my fast carry propagation design working. The slow bit of bipolar junction transistors is switching them off, so I got rid of all of them and used diodes to do all the carry propagation (these will be Schottky diodes for fast switching and low voltage drop). So here it is in it;s simplest form:

    Generate, G, is high if both inputs are high. Kill, K, is high if both inputs are low. The carry goes in on the left, if K1 is high then the first NPN is on and the carry is grounded, if G1 is high then the carry out is high else the carry is propagated. That's pretty simple, I feel confident I can both get this implemented in a way that you can see the signal flow (as above) and thus be able to explain how this time-critical bit of a CPU works to all.

    There's more detail at http://www.nanocpu.org/alu

  • the state machine - or lack of one

    Tony Robinson02/09/2017 at 20:40 0 comments

    Wow, the state machine of the CPU is hard - really hard. I thought I should start with what took the most real estate, the ALU and the memory cells, now I think I'm (touch wood) on top of both of those (I will update logs with progress as and when) but I'm struggling with the state machine - that is the bit of logic that raises all of the right enable lines at the right time. I shouldn't be at all surprised, there's a few people on home-built computers web-ring who said the same thing - it's the go-to site.

    So this isn't really a log entry as I don't have a state machine. What I find fascinating is that a CPU is something that, in my software world, runs compiled code (leaving aside the fact I run Python under Linux in a VM running Windows) but is really something that may execute microcode which may execute itself to fetch instructions (my I = *P++) which executes a state machine which executes a set of control lines which executes a set of logical functions which are expressed as analog signal processing where semiconductor physics (my almost-lost first degree) does the hard work.

    So many levels. I really don't like public speaking unless I have something worthwhile to say, but taking all this from a "BASIC" language through FORTH, assembly code, right the way down to the electrons and holes is something I feel confident I can engage and audience with. Teaching technology is not my goal - my goal is to encourage others to explore their dreams, however corny that sounds. But to do that I've got to succeed and that's a lot more time and effort away that I can plan for (even when you take into account Hofstadter's law).

  • 3.3v vs 5v

    Tony Robinson01/27/2017 at 19:17 14 comments

    Right now my #1 question to sort out is should I run this at 3.3v or 5v? 3.3v has the advantage that transistors switch faster, and I'm an optimiser so I would like this. However I love blue LEDs and have just bought a thousand of them, these are on max current when wired 3.3v -> LED -> NPN -> ground without a current limiting resistor. Should I worry that the LED might short and so blow the lot? (yes I think so). Also my new carry logic uses a diodes ladder which would like 5v much more than 3.3v (at a pinch I could use 5v just for this). So what should it be, 3.3v or 5v - I have yet to decide.

    [ I've been out of the country on a work trip so haven't had any time for this in the last week and a bit - some new Schottky diodes have arrived and I need to stress test my new memory cell - time to take a day's holiday I think ]

    P.S. it seems that there is a maximum thread depth which is stopping me replying directly below some of the comments. As a result they are appearing above which does confuse the flow.

View all 5 project logs

Enjoy this project?

Share

Discussions

Mark Nesselhaus wrote 03/07/2017 at 20:51 point

Good afternoon, I like checking in on your progress. I have some glitches in my project at each stage and it sure has been a learning curve for me but fun at the same time :-) I might try your memory cell out. My memory for the registers is not set in stone yet.

  Are you sure? yes | no

Yann Guidon / YGDES wrote 01/18/2017 at 03:24 point
9 diodes ? That's "above average" :-D

  Are you sure? yes | no

Tony Robinson wrote 01/17/2017 at 16:28 point

I will keep trying!   I now think I have a two transistor, 9 diode memory cell.     You will like the fact that it works on logic, not some dodgy assumed behaviour of NPN bipolar transistors.   I don't know when I'll get the time to put it together and write it up, hopefully this weekend.   Cheers, Tony.

  Are you sure? yes | no

Yann Guidon / YGDES wrote 01/14/2017 at 17:11 point

Thank you for sharing and being open, I'm sure you learn a lot from your mistakes and will make something very cool soon :-)

Developing a good flip-flop is a lost art and there is no shame in making mistakes, everybody does that :-D

Keep trying !

  Are you sure? yes | no

Does this project spark your interest?

Become a member to follow this project and never miss any updates