In previous tutorials VHDL tutorial (#6), we built a circuit for D Morgan’s Theorems in VHDL and verified its output to prove D Morgan’s theorems.

*(If you are not following this VHDL tutorial series one by one, you are requested to go through all previous tutorials of these series before going ahead in this tutorial)*

In this tutorial,

- We shall write a VHDL program to build all other gates (AND, OR, NOT, XOR, NOR, etc.) using only NAND gates
- Verify the output waveform of the program (digital circuit) with the truth table of AND, OR, NOT, XOR, NOR gates

__Digital Circuit__

Now we shall write a VHDL program, compile it, simulate it, and get the output in the form of a waveform. Finely, we shall verify those output waveforms with a given truth table.

*(Please go through step by step procedure given in VHDL-tutorial 3 to create a project, edit and compile the program, create waveform file, simulate the program, and generate output waveforms.)*

__VHDL Program:__

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

entity nand_uni_gate is

Port ( a,b : in std_logic;

y_not,y_and, y_or,, y_xor: out std_logic

);

end nand_uni_gate;

architecture nand_uni_gate_arch of nand_uni_gate is

begin

y_not <= a nand a;

y_and <= (a nand b) nand (a nand b);

y_or <= (a nand a) nand (b nand b);

y_nor <=((a nand a) nand (b nand b)) nand ((a nand a) nand (b nand b));

y_xor <= (a nand (a nand b)) nand (b nand (a nand b));

end nand_uni_gate_arch;

“*entity*” describes input-output connections of a digital circuit. As per our circuit given above, we have only two inputs ‘A’ and ‘B’ and five outputs for five circuits of different gates build using the NAND gate only.

“*architecture*” describes the operation of the circuit – means how the output is generated from a given input.

*(To know more and get more details about VHDL program(s), please go through the first two tutorials VHDL tutorial 1 and VHDL tutorial 2 of these series.)*

Next, compile above program – create waveform file with all inputs and outputs listed – simulate the project and you will get the following result

__Simulation Waveform__

From these output waveforms, we can easily say that the output of different gate circuits built using only NAND gates is the same as the output of a particular gate.

That means we can design all other gates using only the NAND gate, so the NAND gate is a universal gate.

In the next tutorial, we shall prove the NOR gate as a universal gate by designing AND, OR, NOT, NAND, and XNOR gates using only NOR gate.

Filed Under: Tutorials, VHDL