The Wayback Machine - https://web.archive.org/web/20240910103559/https://www.geeksforgeeks.org/implementing-any-circuit-using-nand-gate-only/
Open In App

Implementing Any Circuit Using NAND Gate Only

Last Updated : 23 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

A universal gate is such a gate that we can implement any Boolean function, no matter how complex, using a circuit that consists of only that particular universal gate. The NAND & NOR gates are the most commonly encountered universal gates in digital logic.

In this article, we will take a look at how to convert any circuit into a circuit that consists only of NAND gates. Since the NAND gate is a universal gate, we can convert any circuit into a circuit consisting only of NAND gates. We first start by showing how other gates(AND, OR, Inverter) can be implemented using only NAND gates, then we use this knowledge to discuss how to convert any circuit into only a NAND circuit.

What is NAND Gate?

The NAND gate is a simple form of a Digital Logic gate which gives a False output if all the inputs are True. The device is an inverse of the AND gate. In Boolean algebra the NAND operation is represented as (AB)’. NAND gates are common in digital electronics since it is simple and can be used as a basis of most of the circuits. With gates NAND has one special feature which is that from them it is possible to construct any other function, it really works as a universal gate. This implies that, in principle, an entire digital circuit can be built using only NAND gates and this explains why they are very useful in circuit design.

Truth Table:

A

B

Output

0

0

1

0

1

1

1

0

1

1

1

0

In this table it can be observed that the output is false only when both inputs A and B are true. For the output in all other cases, the value is true.

Objective:

Given a circuit, our task is to implement a circuit that is equivalent to the given circuit and consists of only NAND gates.

Examples:

Example 1:

Given Circuit:

AB+CD

Same Boolean Function with NAND only Circuit

 

Example 2:

Given Circuit:

(A+B)C + DE

Same Boolean Function with NAND only gate circuit:

 

Before we get to how to convert any circuit to a NAND-only circuit, we will take a look at how to implement Complement, AND & OR  operation using NAND gates. We also will need to take a look at how to implement NAND operation using OR gate.  

COMPLEMENT Using NAND

(AA)’ = A’

AND Using NAND

Evaluates to AB

This is quite straightforward, we wish to obtain AB but the NAND gate gives an output (AB)’ so we complement the output of the NAND gate using another NAND gate to obtain ((AB)’)’ which is AB.

OR Using NAND

Evaluates to A+B

We first complement the inputs A and B. Then we perform the NAND operation on these complemented inputs. We get (A’B’)’. 

Using De-Morgan’s law we can show that (A’B’)’ = A + B.

NAND using OR & Inverter

 

To implement NAND operation using OR gate, we first complement the inputs and then perform OR on the complemented inputs.

We get A’ + B’. 

A’ + B’ is equivalent to (AB)’ which can be shown to be true by using De-Morgan’s law.

Procedure for Conversion

Consider the following circuit.

We have:

 

We have to somehow re-implement this circuit using only NAND gates.

Suppose what happens if we insert two inverters between each AND gate and OR gate.

 

This circuit is completely equivalent to the original one as the output of each AND gate is being complemented twice before the signal reaches the OR gate. These inverters will play a key role in the process of conversion.

Now take a look at the highlighted areas.

 

The gates in each highlighted area can be easily combined into one NAND gate since it is basically just an AND gate followed by an inverter.

We get:

 

Now we only have to take care of the blue highlighted area. Recall the implementation of a NAND operation using OR & inverter gates we have covered above, the gates in the blue area implement a NAND operation. Therefore we can just replace all the gates in the blue area with a single NAND gate!

Our Final Result:

 

You can verify for yourself that this circuit implements the function AB + CD, same as that of the original circuit.

Another Example:

Original Circuit:

(A+B + CD)E

Method 1

 

First, we start by replacing the first AND gate(highlighted yellow) with a NAND gate. To do this we insert two inverters after this AND gate.

 

Remember that this circuit is the same as two complement operations resulting in the original signal. The AND gate and the inverter that follows it can be combined into a single NAND gate(see yellow highlighted area).

 

Next, we replace the OR gate in the blue highlighted area with NAND gates. We have seen how to implement OR operation using NAND gates, we put that knowledge to use now.

 

We then proceed to replace the last AND gate(highlighted yellow) with NAND gates. Just like we replaced the OR gate in the previous step, we replace the AND gate with its equivalent NAND gate circuit.

 

We now are left with an OR Gate and an Inverter Gate. A NAND gate can be implemented by an OR gate with complemented inputs. Here we have only one complemented input to the OR gate. To meet the condition that both the inputs are complemented, we insert two inverters between the highlighted OR gate and the preceding NAND gate.

We get:

 

Now both the inputs to the OR gate are complemented. The gates in the blue area represent a NAND operation so we can replace them with a NAND gate.

 

We are now only left with an Inverter. An Inverter gate is basically a one-input NAND gate. We make the necessary replacement and obtain our final circuit.

Our Final NAND gate-only circuit:

 

You can verify that this circuit implements :  (A+B + CD)E

Method 2 (SOP Method):

The original circuit implements the Boolean function : (A+B+CD)E

We first manipulate this Boolean equation so that it is in the Sum of Products(SOP).

In this case, we simply multiply each term in the parenthesis by E.

We get: AE + BE + CDE.

Since this Boolean equation is now in SOP form, the circuit for this equation will be in a standard two-level implementation, meaning there will be a series of AND gates followed by a single OR gate.

We draw the circuit:

 

Just like in example 1, we insert two inverter gates between each AND gate and OR gate.

 

You can probably now figure out what we will do next. We combine the gates in the Yellow areas into one single NAND gate. Also, we know that an OR gate with complemented inputs implements a NAND operation. So we replace the gates in the blue area with a NAND gate.

Our final circuit:

We can conclude that whenever a circuit has a series of AND gates at the first level followed by a single OR gate, we can blindly replace each gate with a NAND gate and the circuit will still implement the same Boolean function.

In this case Method 2, took a lot less effort than Method 1, one might wonder why even bother learning Method 1 when Method 2 seems easier? The answer is that Method 2 requires that the Boolean equation must be represented in Sum of Products form. In this case, it was easy to convert our equation into SOP from, but this is not always the case.

Suppose you have a circuit that implements the Boolean function : (A+B)(C+D)(E+F)(G+H) 

Converting this to SOP form will be complicated, and better with Method 1 in this case.

Advantages

  • It can support any Boolean function.
  • Reduces circuit complexity.
  • It is cost effective because it reduces the variety of gates needed.
  • Has flexibility for using various type of circuits.
  • Aids in the development of standard digital circuit design.

Disadvantages

  • May result into designs that require more circuits and complex ones because several NAND gates are needed for the simplest functions.
  • It may result to higher propagation delays due to more number of gate levels.
  • It might use more power compared to the circuits utilizing fewer types of gates.
  • Needs more chip space because more gates are needed.
  • Design may be slightly less ‘automatic’ and ‘natural’ for some of the logic operations

Applications

  • It is utilized in forming digital circuits.
  • Significant for constructing the microprocessor and the memory unit.
  • Used in error detection and correction techniques.
  • Used in signal processing in Communication and Digital systems.
  • Used in many digital circuits and in every type of logic families.

Conclusion

This article shows the effectiveness of the NAND gate in the field of digital logic design as explained before. This is desirable since by converting circuits to use only NAND gates, it is possible to simplify the designs for circuits, even if some penalties may be incurred in the process like the complexity of the gates. The NAND gate still continues to be significant because it is general-purpose.

Frequently Asked Questions on Implementing Any Circuit Using NAND Gate Only-FAQs

In what way will NAND gates be useful in the Digital Systems?

These NAND gates are capable of being employed in the formation of any digital logic circuit, including, but not limited to, memory and arithmetic units.

What are the reasons for the widespread use of NAND gates in applications of digital circuits?

They are favored because they can carry out any Boolean function and the circuit can be made uncomplicated since only one kind of gate is used.

What sort of practical use can be made of NAND gates in the field of electronics?

NAND gates are applied in memory devices for instance, RAMs and in digital integrated circuits.



Similar Reads

Implementation of AND Gate from NAND Gate
It is worth mentioning that Boolean algebra is a fundamental part of the digital electronics field that uses binary variables and logical operations. Think of it as the mind that makes the computers work effectively. Then, imagine that logic gates (AND, OR, and NOT) could be the necessary helpers in the digital world. These gates are the components
5 min read
Implementation of OR Gate from NAND Gate
Logic gates are an essential component of digital electronics and are used to handle binary data. Because of its universal nature, the NAND gate is particularly significant among these gates. This article explores the use of NAND gates to implement an OR gate, demonstrating the adaptability and usefulness of these fundamental building blocks. In th
4 min read
Difference Between NAND GATE and NOR GATE
NAND and NOR gates are universal logic gates, which means any Boolean expression can be implemented without using any other gate. Using only NOR gates or only NAND gates all other Boolean expressions can be created unlike other gates. In this article, we will discuss the difference between NAND GATE and NOR GATE.  Table of Content What is NAND Gate
4 min read
Implementation of XOR Gate from NAND Gate
Logic Gates are the building blocks of digital circuits, taking binary values as input and returning a binary value as output after performing a logical operation. There are several kinds of gates available in Digital Electronics like basic gates, and universal gates. Implementation of the XOR gate from the NAND gate is possible because the NAND ga
5 min read
NAND Gate
Logic Gates are one of the most important topics in electronics, especially digital electronics. The concept of logic gates relies on the concept of Boolean functions. Logic gates take one or multiple binary values as input and return one binary value as output after doing the logical calculation on them. There are several kinds of GATEs available
7 min read
Implementation of Full Adder using NAND Gates
In Digital Logic Circuit, Full Adder is a Digital Logic Circuit that can add three inputs and give two outputs. The three inputs such as A, B, and input carry as Cin. The output carry is represented as Cout and the normal output is represented as S, Sum. The Cout is also known as the majority 1’s detector, whose output goes high when more than one
9 min read
Half Adder and Half Subtractor using NAND NOR gates
Introduction : A Half Adder is a digital circuit that adds two single-bit binary numbers and outputs the sum and carry. It can be implemented using either NAND gates or with NOR gates. When using NAND gates : The sum output is given by A AND B. The carry output is given by the complement of A AND B. ​ ​W​hen NOR gate is used : The sum output is NOR
5 min read
Differences Between NAND vs NOR Flash Memory
Flash memory is a critical factor in cutting-edge digital devices, serving as the spine for storing data persistently. Among the diverse forms of flash reminiscence, NAND and NOR flash are outstanding variations with awesome characteristics. This article delves into the fundamental variations among NAND and NOR flash memory, elucidating their archi
9 min read
Circuit (Combinational and Sequential) Implementation using Prolog
Prerequisite - Prolog | An Introduction Overview :Digital circuits or digital electronics is a branch of electronics which deals with digital signals to perform the various task to meet various requirement. The input signal applied to these circuits is of digital form, which is represented in 0’s and 1’s binary language format. These circuits are d
4 min read
Difference between combinational and sequential circuit
Combinational circuits are defined as the time independent circuits which do not depends upon previous inputs to generate any output are termed as combinational circuits. Sequential circuits are those which are dependent on clock cycles and depends on present as well as past inputs to generate any output. Combinational Circuit - In this output depe
1 min read
Solving multiplexer circuit
The procedure for solving and finding the output function of the given multiplexer is quite simple. Firstly we will discuss the procedure and then illustrate it with examples. Procedure: Firstly truth table is constructed for the given multiplexer. Select lines in multiplexer are considered as input for the truth table. Output in truth table can be
2 min read
Clock Skew in synchronous digital circuit systems
In Synchronous circuits where all the logic elements share the same clock signal, it becomes imperative to design these elements as close to the clock source as possible because a system-on-chip, FPGA, CPLD contain Billions of transistors. Even though these distances are minute due to their sheer number there is a propagation delay which leads to t
2 min read
What is Circuit-Level Gateway?
A firewall is a device that secures our network by monitoring traffic that can be incoming or outgoing by allowing or blocking it on the basis of security rules. It is also called the first defense device for network security. The main purpose of a firewall is to filter the packets it receives or sends. When a packet is transferred between computer
3 min read
Circuit Elements
A two-terminal electrical device with its voltage-current relationship as its only distinguishing feature is represented mathematically as an idealized circuit element. Although ideal circuit elements are not "off-the-shelf" circuit components, their significance comes from the ability to be coupled to simulate real circuits made up of nonideal ele
7 min read
What is Combinational Circuit ?
Combinational circuits are very well known components in digital electronics which can provide output instantly based on the current input. Unlike sequential circuits, a combinational circuit listens for input signal and and generates output no matter what is the past input or state as it has no feedback or memory component. It only cares about pre
4 min read
Types of Sequential Circuit
A sequential circuit is widely used for storing and processing information such as retaining and manipulating data which makes them an essential component in various electronic devices in the realm of digital electronics. Sequential circuits process data in a sequential manner which makes them essential building blocks of many applications computer
5 min read
How To Find Voltage In A Series Circuit
Voltage in a series circuit is distributed among all the components connected in series. A series circuit is one of the important circuits in electric circuits. To find the voltage in a series circuit we add all the voltages across each component connected in series. In this article, we will discuss how to find the voltage in a series circuit, the
8 min read
How to Solve Parallel Circuit
A parallel circuit is one of the important electric circuits. To solve parallel circuits, we use different formulas accordingly. We can calculate the total current, total resistance, voltage, and current through specific resistors accordingly to solve parallel circuits. The total current in a parallel circuit is the sum of the current in all the br
8 min read
Difference between Circuit switching and Message switching
Data is transmitted through various networks and while doing that, there are several techniques that are used in switching data so that it gets to intended destination. Both methods circuit switching and message switching are distinct. In this article, both these switching techniques will be described, the characteristic features of switching will
5 min read
Implementing 32:1 Multiplexer using 8:1 Multiplexers
A multiplexer is a digital combinational circuit that selects one out of several input lines and directs it to a single output line, hence often alternatively called a data selector. The selection of a particular input line out of several choices takes place on the basis of the selector lines. A multiplexer, in general, has n input lines, log2n sel
3 min read
Difference Between Call Gate, Interrupt Gate, Trap Gate
Gate is used to transfer performance control across all segments. The level of rights assessment is done differently depending on the type of site and the instructions used. Other than that these three gates are almost identical except that Call Gate has parameters for calculating parameters, and that these three gates have different types of field
5 min read
GATE Mock Test Series Free - GATE CS/IT or GATE Data Science and Artificial Intelligence
Are you a GATE aspirant with CS/IT? If yes, you must be occupied by your GATE 2025 Exam preparations. As you know, the GATE 2025 Exam is set to occur in February 2025. You must want to analyze your preparation and performance for the GATE 2025 Exam. Boost your preparation with GeeksforGeeks's FREE GATE CS 2025 - All India Mock or GATE Data Science
5 min read
Implementing Non-contiguous Memory Management Techniques
Memory Management Techniques are basic techniques that are used in managing the memory in operating system. Memory Management Techniques are basically classified into two categories: (i) Contiguous (ii) Non-contiguous We have already discussed the implementation of contiguous in the article Implementation of Contiguous Memory Management Techniques.
3 min read
Implementing DFA for no runs of length less than 4 for input (a,b)
DFA or Deterministic Finite Automata is a finite state machine, in which on every input alphabet a transition is done from one state to another state according to set of defined rules as per the need of string acceptance.In this particular problem, runs of length is the factor to think about.The input alphabets are {a, b}. No runs of length less th
15 min read
GATE | GATE-IT-2004 | Question 56
Consider the undirected graph below: Using Prim's algorithm to construct a minimum spanning tree starting with node A, which one of the following sequences of edges represents a possible order in which the edges would be added to construct the minimum spanning tree? (A) (E, G), (C, F), (F, G), (A, D), (A, B), (A, C) (B) (A, D), (A, B), (A, C), (C,
2 min read
Implementation of XOR Gate from AND, OR and NOT Gate
In this article, we will discuss the implementation of XOR gate using AND, OR and NOT Gate. We will discuss about the AND, OR, XOR and NOT gates, and with it, we will discuss about their operations, logic diagrams and truth table. After understanding the gates and their operation we will use those gates to design a combinational circuit to replicat
5 min read
Implementation of XNOR Gate from AOI Gate
Digital electronics revolve around storing data in bits of 1s and 0s. Not only is digital electronics an efficient way of storing data but it also makes it easier to encrypt and secure our data. It is awesome how we can use different logic gates to implement some functions and represent these equations. In this article, we will see how we can repre
6 min read
Implementation of OR Gate from NOR Gate
The Logic gates are the Fundamental Building Blocks of the Digital Circuits. The Logic Gate takes one or more Binary inputs and performs logical Operations to Produce a single binary Output. Understanding through the Different Combinations of gates is important for the Designer to produce the desired functionality in digital circuits. By Understand
5 min read
200 Days of GATE CS : The Ultimate Study Plan to Ace GATE 2025
Are you preparing to sit for the GATE CS 2025 examination? The Graduate Aptitude Test in Engineering is a very important assessment for a student studying engineering, as it will want to complete a master's qualification or land top-class jobs in Public Sector Undertakings. To crack the GATE CS examination with good scores, one needs to plan a good
15+ min read
Difference Between AND Gate and OR Gate
AND gate and OR gate are basic logic gates. AND gate outputs 1 when all inputs are 1 else output 0. OR gate outputs 1 when at least one input is 1 else output 0. The main difference between AND gate and OR gate is that AND gate represents logical conjunction whereas OR gate represents logical disjunction. In this article we will explore difference
4 min read