Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

VHDL Tutorial – 5: Design, simulate and verify NAND, NOR, XOR and XNOR gates using AND-OR-NOT gates in VHDL

February 14, 2021 By Ashutosh Bhatt

In the previous VHDL tutorial 4, we designed and simulated all seven logic gates (AND, OR, NOT, NAND, NOR, XOR, and XNOR) in VHDL.

(If you are not following this VHDL tutorial series one by one, please 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 NAND, NOR, XOR, and XNOR gates using AND-OR-NOT gates.
  • Simulate the program to design a digital circuit of NAND, NOR, XOR, XNOR gates that is build using AND-OR-NOT gates
  • Verify the output waveform of the program (digital circuit) with the truth table of these logic GATES

Let us start with the digital circuit for which we shall write a VHDL program.

Digital Circuit

The truth table for all the above circuits:
NAND gate using AND-OR-NOT gate circuit Truth Table
NOR gate using AND-OR-NOT gate circuit Truth Table
 XOR gate using AND-OR-NOT gate circuit Truth Table
XNOR gate using AND-OR-NOT gate circuit Truth Table
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 the 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 gate_ckt is
     Port (a,b : in std_logic;
                y_nand,y_nor,y_not,y_xor,y_xnor : out std_logic
               );
end gate_ckt;
architecture gate_ckt_arch of gate_ckt is
       begin
          y_nand <= not (a and b);
          y_nor <= not (a or b);
          y_xor <= (a and not(b)) or (not(a) and b);
          y_xnor <= (a and b) or (not(a) and not(b));
end gate_ckt_arch;

“entity” describes input-output connections of the digital circuit. As per our circuit given above, we have only two inputs ‘A’ and ‘B’ and four outputs for four gates.

“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 first two tutorials – VHDL tutorial one and VHDL tutorial 2 – of these series)

Next, compile above program – create a waveform file with all inputs and outputs listed – simulate the project, and you will get the following result:
Simulation Waveform
Now verify these output waveforms with the truth table of GATEs. For example, here is one case that is highlighted with inputs A=1 and B=0. You can verify the other three cases also.

This is how you can build NAND, NOR, XOR, and XNOR gates using AND-OR-NOT gate in VHDL and verify its output with their truth table.

In the next tutorial, we shall prove D’Morgan’s Theorems by designing their digital circuits using VHDL programming

Related Articles Read More >

VHDL
VHDL Tutorial 1: Introduction to VHDL
VHDL
VHDL Tutorial 2: VHDL programs
VHDL Tutorial – 22: Designing a 1-bit & an 8-bit comparator by using VHDL
VHDL Tutorial – 21: Designing an 8-bit, full-adder circuit using VHDL

Featured Tutorials

  • Gate Level Implementation – DE Part 8
  • Introduction to VHDL & Verilog – DE Part 9
  • Arithmetic Circuits – DE Part 10
  • Logic Gate Implementation of Arithmetic Circuits – DE Part 11
  • Building Code Convertors Using SN-7400 Series ICs – DE Part 12
  • Interfacing stepper motor with 8051(89c51,89c52 ) microcontroller

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • Arduino-based automatic car windows for protection from dust and pollution
  • A groundbreaking alternative to DRAM
  • What are the different types of temperature sensors and their applications?
  • Analog Devices and Stripe launching advanced computer science program
  • NXP expands its EdgeVerse portfolio with crossover application processors
...

RSS EDABOARD.com Discussions

  • Understanding of RHCP or LHCP
  • Impedance Maching
  • What is the safe distance for RF antenna under 220KV high voltage equipment?
  • Will this RF power transistor work for RF power amp at 2.4 GHz?
  • Nport instance connection in cadence

RSS Electro-Tech-Online.com Discussions

  • Momentary push button DPDT switch with alternate action
  • Step-down switching regulator with 1MHz PWM. Schematic question.
  • HOW to buy online solar motion detector LED Lights with NO Lumens ratings?
  • Ideas for a power supply?
  • ST7066U 20x4 LCD problems
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering