Fundamentals

Make it Logical

The Basics of Digital Logic

Elmo V.Jansz

Issue 55, February 2022

We describe the most common digital logic gates and how they work.

Digital Logic is based on an Electronic Circuit called a Logic Gate. Its function is described by Logic Symbols, Boolean Equations and Truth Tables. The following image shows the block diagram of a general logic gate.

This is a two input gate with output Z and inputs A and B. The state of the output depends on the states of the inputs A and B. The Truth Table is also shown.

The output will depend on the type of circuit used. There are 5 basic types of logic gates:

  1. AND Gate
  2. OR Gate
  3. NOT Gate
  4. NAND Gate
  5. NOR Gate

Each of these circuits can be constructed using different types of digital circuitry.

  1. RTL (Resistor-Transistor Logic)
  2. DTL (Diode-Transistor Logic)
  3. TTL (Transistor-Transistor Logic)
  4. CMOS (Complementary Metal Oxide Semiconductor Logic)

In this article, we shall confine ourselves to TTL which is the easiest to use, handle and the most versatile.

TTL requires a power rail of approximately 5Volts and logic levels of 0 to 0.8V for a Low or ‘0’ and from 2V to 5V for a High or ‘1’.

The shaded area from 0.8V to 2V is not used.

We will now discuss the operation of these gates individually.

AND Gate

The Logic Symbol for the AND gate, its truth table and Boolean Equation are shown here.

Boolean Algebra was developed in the mid-1800s. It was first used to simplify complex switching circuits. However, it was around 1938 that it was used in digital circuitry. Boolean equations have three elements namely input variables, output variables and an operator (the.) shown with the AND circuit above.

A good analogy for an AND gate is a light bulb with two switches in series.

The lamp is on only when both switches are closed. Compare this with the AND Gate truth table. The Boolean Equation for the AND gate is read as Z equals A AND B. ››

OR Gate

›› The logic symbol for an OR gate, its Boolean Equation and truth table are shown here.

The Boolean Equation is read as Z equals A OR B.

The OR gate can be understood by using the circuit with the two switches again but now with the switches in parallel.

The lamp can be turned on by closing switch A or switch B or both.

Inverter NOT

The next simplest circuit is the NOT or Inverter. Unlike the AND and OR gates the NOT does not make decisions but converts a 0 at its input to a 1 at its output and conversely a 1 at its input into a 0 at its output.

The inverter can be represented by either of the symbols shown in above.

The logic equation reads Z equals not A

NAND Gate

The NAND gate is an AND Gate with an inverter on its output. The truth table and logic equation are shown here.

Observe that the output is the opposite of the AND for the same input conditions. This is represented by the bar over the A.B

NOR Gate

This is the same as the OR gate with the output inverted. Its truth table, logic symbol and logic equation are shown here.

EX-OR Gate

Finally, we have one more gate that is worth mentioning. This is the Exclusive OR. Its truth table, logic symbol and Boolean Equation are shown here.

A shorthand form of the Boolean equation is the + sign with a circle around it. The Exclusive OR gate gives a high only when its inputs are different. This feature makes it very useful in practice.

EX-OR vs XOR

While XOR may be the more common term, EX-OR is another term used in some parts of the world and in some industries and teaching systems more than XOR. People will use whatever is more familiar and logical (no pun intended) to them and both terms are valid and accepted. 'X' in some other systems means 'crossover' or 'hybrid/combination'.

Hands On: AND Gate Circuit

With the theory out of the way, we can now set up a circuit to test and understand how these gates function in practice. The schematic and wiring diagram shown here shows a circuit set up for testing an AND gate. The photo shows the actual setup.

Note: The LED has a flat on one side. This is the negative side.

Parts Required:JaycarAltronicsPakronics
1 x Solderless BreadboardPB8820P1002DF-FIT0096
1 x Packet Breadboard Wire LinksPB8850P1014ASS110990044
2 x 10K Resistors* (5K or higher also suitable)RR2798R7249SS110990043
1 x 470Ω Resistor* (330Ω also suitable)RR0540R7550SS110990043
1 x 7408 ICZS5008--
1 x LED*ZD0150Z0800ADA299
2 x SPST Slide Switches (or equivalent) #SS0834S2071-
OPTIONAL:---
1 x 5V Power Supply^MP3144M8903A-
1 x Breadboard Power SupplyXC4606Z6355SS106990021

Parts Required:

* Quantity required, may only be sold in packs. #Slide switches may not be breadboard compatible.

Set up the circuit and verify its truth table as previously described. The LED should be on for a high and off for a low. Note very carefully that one side of the power supply is grounded through the mains. This is to provide 0 volts.

The pull up resistors pull the inputs up towards 5 Volts (High) and ensure a steady input when the switches are open. When the switches are closed the inputs go to 0 Volts. (Low).

In this manner, we can check out the other gates as well using the following ICs.

NOT 7404
OR 7432
NAND 7400
NOR 7402
EX-OR 7486

All these IC packages have several gates on them and we can use whichever we require. All IC packages are shown at the end of this article.

Hands On: OR and AND Gate Circuit

Additional Parts Required:JaycarAltronicsPakronics
1 x 10K Resistor* (5K or higher also suitable)RR2798R7249SS110990043
1 x 7432 IC (or equivalent)ZS5032Z8032-
1 x SPST Slide Switches (or equivalent) #SS0834S2071#-

Additional Parts Required:

* Quantity required, may only be sold in packs. #Slide switches may not be breadboard compatible.

Now that we are familiar with the basics of digital logic, we can generate a given logic function by interconnecting two gates. Suppose we require to generate the following logic function and check out its truth table.

Z = (A + B)•C

The logic gates, truth table and Boolean Equation are shown here.

There are now three inputs and this requires eight combinations to define all possible states.

Set up the circuit and check out its operation by means of its truth table. Note that a logic high at C and a logic high at A or B will result in a high at the output Z.

Where to from here?

We hope we have provided you with a solid understanding of logic gates. If you want to dive deeper into how Logic Gates work, and how to build a Logic Probe, you can read our Classroom articles in Issues 19 through to 22, written by Bob Harper.

We have also included pinout for some of the common logic gate ICs here for your reference.