2022-11-14

What are Logic Gates?

Logic Gates are important to electronics everywhere! We describe logic gates using 1s and 0s. Where True or On is represented by 1 and False or Off is represented by 0. In programming terminology, this representation, or data type, is called Boolean. Where a value is represented by two choices, True or False.

Types of Basic Logic Gates

There are several basic logic gates used in performing operations in digital systems. The common ones are;

  • OR Gate
  • AND Gate
  • NOT Gate
  • XOR Gate

Additionally, these gates can also be found in a combination of one or two.

OR Gate

In an OR gate, the output of an OR gate attains state 1 if one or more inputs attain state 1.



The Boolean expression of the OR gate is Y = A + B, read as Y equals A ‘OR’ B.

OR Logic Table

The truth table of a two-input OR basic gate is given as;


A B Y
0 0 0
0 1 1
1 0 1
1 1 1

AND Gate

In the AND gate, the output of an AND gate attains state 1 if and only if all the inputs are in state 1.



The Boolean expression of AND gate is Y = A*B

AND Logic Table

The truth table of a two-input AND basic gate is given as;


A B Y
0 0 0
0 1 0
1 0 0
1 1 1

NOT Gate

In a NOT gate, the output of a NOT gate attains state 1 if and only if the input does not attain state 1.



The Boolean expression of NOT gate is Y = \(\bar {A}\) It is read as Y equals NOT A. In Programming we use ! to mean not. So in programming the expression would be Y = !A or ‘Y equals NOT A’

NOT Logic Table

The truth table of NOT gate is as follows;


A Y
0 1
1 0

Combining Gates

We can utilize the combination of the AND,OR and NOT gates to create our own logic tables such as the below.




A B \(\bar {A}\) (NOT A) \(\bar {A}\) + B ((NOT A) or B)
0 0 1 1
0 1 0 1
1 0 0 0
1 1 0 1

Combining Gates - Part 2

Follow along from right to left.It’s just simple arithmetic!


A B A * B A * B + A
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1

Combining Gates - Part 3

Somtimes it’s easier to assign new values. It makes logic easier to follow!

A B A * B = Y Y \(\bar {B}\) \(\bar {A}\) Y + \(\bar {B}\) + \(\bar {A}\)
0 0 0 0 1 1 1
0 1 0 0 1 0 1
1 0 0 0 0 1 1
1 1 1 1 0 0 1




No Matter what value the above logic will ALWAYS return TRUE!

Combining Gates - Practice 1




A B \(\bar {A}\) \(\bar {B}\) A * \(\bar {B}\) \(\bar {A}\) * B (A * \(\bar {B}\)) + (\(\bar {A}\)* B)
0 0 ? ? ? ? ?
0 0 ? ? ? ? ?
0 0 ? ? ? ? ?
0 0 ? ? ? ? ?

Combining Gates - Practice 1 (SOLUTION)

A B \(\bar {A}\) \(\bar {B}\) A * \(\bar {B}\) \(\bar {A}\) * B (A * \(\bar {B}\)) + (\(\bar {A}\)* B)
0 0 1 1 0 0 0
0 1 1 0 0 1 1
1 0 0 1 1 0 1
1 1 0 0 0 0 0

Combining Gates - Practice 2

Remember! In math we calculate anything in parenthesis () first!


A B \(\bar {B}\) (\(\bar {B}\) + B) * A \(\bar {B}\) + (B * A)
0 0 ? ? ?
0 1 ? ? ?
1 0 ? ? ?
1 1 ? ? ?

Combining Gates - Practice 2 (SOLUTION)




A B \(\bar {B}\) (\(\bar {B}\) + B) * A \(\bar {B}\) + (B * A)
0 0 1 0 1
0 1 0 0 0
1 0 1 1 1
1 1 0 1 1

THE END

This presentation was made using HTML,CSS, RMarkdown, IOSLIDES, and Latex. These are all different types of programming languages used by programmers worldwide!