Close
0%
0%

Simple ALU from discrete components

Prototyping some processor functions using logical gates made of discrete transistors, resistors and diodes

Similar projects worth following
This is an offshoot from the 16-bit ttl computer project, where I intend to make some scaled down components of the CPU from discrete transistors and other components.

All the circuits I am doing for this project are based on one fundamental unit logic gate: DTL invertor/NAND (depending on a number of inputs.

Here is the schematic for 2-input NAND gate:

One can make arbitrary number of inputs (within reason) by just changing the number of diodes. By adding additional (inverting) output stage AND gate is done.

With the resistor values shown, the gates are not particularly fast, but on the other hand have a small power consumption. And anyway I have a ton of resistors with these values, so I am using them.

In the course of iterations through the time I came out with circuit layout which can be likened to "semi-cordwood" -- by using 3rd dimension I had achieved much more close packaging, and simplification of wiring, in exchange to reduced repairability. The Vcc and Gnd are on separate planes, with Vcc made as a mesh of inter soldered resistor leads on top of the circuit, and Gnd wires going under it.

On the photo below is the closeup on the Arithmetic board, where details of this construction method could be inferred.

By using component leads as signal pathways and connecting gates directly with them, as well as placing gates more closely and symmetrically, further compactification and reducing number of additional connecting wires is achieved.

Here is an example of an XOR gate made of four NAND gates:

So, I am set to use these NAND gates wherever possible, with addition of AND gates where necessary. Using NOR / OR gates is not as parts/real estate efficient, and I am trying to avoid them.

8 bit Adder-subtractor.dig

This is a working simulation of the 8-bit Arithmetic Unit. To run it, use the "Digital" logic simulator by H. Neeman: https://github.com/hneemann/Digital/releases

- 89.39 kB - 01/22/2019 at 05:26

Download

  • The Control Panel

    Pavel01/23/2019 at 06:21 1 comment

    Building the Arithmetic Unit is great, but as it is there is no simple way to assess its workings. As I've built it, I am personally know what to look at, but for most outside people, the shining of the LEDs on the board is still cryptic. Also, by no means it is obvious for me at the first glance. And giving inputs by connecting individual wires is a pain.

    So, the solution for this is simple interface, Control Panel (CP) with switches and indicator lights for switch states and output from the circuit to which it is connected.

    For each individual switch, there is a simple circuit:

    The values of resistors directly connected to the transistor may vary depending on the colour of LED.

    I decided to make this control panel look pretty, and for this , it is composed of two boards, one with switches, lights and connectors ("face board"), and other with all transistors and most of resistors ("driver board").

    It turned out to be quite a lot of work, because there are so many wires I needed to solder. 

    So, here is the "face board":

    Connectors:

    Facing left, 4 pin, signals, from top to bottom: Carry_out (coming to the CP), Carry_in, Carry_in_enable, Sub/Inv B

    On the top, from left to right:

    8 bit operand A - coming out of CP;

    8 bit operand B - coming out of CP;

    8 bit Result - coming into the CP.

    Switches and associated lights:

    Individual switches:

    Leftmost, with clear Red LED - Carry_in_enable,

    Closer to light rows, with coloured Blue LED - SUB/INV,

    Rightmost, with coloured Red LED - Carry_in.

    Switch banks:

    Left -- operand A, associated with the top row, Yellow, LEDs,

    Right -- operand B, associated with the middle row, Green LEDs.

    Lights indicating incoming signals -- bottom row, 9 White LEDs:

    The leftmost, Warm White, near SUB/INV switch: Carry_out,

    The rest 8, Cold White: Result.

    And the "driver board":

    On this overview one can see these boards connected with a bunch of wires:

    When the boards are stacked, it all looks prettier:

    View from the sides:

    Testing all the lights (except for C_out):

    After all the teasing, below there are image of this Control Panel connected to the Arithmetic Unit:

    And the video showing how it all works together.

    Total parts count for the Control Panel:

    Part namecount
    Perfboard 30*24 holes (9*7 cm)2
    2N2222A npn transistor19
    Resistor 510R8
    Resistor 1k28
    Resistor 10k17
    Resistor 20k1
    Resistor 100k10
    Red LED (clear)1
    Red LED (coloured)1
    Blue LED (coloured)1
    Yellow LED (coloured)8
    Green LED (coloured)8
    Warm White LED (clear)1
    Cold White LED (clear)8
    SPDT switch (connected as spst)3
    DIP bank of 8 SPST switches2
    L7805 Voltage regulator1
    Capacitor 0.1uF1
    Capacitor 0.33uF1
    Pin headers x83
    Pin headers x41
    Power connector2
    Total parts127

  • Arithmetic Unit

    Pavel01/22/2019 at 06:46 0 comments

    The ALU (Arithmetic Logic Unit) is arguably is a heart of any CPU, which is doing the operations on the bits and bytes of data.

    Here I am making an Arithmetic half of it, the circuit which, in my case, is going to do additions and subtractions on 8-bit binary numbers.

    For it I am using only NAND gates, which are the smallest DTL gates I can make from discrete components -- and these already 7 parts per gate.

    Lets start to build up this unit.

    Here is the classical schematic for a full adder:

    Here no NAND gate in sight. But theoretically, one can make any other gate from NANDs, so this should not discourage us. We can substitute XORs by groups of 4 NAND gates:

    And we can also easily substitute AND-OR combination with NAND-NAND, and logical function will stay the same:

    And now, one can see that highlighted pairs of NAND gates are doing exactly the same work, and we can safely eliminate two of them without compromising the whole circuit:

    For the unit to do subtractions, we need a way to conditionally invert the B input - and this can be done with just one other XOR gate, which in this case will also be 4 NAND gates instead:

    After stacking 8 of these units, and making conditional inverting on Carry in +adding C_in enable we are having a full-fledged 8-bit ripple adder-subtractor. If we are also  using output from the middle XOR group (right before C_in input), we than have a "free" XOR/XNOR functionality.

    On the completion of this stacking we are getting this:

    This configuration of gates is almost exactly the same as on the actual board.

    Implementing this the way I do, the board looks like this:

    On the photo is a complete board during testing. The only additional parts are L7805 voltage regulator with a pair of caps on the lower right, near alligators.

    Pin headers are used as convenient connection points; this was done for connecting with some other boards in the future, most prominently, with control panel, which will be described in the next log.

    Here is parts count for this board:

    Part namecount
    Perfboard 78*36 holes1
    2N2222A npn transistor110
    1N4148 diode218
    Resistor 10k110
    Resistor 20k109
    Resistor 47k109
    Red LED (clear)109
    L7805 Voltage regulator1
    Capacitor 0.1uF1
    Capacitor 0.33uF1
    Pin headers x84
    Pin headers x41
    Power connector1
    Total parts775

View all 2 project logs

Enjoy this project?

Share

Discussions

Dr. Cockroach wrote 06/27/2019 at 16:48 point

Looking good :-D My kind of wiring without the cardboard :-D

  Are you sure? yes | no

Dave's Dev Lab wrote 01/23/2019 at 04:15 point

great looking build! the documentation and logs are awesome!

  Are you sure? yes | no

Pavel wrote 01/23/2019 at 05:04 point

Thanks!

  Are you sure? yes | no

Dan Maloney wrote 01/22/2019 at 16:19 point

Love the build - tidy and chaotic at the same time. It almost looks like you intend to make these pluggable modules, judging by the headers at the end of the card. Nice design!

  Are you sure? yes | no

Pavel wrote 01/22/2019 at 18:09 point

The intention here is to connect modules with ribbon cables, as boards themselves are quite flimsy, and need support.

  Are you sure? yes | no

Ken Yap wrote 01/22/2019 at 07:44 point

Cool! It's a pity you couldn't spare one more transistor and resistor per gate like the Fairchild DTL series:

https://datasheet.datasheetarchive.com/originals/scans/Scans-026/ScansUX9780.pdf

I suppose you wanted that LED indicator. It cuts into your noise margin though. What voltage are you running it at?

I still have some DTL chips somewhere. I feel old. :(

  Are you sure? yes | no

Pavel wrote 01/22/2019 at 10:56 point

Thank you for datasheet, I didn't know about these particular schematics. I started with the schematic, found on the internet, where there are two diodes in a row used, coming into the transistor base. I used red LED instead of pair of 4148, just to lower part count. That they also act as indicators is just happy coincidence, which also happens to simplify testing by much. I actually tried variation with a second transistor, but without middle diode, and it was not good by my measure. 

Also, datasheets are describing ICs, and as I had read somewhere, making a transistor instead of diode comes essentially at no cost chip real estate wise.

As for noise tolerance, my gates are quite good, as anything below 1,9 V is low, and above is high. Output swings almost rail to rail. Just a bit slow) 

And lastly, I tried to minimize part count per gate as much as I could, because when doing bigger circuits it all adds up. 

I use 5 Volt for my circuits.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

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