Logic-Gates-using-LTspice

Logic Gates using LTspice

This repository explains the implementation of Logic Gates in CMOS Logic using LTspice Simulator. This shows the schematics of Logic Gates and plot the output waveform to verify the functionality.

Table of Contents

Introduction

Logic Gate: A logic gate is a device that performs logical operations on one or more binary inputs and produces a single binary output. The primary way of building logic gates uses diodes or transistors acting as electronic switches. Today, most logic gates are made from MOSFETs (metal–oxide–semiconductor field-effect transistors). Logic circuits include such devices as multiplexers, registers, arithmetic logic units (ALUs), computer memory and microprocessors which may contain more than 100 million logic gates.

Logic Gates - Basic Gates and Universal Gates

Basic Gates: Basic gates, also known as elementary or fundamental gates, include the AND, OR and NOT gates. These gates operates on binary signals (0s and 1s) and provide the basis for all digit computations. Other gates such as XOR, XNOR, NAND and NOR can be derived from basic gates.

Universal Gates: A universal gate is a digital logic gate that can be used to implement any Boolean function without requiring other gates. NAND and NOR Gates are universal gates.

CMOS: Complementary metal–oxide–semiconductor (CMOS) is a type of MOSFET that uses complementary and symmetrical pairs of p-type and n-type MOSFETs for logic functions. Input is applied at the common gate of PMOS and NMOS transistors.Output is taken from the PMOS and NMOS drain. CMOS technology is used for constructing integrated circuit (IC) chips, including microprocessors, microcontrollers, memory chips and other digital logic circuits. Two important characteristics of CMOS devices are high noise immunity and low static power consumption.

PMOS: The PMOS transistor is a p-channel device. It conducts current when a negative voltage (logic low) is applied to its gate terminal with respect to the source terminal. In CMOS, PMOS acts as pull up network in which the source is connected to VDD. When logic low(0) is applied is CMOS, the PMOS transistor turns on and connects the VDD to output which makes the output to logic high(1).

NMOS: The NMOS transistor is an n-channel device. It conducts current when a positive voltage (logic high) is applied to its gate terminal with respect to the source terminal. In CMOS, MMOS acts as pull down network in which the source is connected to ground. When logic high(1) is applied is CMOS, the NMOS transistor turns on and connects the output to ground which makes the output to logic low(0).

Objectives

The main goal of this project are given below

  1. To plot the schematics of logic gates, and circuits
  2. To plot the output waveform
  3. To verify the functionality

Project Structure

LTspice Simulation Files: Files with .asc extension represents LTspice simulation files for each logic gate.

Circuit Details

  1. The output of AND gate produces 1 if and only if all the input states are 1 else it produces 0. The logic symbol and truth table of 2-input AND gate is shown below.

image image

Figure 1: Logic Symbol, Truth table and Logic Circuit of AND gate

  1. The output of OR gate produces 1 if one or more input states are 1 else it produces 0. The logic symbol and truth table of 2-input OR gate is shown below.

image image

Figure 2: Logic Symbol, Truth table and Logic Circuit of OR gate

  1. The NOT gate is a digital logic device whose output is always the complement of its input. The NOT gate can be implemented in CMOS logic by connecting PMOS to VDD which acts as Pull Up Network (PUN) and NMOS is connected to ground which acts as Pull Down Network (PDN). The logic symbol, truth table and CMOS implementation of NOT gate is shown below.

image image

Figure 3: Logic Symbol, Truth table and Logic Circuit of NOT gate

  1. The output of NAND gate produces 1 if any one of the input state is 0 else it produces 0. The logic symbol and truth table of 2-input NAND gate is shown below.

image image

Figure 4: Logic Symbol, Truth table and Logic Circuit of NAND gate

  1. The output of NOR gate produces 1 if and only if all the input states are 0 else it produces 0. The logic symbol and truth table of 2-input NOR gate is shown below.

image image

Figure 5: Logic Symbol, Truth table and Logic Circuit of NOR gate

LTspice Simulation

LTspice captures schematics of different circuits and shows the results of simulation by using waveform viewer. Circuit simulation analysis provides the transient, AC and DC analysis.

Terms Description

So, with the given inputs, the voltage source will start at 0V, then immediately rise to 5V. It will remain at 5V upto 5us for VA and 10us for VB, then drop back down to 0V. The total period for one complete cycle of this waveform is 10us for VA and 20us for VB. This cycle will repeat 10 times.

Schematics

Steps to draw schematics

  1. To create a new schematic -> File - New Schematic (Ctrl+N)
  2. Place the transistors using the option Component (P) in the toolbar.
  3. Place the voltage sources and ground from the toolbar and set the values as mentioned above.
  4. Label all the components by using left click on each component.
  5. Make connections by using the option Wire (W) in the toolbar.
  6. Include the technology library using spice directive.
  7. Give the length and width of NMOS and PMOS transistors by selecting the respective transistors.

image image

Figure 6: Length and Width of transistors

  1. To verify the transient analysis -> Click on Voltage sources and give the specific values as mentioned above in the Terms Description.

image

Figure 7: Transient Analysis values

Schematic of AND Gate

image

Figure 8: LTspice Schematic of AND Gate

Schematic of OR Gate

image

Figure 9: LTspice Schematic of OR Gate

Schematic of NOT Gate

image

Figure 10: LTspice Schematic of NOT Gate

Schematic of NAND Gate

image

Figure 11: LTspice Schematic of NAND gate

Schematic of NOR Gate

image

Figure 12: LTspice Schematic of NOR gate

Simulation Results

How to simulate

Results

The pulse rises from 0 to 5v. Depending on the pulse width and period settings, the pulse will repeat at regular intervals. The generated output is based on the applied inputs VA, VB and the logic functionality. The graphs VA - V(n002), VB - V(n003), Vout - V(vout) represent the inputs and output respectively with different colours. The simulation results verifies the functionality of circuits.

image

Figure 13: Simulated waveform of AND Gate

image

Figure 14: Simulated waveform of OR Gate

image

Figure 15: Simulated waveform of NOT Gate

image

Figure 16: Simulated waveform of NAND gate

image

Figure 17: Simulated waveform of NOR gate