Close
0%
0%

Kransputer

1,896 transistors make a CPU that knows one instruction: subtract. Eight of them become a multiprocessor nobody has built from loose parts.

Similar projects worth following
0 followers
A processor built out of individual CMOS transistors — 1,896 for one core, fewer than the 2,300 in an Intel 4004. It knows exactly one instruction: it subtracts one number from another and jumps if the result came out zero or negative. Addition, multiplication, strings and pointers are all built on top of that in software.

It is CMOS rather than the NMOS almost every discrete CPU is built from, so it draws power in proportion to its clock rate instead of burning a watt while standing still. Paying two transistors per gate for that is the reason the rest of the design is so spare.

The goal is not one of these but eight, wired in a ring and passing messages — which appears to be unoccupied ground, since every discrete-transistor computer I can find is a single processor. Nothing is soldered yet.

This is a processor built out of individual transistors — 1,896 of them for one core, fewer than the 2,300 in an Intel 4004.

It knows exactly one instruction. Not a small instruction set: one instruction. It subtracts one number from another and jumps if the result came out zero or negative. That is the entire machine. Addition, multiplication, strings, pointers and loops are all built on top of it in software, which is possible because one instruction is enough to compute anything — a fact that is easier to prove than to believe.

The goal is not one of these but eight, wired in a ring and passing messages to each other. That part appears to be unoccupied ground: every discrete-transistor computer I can find is a single processor, and nearly all of them are NMOS rather than CMOS.

Nothing is soldered yet, and nothing will be for a long time. This is a CMOS homebrew computer being designed in the open, and these logs catch up on how it got here.

Why CMOS, when almost nobody else does

Nearly every discrete-transistor computer ever built is NMOS: one transistor pulling the output down, one resistor pulling it up. Half the parts of the alternative and a far simpler board. MOnSter 6502, discrete6502 and Spikeputor all take that route.

It has one problem, and it is not subtle. A gate holding a low output has its pull-down transistor on and its pull-up resistor still connected to the supply, so there is a complete path from rail to rail. With a 10 kΩ pull-up that is 0.5 mA, burned continuously, per gate.

This machine is on the order of a thousand gates, and at any moment about half of them sit low:

Current per low gate0.5 mA
Gates, order of magnitude~1,000
Standing current~250 mA
Standing power at 5 V~1.25 W

Drawn while computing, while waiting, and while doing nothing at all. It does not depend on the clock, so slowing the machine down does not help — the loss is not switching, it is standing. NMOS builds compensate by running slowly anyway; Spikeputor is around 3 kHz, MOnSter 6502 around 50 kHz.

CMOS replaces the resistor with a P-channel transistor that is switched off precisely when the pull-down is switched on. There is never a path from rail to rail, so a gate that is holding a value draws essentially nothing. Current flows only while switching, which makes power proportional to clock rate rather than to gate count. Speed becomes a dial instead of a fixed bill.

The price is exact: two transistors where NMOS needs one. Every gate, across the whole machine.

That factor of two is the largest single cost decision in this project, and it is the reason everything else about the design is strange. One instruction instead of an instruction set, one bit at a time instead of sixteen, and a serial memory instead of a bus — all three exist to win back the transistors that CMOS costs. Take the CMOS decision away and there is no reason to build the machine this way at all.

Three ideas, and each makes the other two cheaper

One instruction. The machine only knows subleq — subtract, and branch if the result is less than or equal to zero. There is no opcode field, so there is nothing to decode, so the instruction decoder does not exist. What would be an instruction set lives in the assembler, as macros.

A few bits at a time. A serial datapath shrinks the ALU from a block to a handful of gates. You pay in clock cycles, which are cheap in CMOS while transistors are not.

One serial wire. Memory, display and input all speak SPI. There is no address bus, no data bus and no bus drivers — roughly six hundred transistors that would compute nothing.

Remove any one and the other two get worse. Serial arithmetic is only attractive because the memory interface is already serial. The result is that the machine is conceptually a single object: a large shift ring with a one-bit ALU in it.

Why a ring, and not just more memory

Measuring where the clock cycles actually go turned up something I did not expect. Over a real program,...

Read more »

  • Every gate inverts, and that is not a choice

    Dennis Decoene2 hours ago 0 comments

    This CMOS homebrew computer started with one 2N7000 and one resistor, and with me not knowing what a logic gate looked like on the inside.

    A MOSFET is a switch. Put the gate below its threshold voltage and it is an open circuit. Put it above and it is close to a short. The gate itself draws no current, which is the whole reason you can chain thousands of these together without the first one running out of drive.

    Wire one from the output down to ground, put a resistor from the output up to the supply, and feed the gate. Input at 0 V, the transistor is off, the resistor pulls the output to 5 V. Input at 5 V, the transistor is on, it wins against the resistor, output goes to 0 V.

    That is a NOT gate, and it is the entire foundation.

    Put two transistors side by side under the same resistor and either one pulls the output down. Output is high only when both inputs are low. That is NOR.

    Then I tried to build an OR gate

    The obvious idea: I do not want the inversion, so move the resistor to the other side. Put it between the transistor and ground, take the output from between them. Now a high input gives a high output. No inversion.

    Topologically that is fine. Electrically it collapses.

    The transistor only conducts while its gate sits above its source by more than the threshold. In this arrangement the source is the output. As the output rises, the gate-to-source voltage falls, and the transistor throttles itself. Feed 5 V into the gate and the output stops somewhere around 3 V.

    One stage of that is survivable. Feed those 3 V into an identical stage and you come out around 1 V, which is below the threshold. Two stages deep the signal is dead. You have built an attenuator.

    The fix is not a better resistor. The fix is that a stage which only pulls one way restores the signal, because the output is tied hard to a rail rather than sitting somewhere between them. And a stage that only pulls down produces a low output for a high input.

    So every gate inverts. Not as a convention, not as a style — as a consequence of how the device works.

    What that costs

    You buy signal restoration with an inversion, and you pay for the non-inverting functions with an extra stage:

    GateTransistors
    NOT2
    NAND24
    NOR24
    AND26
    OR26

    This is backwards from how the functions are usually taught. AND and OR are the simple ones on paper and the expensive ones in silicon; NAND and NOR are the awkward ones on paper and the cheap ones in silicon. AND is a NAND with an inverter bolted on, and you pay two transistors for the privilege of not inverting.

    Every architectural decision later in this project is downstream of that table.

    The mistake worth recording

    Asked what two transistors in series under a pull-up would do, I said AND. It is NAND.

    I had established the inversion rule about four minutes earlier and immediately forgot to apply it. That is worth writing down because it is the specific error everybody makes at this point: you reason correctly about the pull-down network, work out that both inputs have to be high for current to flow, and then forget that current flowing means the output goes low.

    The rule that fixes it permanently:

    The pull-down network can only ever add paths to ground as inputs go high. More inputs high means more pull-down, means lower output. A stack of transistors is therefore always a decreasing function of its inputs.

    Anything that needs to go up when an input goes up needs a second stage. There is no arrangement of pull-downs that avoids it.

    That constraint is about to become expensive, because there is one very common gate whose truth table does not decrease and does not increase. Next post: XOR, and why it sets the price of every adder ever built.

View project log

Enjoy this project?

Share

Discussions

Does this project spark your interest?

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