SlideShare a Scribd company logo
1 of 7
Experiment–5
Objective: Design and simulate 4- bit Comparator using VHDL.
Requirement: Computer Software Requirement: XILINX 8.2 Software
Theory:
A digital comparator is a hardware electronic device that takes two
numbers as input in binary form and determines whether one number
is greater than, less than or equal to the other number.
A comparator used to compare two binary numbers each of four bits
is called a 4-bit magnitude comparator. It consists of eight inputs
each for two four bit numbers and three outputs to generate less
than, equal to and greater than between two binary numbers.
In a 4-bit comparator the condition of A>B can be possible in the
following four cases:
1. If A3 = 1 and B3 = 0
2. If A3 = B3 and A2 = 1 and B2 = 0
3. If A3 = B3, A2 = B2 and A1 = 1 and B1 = 0
4. If A3 = B3, A2 = B2, A1 = B1 and A0 = 1 and B0 = 0
Similarly the condition for A<B can be possible in the following four
cases:
1. If A3 = 0 and B3 = 1
2. If A3 = B3 and A2 = 0 and B2 = 1
3. If A3 = B3, A2 = B2 and A1 = 0 and B1 = 1
4. If A3 = B3, A2 = B2, A1 = B1 and A0 = 0 and B0 = 1
The condition of A=B is possible only when all the individual bits of
one number exactly coincide with corresponding bits of another
number.
Circuit:
Truth Table:
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity comparator_4bit is
Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC_VECTOR (3 downto 0);
eq : out STD_LOGIC;
ag : out STD_LOGIC;
bg : out STD_LOGIC);
end comparator_4bit;
architecture Behavioral of comparator_4bit is
begin
ag <= '1' when (a> b)
else '0';
eq <= '1' when (a = b)
else '0';
bg <= '1' when (a < b)
else '0';
end Behavioral;
TEST BENCH:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY comparator_tb IS
END comparator_tb;
ARCHITECTURE behavior OF comparator_tb is
COMPONENT comparator_4bit
PORT(
a : IN std_logic_vector(3 downto 0);
b : IN std_logic_vector(3 downto 0);
eq : OUT std_logic;
ag : OUT std_logic;
bg : OUT std_logic
);
END COMPONENT;
--Inputs
signal a : std_logic_vector(3 downto 0) := (others => '0');
signal b : std_logic_vector(3 downto 0) := (others => '0');
--Outputs
signal eq : std_logic;
signal ag : std_logic;
signal bg : std_logic;
BEGIN
uut: comparator_4bit PORT MAP (
a => a,
b => b,
eq => eq,
ag => ag,
bg => bg
);
-- Stimulus process
stim_proc: process
begin
A<="0100";
B<="0010";
wait for 100 ns;
A<="0101";
B<="0010";
wait for 100 ns;
A<="1100";
B<="0011";
wait for 100 ns;
A<="0100";
B<="0100";
wait for 100 ns;
A<="0101";
B<="1100";
wait for 100 ns;
A<="1100";
B<="1100";
wait for 100 ns;
end process;
END;
OUTPUT:
RTL Schematic:
Wave From:
Result:
VHDL program to implement 4 bit comparator has been
successfully simulated.

More Related Content

What's hot

Divide by N clock
Divide by N clockDivide by N clock
Divide by N clockMantra VLSI
 
2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdf2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdfUsha Mehta
 
Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...
Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...
Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...prajon
 
Synopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation System
Synopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation SystemSynopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation System
Synopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation SystemMostafa Khamis
 
Basics of Digital Design and Verilog
Basics of Digital Design and VerilogBasics of Digital Design and Verilog
Basics of Digital Design and VerilogGanesan Narayanasamy
 
Digital VLSI Design : Combinational Circuit
Digital VLSI Design : Combinational CircuitDigital VLSI Design : Combinational Circuit
Digital VLSI Design : Combinational CircuitUsha Mehta
 
Layout & Stick Diagram Design Rules
Layout & Stick Diagram Design RulesLayout & Stick Diagram Design Rules
Layout & Stick Diagram Design Rulesvarun kumar
 
CMOS fabrication n well process
CMOS fabrication n well processCMOS fabrication n well process
CMOS fabrication n well processSouvikDatta22
 

What's hot (20)

Divide by N clock
Divide by N clockDivide by N clock
Divide by N clock
 
FPGA
FPGAFPGA
FPGA
 
2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdf2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdf
 
lvs ppt.pptx
lvs ppt.pptxlvs ppt.pptx
lvs ppt.pptx
 
Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...
Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...
Ultra-thin body SOI MOSFETs: Term Paper_class presentation on Advanced topics...
 
Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
 
Synopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation System
Synopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation SystemSynopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation System
Synopsys Fusion Compiler-Comprehensive RTL-to-GDSII Implementation System
 
Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)
 
Layout02 (1)
Layout02 (1)Layout02 (1)
Layout02 (1)
 
Basics of Digital Design and Verilog
Basics of Digital Design and VerilogBasics of Digital Design and Verilog
Basics of Digital Design and Verilog
 
Digital VLSI Design : Combinational Circuit
Digital VLSI Design : Combinational CircuitDigital VLSI Design : Combinational Circuit
Digital VLSI Design : Combinational Circuit
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
Vlsi design flow
Vlsi design flowVlsi design flow
Vlsi design flow
 
Vlsi 2
Vlsi 2Vlsi 2
Vlsi 2
 
VHDL
VHDLVHDL
VHDL
 
SOI
SOISOI
SOI
 
Layout & Stick Diagram Design Rules
Layout & Stick Diagram Design RulesLayout & Stick Diagram Design Rules
Layout & Stick Diagram Design Rules
 
Verilog ques
Verilog quesVerilog ques
Verilog ques
 
Test Bench Development
Test Bench DevelopmentTest Bench Development
Test Bench Development
 
CMOS fabrication n well process
CMOS fabrication n well processCMOS fabrication n well process
CMOS fabrication n well process
 

Similar to Design 4-bit comparator VHDL

Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...UmerKhan147799
 
DLD Lecture No 21 BCD Multiplier and Magnitude Comparator.pptx
DLD Lecture No 21  BCD Multiplier and Magnitude Comparator.pptxDLD Lecture No 21  BCD Multiplier and Magnitude Comparator.pptx
DLD Lecture No 21 BCD Multiplier and Magnitude Comparator.pptxSaveraAyub2
 
4 bit magnjtude comparators ppt COA project
4 bit magnjtude comparators ppt COA project4 bit magnjtude comparators ppt COA project
4 bit magnjtude comparators ppt COA projectragavank029
 
Digital Comprator
Digital CompratorDigital Comprator
Digital Compratorsuraj829
 
Chapter 3:Programming with Java Operators and Strings
Chapter 3:Programming with Java Operators and  StringsChapter 3:Programming with Java Operators and  Strings
Chapter 3:Programming with Java Operators and StringsIt Academy
 
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsFYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsArti Parab Academics
 
Chapter 3 : Programming with Java Operators and Strings
Chapter 3 : Programming with Java Operators and  StringsChapter 3 : Programming with Java Operators and  Strings
Chapter 3 : Programming with Java Operators and StringsIt Academy
 
Comparators in DLD.
Comparators in DLD.Comparators in DLD.
Comparators in DLD.Zain Jafri
 
E4 unit 2 combitional circuits.pptx
E4 unit 2 combitional circuits.pptxE4 unit 2 combitional circuits.pptx
E4 unit 2 combitional circuits.pptxDeekshithSkandaM
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuitKalai Selvi
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logicDeepak John
 
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...UmerKhan147799
 
Bitwise Operations(1).pdf
Bitwise Operations(1).pdfBitwise Operations(1).pdf
Bitwise Operations(1).pdfDalvinCalvin
 

Similar to Design 4-bit comparator VHDL (20)

Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
 
DLD Lecture No 21 BCD Multiplier and Magnitude Comparator.pptx
DLD Lecture No 21  BCD Multiplier and Magnitude Comparator.pptxDLD Lecture No 21  BCD Multiplier and Magnitude Comparator.pptx
DLD Lecture No 21 BCD Multiplier and Magnitude Comparator.pptx
 
4 bit magnjtude comparators ppt COA project
4 bit magnjtude comparators ppt COA project4 bit magnjtude comparators ppt COA project
4 bit magnjtude comparators ppt COA project
 
Digital Comprator
Digital CompratorDigital Comprator
Digital Comprator
 
DLD Chapter-4.pdf
DLD Chapter-4.pdfDLD Chapter-4.pdf
DLD Chapter-4.pdf
 
Chapter 3:Programming with Java Operators and Strings
Chapter 3:Programming with Java Operators and  StringsChapter 3:Programming with Java Operators and  Strings
Chapter 3:Programming with Java Operators and Strings
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsFYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
 
Logic Gates.pptx
Logic Gates.pptxLogic Gates.pptx
Logic Gates.pptx
 
Chapter 3 : Programming with Java Operators and Strings
Chapter 3 : Programming with Java Operators and  StringsChapter 3 : Programming with Java Operators and  Strings
Chapter 3 : Programming with Java Operators and Strings
 
Comparators in DLD.
Comparators in DLD.Comparators in DLD.
Comparators in DLD.
 
Digital Logic Design
Digital Logic Design Digital Logic Design
Digital Logic Design
 
B sc3 unit 4 combi..lckt
B sc3 unit 4 combi..lcktB sc3 unit 4 combi..lckt
B sc3 unit 4 combi..lckt
 
E4 unit 2 combitional circuits.pptx
E4 unit 2 combitional circuits.pptxE4 unit 2 combitional circuits.pptx
E4 unit 2 combitional circuits.pptx
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
 
Programming in Arduino (Part 1)
Programming in Arduino (Part 1)Programming in Arduino (Part 1)
Programming in Arduino (Part 1)
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logic
 
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
 
Bitwise Operations(1).pdf
Bitwise Operations(1).pdfBitwise Operations(1).pdf
Bitwise Operations(1).pdf
 
DE notes
DE notesDE notes
DE notes
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

Design 4-bit comparator VHDL

  • 1. Experiment–5 Objective: Design and simulate 4- bit Comparator using VHDL. Requirement: Computer Software Requirement: XILINX 8.2 Software Theory: A digital comparator is a hardware electronic device that takes two numbers as input in binary form and determines whether one number is greater than, less than or equal to the other number. A comparator used to compare two binary numbers each of four bits is called a 4-bit magnitude comparator. It consists of eight inputs each for two four bit numbers and three outputs to generate less than, equal to and greater than between two binary numbers. In a 4-bit comparator the condition of A>B can be possible in the following four cases: 1. If A3 = 1 and B3 = 0 2. If A3 = B3 and A2 = 1 and B2 = 0 3. If A3 = B3, A2 = B2 and A1 = 1 and B1 = 0 4. If A3 = B3, A2 = B2, A1 = B1 and A0 = 1 and B0 = 0 Similarly the condition for A<B can be possible in the following four cases: 1. If A3 = 0 and B3 = 1 2. If A3 = B3 and A2 = 0 and B2 = 1 3. If A3 = B3, A2 = B2 and A1 = 0 and B1 = 1 4. If A3 = B3, A2 = B2, A1 = B1 and A0 = 0 and B0 = 1 The condition of A=B is possible only when all the individual bits of one number exactly coincide with corresponding bits of another number.
  • 2. Circuit: Truth Table: VHDL CODE: library IEEE; use IEEE.STD_LOGIC_1164.ALL;
  • 3. entity comparator_4bit is Port ( a : in STD_LOGIC_VECTOR (3 downto 0); b : in STD_LOGIC_VECTOR (3 downto 0); eq : out STD_LOGIC; ag : out STD_LOGIC; bg : out STD_LOGIC); end comparator_4bit; architecture Behavioral of comparator_4bit is begin ag <= '1' when (a> b) else '0'; eq <= '1' when (a = b) else '0'; bg <= '1' when (a < b) else '0'; end Behavioral; TEST BENCH: LIBRARY ieee; USE ieee.std_logic_1164.ALL; ENTITY comparator_tb IS END comparator_tb; ARCHITECTURE behavior OF comparator_tb is COMPONENT comparator_4bit
  • 4. PORT( a : IN std_logic_vector(3 downto 0); b : IN std_logic_vector(3 downto 0); eq : OUT std_logic; ag : OUT std_logic; bg : OUT std_logic ); END COMPONENT; --Inputs signal a : std_logic_vector(3 downto 0) := (others => '0'); signal b : std_logic_vector(3 downto 0) := (others => '0'); --Outputs signal eq : std_logic; signal ag : std_logic; signal bg : std_logic; BEGIN uut: comparator_4bit PORT MAP ( a => a, b => b, eq => eq, ag => ag, bg => bg );
  • 5. -- Stimulus process stim_proc: process begin A<="0100"; B<="0010"; wait for 100 ns; A<="0101"; B<="0010"; wait for 100 ns; A<="1100"; B<="0011"; wait for 100 ns; A<="0100"; B<="0100"; wait for 100 ns; A<="0101"; B<="1100"; wait for 100 ns; A<="1100"; B<="1100"; wait for 100 ns; end process; END;
  • 7. Result: VHDL program to implement 4 bit comparator has been successfully simulated.