Logic Gates

What are Logic Gates?

Digital logic circuits can be broken down into two subcategories- combinational and sequential. Combinational logic changes “instantly”- the output of the circuit responds as soon as the input changes. Sequential circuits have a clock signal, and changes propagate through stages of the circuit on edges of the clock.

To the right is logic in action. Using a 555 timer with internal logic gates and other electronic components, we can create some pretty cool electronic projects!

Common Gates

AND gate 

Output is 1 if BOTH inputs are 1

OR gate

Output is 1 if AT LEAST one input is 1

XOR gate

Output is 1 if ONLY one input is 1

NOR gate

Output is 1 if BOTH inputs are 0

NAND gate

Output is 1 if AT LEAST one input is 0

XNOR gate

Output is 0 if ONLY one input is 1

NOT gate

Output of a NOT gate inverter is a 1 if the input is a 0, and vise versa.

Buffer

Output is the same as input. Space filler. 

Boolean Algebra

Boolean algebra is a mathematical structure and set of operations used in digital logic design and computer science. It was introduced by mathematician and logician George Boole in the mid-19th century. Boolean algebra deals with binary variables and operations, where variables can only take on one of two possible values: true (often represented as 1) or false (represented as 0).

Boolean algebra follows specific rules and laws, such as:

Boolean algebra is fundamental to the design and analysis of digital circuits. It provides a mathematical framework for expressing and manipulating logical expressions, helping engineers and designers to simplify and optimize complex logical circuits. Additionally, Boolean algebra is closely related to binary arithmetic and forms the basis for programming and computer science concepts such as binary code, truth tables, and logic gates.

Logic and Truth Tables

Truth tables are simple plots that explain the output of a circuit in terms of the possible inputs to that circuit. Here are truth tables describing the six main logic gates:

What is Inside a Logic Gate?

Logic gates are made of other electronic components like diodes, resistors, transistors, and MOSFETS, a type of transistor. Most logic gates can be made in more than one way using a combination of different components. Pictured below is an AND gate made three ways:

Build Your Own Logic Gates!

Almost everything a CPU can do can be reduced to some sort of logic equation. In math and theoretical computer science, the most common logic operations are AND, OR, and NOT. From an electrical point of view NOR and NAND gates are far more popular.

In theory, every logic operation can be performed using only NAND gates. In practice, it is more useful to use other gates as well. The following exercises will describe and demonstrate how the different gates can be implemented using transistors for AND, OR, NOT, NOR, and NAND gates.

In these exercises, you will construct the logic gates that you will find inside the ICUs of future projects. You will find that logic gates are made up of a combination of transistors and resistors where ICUs are made up of a combination of logic gates and further resistors. 

You will use the following schematics to create and test your built logic gates.

Exercise 1: AND Gate

Background Knowledge:

What you'll need:

1 - 5V Power Supply

1 - Positive and Negative Alligator Clips

1 - Breadboard

2 - 3904 NPN Transistors

3 - 10K Ohm Resistor

1 - 4 Pin DIP Switch

1 - 5mm Red LED

1 - Jumper Wire Set

What to Expect:

When you complete this circuit the LED will only turn on if you’ve met the correct conditions for the AND Gate. If the LED turns on when only the Input B is closed, slowly lower the resistor value of the 10K Resistor that is in parallel with the LED until it turns off. This should be no lower than 1K minimum.

How it Works:

Questions:

Exercise 2: OR Gate

Background Knowledge:

What you'll need:

1 - 5V Power Supply

1 - Positive and Negative Alligator Clips

1 - Breadboard

2 - 3904 NPN Transistors

3 - 10K Ohm Resistor

1 - 4 Pin DIP Switch

1 - 5mm Red LED

1 - Jumper Wire Set

What to Expect:

When you complete this circuit the LED will only turn on if you’ve met the correct conditions for the OR Gate.

How it Works:

Questions:

Exercise 3: NOT Gate

Background Knowledge:

What you'll need:

1 - 5V Power Supply

1 - Positive and Negative Alligator Clips

1 - Breadboard

1 - 3904 NPN Transistors

1 - 470 Ohm Resistor

1 - 10K Ohm Resistor

1 - 4 Pin DIP Switch

1 - 5mm Red LED

1 - Jumper Wire Set

What to Expect:

When you complete this circuit the LED will only turn on if you’ve met the correct conditions for the NOT Gate.

How it Works:

Questions:

Exercise 4: NAND Gate

Background Knowledge:

What you'll need:

1 - 5V Power Supply

1 - Positive and Negative Alligator Clips

1 - Breadboard

2 - 3904 NPN Transistors

1 - 470 Ohm Resistor

2 - 10K Ohm Resistor

1 - 4 Pin DIP Switch

1 - 5mm Red LED

1 - Jumper Wire Set

What to Expect:

When you complete this circuit the LED will only turn on if you’ve met the correct conditions for the NAND Gate.

How it Works:

Questions:

Exercise 5: NOR Gate:

Background Knowledge:

What you'll need:

1 - 5V Power Supply

1 - Positive and Negative Alligator Clips

1 - Breadboard

2 - 3904 NPN Transistors

1 - 470 Ohm Resistor

2 - 10K Ohm Resistor

1 - 4 Pin DIP Switch

1 - 5mm Red LED

1 - Jumper Wire Set

What to Expect:

When you complete this circuit the LED will only turn on if you’ve met the correct conditions for the NOR Gate.

How it Works:

Questions:

Check out our Electronics Projects page for fun projects with Integrated Circuits that use Logic!