How to Convert a Logic Diagram to Its NAND-Only Equivalent?

Last Modified:

How to Convert a Logic Diagram to Its NAND Equivalent?

The steps for converting a given function into its NAND-based equivalent circuit are outlined here.

  1. Bubble Placement: This step sets up the circuit for dual transformation using De Morgan’s Law.
    • Append a bubble (NOT gate) to:
      • The output of every AND gate
      • The input of every OR gate
  2. Bubble Balancing: This ensures that the logic function remains unchanged despite the transformation.
    • For every wire in the circuit (input to gate, gate to gate, gate to output):
      • Check if zero or two bubbles exist on that wire
        • If yes, they are neutral or cancel out, so, no action needed.
        • If no, insert an extra bubble to restore logical equivalence.
  3. Gate Replacement:
    • Replace gates as follows:
      • AND gate + bubble on outputNAND gate
      • OR gate + bubbles on inputsNAND gate
      • Standalone bubbles (NOT gates)NAND gates with tied inputs
    • Optional Step: This produces a much neater outcome
      • If a bubble was added between an input literal and the first gate, you can:
        • Complement the literal (e.g., use \(\mathsf{\overline{A}}\) instead of \(\mathsf{A}\)) to skip adding a separate NOT gate

If the original function is provided in Boolean form, or as a truth table, or in a schematic which includes NOR, XOR, or XNOR gates, it should first be translated into its AND-OR equivalent circuit. Once that standard form is established, the following steps can be applied to systematically transform it into a NAND-only implementation.

In this section, we’ll explore how to transform any given logical function into its NAND gate equivalent form. For converting a schematic into a NOR-based version, refer to its dedicated page. You can also click through to see how each basic gate is implemented using NAND and NOR gates. For broader strategies and examples, visit the page titled How to Convert to Equivalent NAND/NOR Schematics? to discover more options and techniques.

Why Use This Approach?

While replacing each gate with its NAND equivalent is a valid approach to convert a schematic, it can sometimes introduce unnecessary gates into the final circuit. These redundancies can often be avoided by applying the structured bubble-pushing method outlined above.

Best-Use Case

This method is most effective when the original schematic is given in standard Sum of Products (SOP) form, as it naturally avoids introducing extra bubbles during conversion. That said, any circuit—regardless of its initial structure—can still be transformed into its NAND equivalent by following these steps.

Comparison with Converting to NOR Equivalent Circuit

In comparison, the key distinction in the NOR equivalence steps is that a bubble is added to the output of each OR gate and to the input of each AND gate. Beyond this adjustment, the overall procedure remains the same. See the solution with this approach and the final conclusion.

Example

To convert a logic diagram into its NAND equivalent form, we start by analyzing a circuit arranged in a non-standard configuration—neither in canonical Sum of Products nor in Product of Sums form. The circuit includes five inputs: \(\mathsf{A, B, C, D}\), and \(\mathsf{E}\). First, inputs \(\mathsf{A}\) and \(\mathsf{\overline{B}}\) are fed into an AND gate, which we’ll refer to as \(\mathsf{g_1}\), producing one intermediate output. Meanwhile, inputs \(\mathsf{\overline{C}}\) and \(\mathsf{D}\) enter an OR gate, labeled \(\mathsf{g_2}\), generating a second intermediate output. Next, the outputs of \(\mathsf{g_1}\) and \(\mathsf{g_2}\) become the inputs to another OR gate, named \(\mathsf{g_3}\). Then, the output of \(\mathsf{g_3}\) is combined with input \(\mathsf{E}\) at the inputs of a second AND gate, called \(\mathsf{g_4}\). Finally, \(\mathsf{g_4}\) produces the circuit’s output signal, denoted as \(\mathsf{Z}\). With this structure defined, we can now proceed to systematically replace each gate with its NAND-based equivalent, ensuring the entire circuit is expressed using only NAND gates.

the image shows a base circuit to be covnerted to its nand and nor equivalent forms

Step 1

To enhance clarity and streamline the NAND conversion, a NOT gate—represented as a blue bubble—has been added:

  • At the output of each AND gate, namely \(\mathsf{g_1}\) and \(\mathsf{g_4}\).
  • At the input of each OR gate, namely \(\mathsf{g_2}\) and \(\mathsf{g_3}\).
the image shows the step 1 of converting a circuit to its nand equivalent form

Step 2

All wires have been checked for logic neutrality, and pink bubbles have been added where needed to cancel lone inversions.

  • No bubble added to wires connecting \(\mathsf{A}\) and \(\mathsf{\overline{B}}\) to the inputs of \(\mathsf{g_1}\).
  • Bubble added to each wire connecting \(\mathsf{\overline{C}}\) and \(\mathsf{D}\) to the inputs of \(\mathsf{g_2}\).
  • No bubble added to the wire connecting \(\mathsf{E}\) to the input of \(\mathsf{g_4}\).
  • No bubble added to the wire connecting output of \(\mathsf{g_1}\) to input of \(\mathsf{g_3}\) (two bubbles cancel out).
  • Bubble added to the output of \(\mathsf{g_2}\) to balance the one at \(\mathsf{g_3}\)’s input.
  • No bubble added to the wire connecting output of \(\mathsf{g_3}\) to input of \(\mathsf{g_4}\).
  • Bubble added to the wire connecting output of \(\mathsf{g_4}\) to output \(\mathsf{Z}\) to restore neutrality.
the image shows the step 2 of converting a circuit to its nand equivalent form

Step 3

All gates have been successfully replaced with their NAND equivalents. However, the additional bubbles introduced for logic balancing—shown in pink—remain in the circuit to preserve functional correctness. These bubbles represent necessary inversions that could not be canceled out and are implemented using NAND gates configured as NOT gates.

the image shows the initial step 3 of converting a circuit to its nand equivalent form

The bubbles originally connected to the input signals have been omitted, and the corresponding input literals have been inverted to reflect their effect (shown in pink). All remaining bubbles have been replaced with NAND-based inverters, ensuring the final circuit maintains logical equivalence using only NAND gates. The final circuit in NAND form is shown here.

the image shows the final step of converting a circuit to its nand equivalent form

Alternative Solution

Here we observe an alternative solution that bypasses the bubble-pushing method and instead directly replaces each gate with its NAND equivalent, as previously discussed.

this image shows the alternative solution to transforming a given circuit to its nand equivalent form by just replacing the gate equivalents

Conclusion

At first glance, the resulting circuit may appear different, but upon closer inspection, both implementations are logically equivalent. This equivalence becomes clear when we analyze the role of the bubbles. While looking at the alternative solution:

  • \(\mathsf{g_5}\) functions as a NOT gate and is effectively canceled out by the bubble at the input of \(\mathsf{g_3}\).
  • The bubble at the second input of \(\mathsf{g_3}\) in the bubble-push solution corresponds to \(\mathsf{g_5}\) in the final solution using the bubble-push method.
  • The bubbles at the inputs of \(\mathsf{g_2}\) are omitted in the bubble-push solution because the inputs themselves are inverted
  • \(\mathsf{g_6}\) is identical in both implementations

Ultimately, both methods yield the same logical behavior. However, the bubble-push approach tends to produce a cleaner schematic by eliminating bubbles at the inputs of NAND gates, resulting in a more streamlined and visually intuitive design.

Example 1: Convert the function \(\mathsf{Z=A\left(CD+B\right)+B\overline{C}}\)

Original Circuit:

Step 1: Bubble Placement

Step 2: Bubble Balancing

Step 3: Gate Replacement

Example 2: Convert the function \(\mathsf{Z=A\overline{D}+B\overline{D}+C\overline{D}}\)

Approach 1: Canonical Sum of Products Form, \(\mathsf{Z=A\overline{D}+B\overline{D}+C\overline{D}}\)
Original Circuit:

Step 1: Bubble Placement

Step 2: Bubble Balancing: All placed bubbles are balanced as they cancel each other out.

Step 3: Gate Replacement

Approach 2: Non-Standard Form, \(\mathsf{Z=\overline{D}\left(A+B+C\right)}\)
Original Circuit:

Step 1: Bubble Placement

Step 2: Bubble Balancing

Step 3: Gate Replacement

How to Convert a Logic Diagram to Its NAND-Only Equivalent