Search
  • Riya Manchanda

Integrated Circuits: Making a 4-Bit Calculator (Part 1)



Have you ever wondered how a tiny microchip is capable of running your entire computer? I assure you, it's no magic. Just simple good-ol' science. We combine thousands or even millions of transistors and wires to create something called 'Integrated Circuits', which perform all the operations in a microchips. I am now starting a series of blog posts where. we explore how a simple Integrated Circuit for a four-bit calculator can be designed. Our calculator will perform addition, positive subtraction, and multiplication. We will explore integer subtraction and division in another tutorial.


Table of Contents for this post:

  1. What are Integrated Circuits?

  2. What are Logic Gates and how are they made?

  3. How do transistors and capacitors make Logic Gates?


DISCLAIMER: The circuit images shown are subject to copyright.



What are Integrated Circuits?


Integrated Circuits are micro-circuits or assemblies of electronic components such as transistors, diodes, capacitors and resistors, which are embedded into a flat singular unit, usually a semiconductor like silicon. The set up is then made into chips and microchips. Before we move on to developing a circuit, it is essential to learn about some basic components comprising a microchip.


One of the most basic electrical components are resistors. Resistors are essentially just pieces of a particular material with high natural resistivity. As the name suggests, they offer resistance in a circuit to reduce the electrical energy flowing through it by converting and emitting it as thermal energy. It is measured in ohms, and the relationship between Resistance, Current and Voltage in a circuit can be given be the Ohm's law: R = V/I. The representation of a resistor in a circuit is this:



Next, we have the capacitor which is the basic building block used in computer storage and memory. As you may have guessed, they store electrical energy that they obtain from their power source, such that this energy can be used later. The principle behind the capacitor is that it contains of two conducting plates with an insulating material in between. When this component is connected to a battery, the side of the capacitor connected to the positive terminal gains holes or loses electrons, while the other side gains a surplus of electrons. This charges the capacitor similar to a battery. The circuit symbol for a capacitor is:



The most important component in an integrated circuit is a transistor. A transistor acts like a switch/gate , or an amplifier between two distinct points in a circuit. It usually has three pins, a collector, an emitter and a base. The concept behind simple junctions transistors is that the collector and the emitter are n-type, which means they have a surplus of electrons. Whereas, the base in the middle is p-type which means it has a surplus of 'holes' (absence of electrons), which prevents the flow of electrons from emitter to collector. Once the base is supplied with a small current, allows the large flow from emitter to collector, thus acting both like a switch and an amplifier simultaneously. When the current is flowing the transistor is said to be in the 'on' state or 1, while at other times it is known to be in the 'off' state or 0. This is how you represent a transistor in a circuit:



Moving on, another important electronic component worth learning about is a diode. A diode is component which controls the direction of the flow of current in a circuit. It acts as a one-way switch and basically stops the current from flowing in the opposite direction. A diode undergoes a process called doping, which alters its electrochemical properties making it suitable for its purpose. A simple polar diode also consists of three regions: an anode which is of p-type and has holes, a cathode which is of n-type and has excess electrons, and a depletion zone which is the junction where transfer of electrons takes place. The depletion region's electric field prevents the current from flowing in the opposite direction. The circuit symbol for a diode is:



Now that we know this, we can move on to understanding how these components are combined to bring the decision-making and arithmetic abilities of a computer to life using something called Logic Gates.



What are Logic Gates?


Logic Gates are simple blocks of circuits which receive an input, perform a boolean logical operation on it, and return one singular binary output. These circuits are made possible through connections between different electrical components arranged in different orientations to implement a variety of logic. Most commonly, logic gates receive upto two inputs and return an output. The different types of logic gates are below:


AND Logic Gate


If you have experience with computation and programming, you know that the AND operator takes two inputs, and returns true as the output if and only if both the inputs are true. Otherwise, it returns false. That is exactly what the AND Logic Gate does, where 0 is false (no flow of current) and 1 is true (current flows). The truth table for this gate is below:



This Logic Gate is represented by this symbol in a circuit:


OR Logic Gate


As the name suggests, this logic gate also takes two inputs, and returns true/1 when either one of them is true. If both of them are false, then it returns false/0. The truth table is:



This Logic Gate is represented by this symbol in a circuit:


NOT Logic Gate


The NOT Logic Gate is the only logic gate that takes a singular input. It is relatively simpler and its function is to merely convert the input into a different binary state (or to flip the input) and return it as the output. The truth table for it is below:



This Logic Gate is represented by this symbol in a circuit:




XOR Logic Gate


The XOR Logic Gate, also known as exclusive or, is a variation of the OR gate, and it also takes two distinct inputs. This gate returns true if and only if one of the inputs is true/1. If both of the inputs are true, or both of the inputs are false, then this gate will return false/0. The truth table for this gate is below:



This Logic Gate is represented by this symbol in a circuit:


NOR Logic Gate


The NOR Logic Gate is another variation of the OR gate, taking two distinct inputs. This gate returns true if and only if neither of the inputs are true. In simple words, this gate will return true/1 only if both the inputs are false/0. Otherwise, it will naturally return false. The truth table for the gate is below:



This Logic Gate is represented by this symbol in a circuit:


NAND Logic Gate


The NAND Logic Gate is a simple variation of the AND gate, and also takes two inputs. This gate will return false only if both the inputs are true. At all other times, it will return true. So, essentially it does the exact opposite of the AND gate. The truth table is below:



This Logic Gate is represented by this symbol in a circuit:


XNOR Logic Gate


The last and probably the fanciest logic gate is XNOR - a variation of the XOR gate, which returns true only if both the inputs are true or both the inputs are false. If the two inputs are different from each other, then this gate will return false. The truth table is below:



This Logic Gate is represented by this symbol in a circuit:



Great, that was the theoretical part of it. What we now might want to do is understand how these logic gates are made using transistors and resistors. It is not critical to understand this in order to produce a design for a calculator so you can skip ahead, however if you're curious about how stuff works, read through the next section as well!



How do Transistors make Logic Gates?


We will now understand how these logic gates are made using simple electronic components. To understand the following, you will need to have a basic idea about reading and comprehending electrical circuits. If you do, then let us consider each gate one-by-one:


AND

The AND gate practically uses three resistors and two transistors to work. As you can see in the circuit diagram, what basically happens is that the output wire receives current if and only both the transistors in between are in the 1 state, since only then will current flow from the Vcc to the ground. Naturally, for both the transistors to be in the 'on' state, both A and B have to be in the 1 (only then will the current be supplied to the base of the transistors, and allow it to flow from collector to emitter). The main purpose of the resistors is to control the flow of the current, and to prevent dangerous short circuit which could occur due to absence of any other forms of resistance (output appliance) in the circuit.



OR

This gate uses three resistors and two transistors as well. As you can see in this circuit, both the transistors are connected in parallel to the Vcc (power) and the ground. In layman terms, unlike the previous circuit in which both transistors were placed in a singular route between the power and the ground, this circuit has two different paths for current to travel with one transistor each. As a result, if even one of the transistors is in the 1/on state, the circuit will be complete and current will be able to flow from Vcc to ground, also flowing into the output wire placed in between. So if even one of the inputs are true (current flows), then the condition for this gate will be met. Consistent with the truth table seen above, the only time this circuit will result in no current flowing through the output wire, is when both of the inputs or transistors are 0.


NOT

This circuit is relatively simple. In this case, when the input A is 0, there is no direct path between the Vcc (power) to the ground, since the transistor will be in the off state. Thus, the current from the Vcc will automatically choose the alternate path and exit through the output wire. On the other hand, when the input A is 1 or if the current is flowing, then the transistor is in the 'on' state. This allows the voltage across the resistor to drop and the current from the Vcc travels to the ground through the transistor, instead of flowing into the output wire. Thus, in this way the NOT gate, also known as the Inverter, flips the input that it receives.

XOR

The construction of the XOR gate is slightly more complex. As you can see, we use two AND gates, 2 NOT gates and 1 OR gate in order to make the XOR gate. I will not be displaying a detailed circuit diagram here, since the circuits for the gates above are simply combined to make this gate. This is how it works, first take input A and the inverse or opposite of input B, and check if both of them are 1. Next, we take the inverse/opposite of input A, and input B, checking if both of them are 1. Then we pass this through an OR gate, which returns true if even either of the ANDs return true. This way the gate will only return true if only one of the inputs is 1 (because of the NOT gates).


NOR

The NOR gate works similar to OR. In this, by default when both the transistors are in the 'off' state, there is path for the current to travel form the Vcc to the ground and thus it flows into the output wire. However, if even one of the transistors are in the 'on' state, The current from Vcc can now travel to the ground as the voltage drops. These transistors are connected in parallel, so the current can take either path. Thus, if even one of the inputs is true (even one transistor is on), the current will flow into the ground instead of the output wire.


NAND

This gate works on the same principle as the above, only with the difference that in this case we have the transistors connected in series instead of parallel, since we only want the current to not flow (return false) if both the conditions are true. Thus, naturally the current will from the Vcc power to the output wire, since there is no way for it get grounded as the transistors are in their 'off' state. Even if one of the transistors are on, the other one will still stop the current from reaching ground. However, if both the transistors are on, then the current will flow from the Vcc to ground and not into the output wire, thus making the output as false. In all the other cases, the output will remain true.


XNOR

The XNOR gate, being a variation of the XOR gate, also comprises multiple other gates. It contains two AND gates, two NOT gates. According to the truth table, we want this circuit to return true if the input is 11 or 00. The way it works, is that first we take input A and input B and check whether they are both true (11) using an AND gate. Next, we invert input A and B, and check if they are both true now (which would be the case for 00). If either of these conditions are met (which we check for using an OR gate), then the output will be true, else it will be false.


And that's it! This is the very basic working principle behind logic gate circuits, and with this knowledge we are now ready to design our own IC for a 4-bit calculator.



 


Conclusion:

Wow, great job. We are now equipped with the fundamental knowledge we need to design 4-bit calculator. With this, we can now move on to exploring how these electrical components are actually used in arithmetic circuits. This is the first part of a series of blog posts that I am doing about 'Integrated Circuits: Making a 4-bit Calculator'. So, watch out for my next posts and make sure to enjoy what you're learning. I would like to extend my heartfelt gratitude to everyone who stuck around and if you found this post useful, please do not forget to like and comment. Before I sign off, I would like to remind you to keep exploring and experimenting!


Until Next Time ~

367 views0 comments

Recent Posts

See All