# Designing your own computer. Part 1

#### Introductory part. "Napoleonic plans"

Almost a year ago, I had the idea to understand how a computer works, how it works. And of course, there was a huge desire to create your own on elementary logic elements (to be more precise - on transistors).
Then I had only a small idea of ​​his work: I knew that all digital electronics was built on logic elements (for me it was like a postulate), but I could not figure out how the program was executed, numbers were summed up, why interruptions ... This list questions can go on, but not about that now.
Define the characteristics of the developed computer:
• Logic Type: Binary Logic
• Data bus resolution: 32 bits
• Address bus width: 24 bits (16 777 216 32-bit numbers can be addressed)
• Execution of basic arithmetic, logical, bitwise operations on data, as well as operations on memory cells (mov, xchg)
• Implementation of the memory allocation function (4 assembler instructions are provided)
• Data processing directly and using pointers

#### Software

For the design of logic circuits, there are many programs. But for large-scale design and debugging, my requirements were satisfied only by two programs (probably my requirements are too severe):

Actually requirements:
1. Intuitive interface
2. Creating large schemas
3. Ability to create modular schemes (scheme in the scheme)
4. A variety of basic logic elements with the ability to edit their parameters
5. The presence of the element "RAM" and \ or "ROM"
6. Ability to load a binary file into RAM \ ROM and save a RAM dump to a binary file
7. The presence of an extensive element base for input / output of information and debugging circuits (buttons, constants, probes, clock generator ...)

In this and all subsequent posts, when I publish logic circuits, I will use Logisim because I recently switched to Ubuntu, although the whole project is done on Logic Circuit.

#### Action plan

Since practice without theory does not exist, a theoretical basis is needed to create something. Therefore, today in the program we will consider the following theoretical aspects:
• A key element of all digital electronics is the transistor;
• Logical elements, their types;
• Technologies for building electronic circuits or building logic elements on transistors;
• The laws of de Morgan or how to reduce the number of gates;

#### A key element of all digital electronics is the transistor

The basic element for the integrated circuit is a transistor.
For the definition of Wikipedia,
transistor - a radio-electronic component of semiconductor material that allows the input signal to control the current in the electrical circuit.
Transistors consist of logic elements. Triggers, adders, logic blocks, counters are created from logic elements. By combining all this in the right way, you can create your own computer (or EOM).

#### Logical elements, their types

Logical elements - devices designed to process information in digital form.

A logical function of any complexity can be set using the following logical elements:
• The element is NOT (inverter). The output will be “1” if and only if the input is “0”;
• Element And (conjunction). The output will be “1” if and only if all inputs will have “1”;
• Element OR (disjunction). The output will be “1” when at least one input will have “1”;
• The addition element modulo 2 (exclusive OR). The output will be “1” if and only if the input will have an odd amount of “1”;
• Repeater;
• Control repeater. Used to connect multiple outputs to one output.

Logic elements in Logisim:

#### Technologies for building electronic circuits or building logic elements on transistors

The initial idea was to build a computer not on 7400 series chips , but on transistors. And I began to search for technologies for building electronic circuits. There are the following:

Next, I read for each advantage / disadvantage, and among them I chose resistor-transistor logic . The choice was obvious in view of the fact that this logic has constructive simplicity and low cost. And also to this logic there is a huge selection of bipolar SMD transistors and SMD resistors. Transistors I took BC847C npn and BC857C pnp.
Closing my eyes to all the flaws, for a month I plunged into the counting of logic elements on transistors. He made several test circuits on a breadboard using BC547C transistors. I was pleased with the results of the theoretical and practical parts.
Layout:

The last stage remained - designing a synchronous T-flip-flop circuit on 847 transistors, checking its operability and analyzing the frequency characteristics. The performance test is quite simple - a logical “1” is fed to the input “T”, and clock pulses from the generator are fed to the input “C”. At the output, I have to get clock pulses whose frequency is half the input. If everything works at an acceptable frequency, then the whole computer will work.
Designed a circuit that consists of 4 T-flip-flops. I made the printed circuit board a photo-resistive method, soldered it uncomplicatedly and eventually got just such beauty (track width - 0.15 mm):

I connected a 5 volt power source to the circuit, connected a generator to the input and an oscilloscope to the output. I started testing at a frequency of 1 MHz, but the circuit did not work. Then I lowered it to 20 kHz - voila, the circuit worked correctly. Manipulating the supply voltage I was able to increase the operating frequency to 40 kHz ...
Alas, the circuit did not live up to my expectations. In addition, only one T-trigger worked correctly at a frequency of up to 40 kHz, and all the others could not go from high to low, although the internal RS-triggers worked correctly.
I conducted some more experiments on the construction of logic elements, only on field-effect transistors. The results were satisfactory, but some problems appeared:

1. High cost of the project (about \$ 1000 only for transistors);
2. The problem is to get SMD field effect transistors in Ukraine;
3. The problem is to solder 15 - 20 thousand transistors on CMOS logic, instead of 7 - 10 thousand on RTL.

For myself, I made a good conclusion : it is better to buy 7400 series chips with logic elements than to make logic elements on transistors. And for the sake of conscience, when the entire circuit on the microcircuits is ready, you can replace several key microcircuits with transistor circuits and connect in turn both of them to demonstrate that all microcircuits can be replaced with transistors :)

#### De Morgan laws or how to reduce the number of gates

The laws of de Morgan are the rules that bind logical operators (disjunction and conjunction) using logical negation. In formal logic, they can be written as follows:

Consider an example of the use of these rules in action. Suppose we have such a scheme:

Using de Morgan's laws, the scheme can be redone into this:

As you can see from the truth tables, the logic of these schemes is identical.
Now a small postulate : for logic elements (except logical NOT) on CMOS logic with an inverse output (for example, a logical 2I-NOT), two transistors are needed less than for logic elements with a non-inverse output (for example, a logical 2I).
Then, for the first circuit you will need 18 transistors, and for the second - 12 transistors. Moreover, the second circuit will work faster due to the fact that fewer valves are used and the signal will pass an order of magnitude faster.

#### Future plans

In the next post I will talk about triggers and we will begin to design ALU.