

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























RAO PAHALD SINGH GROUP OF INSTITUTIONS
BALANA(MOHINDER GARH)
Write the vhdl code and simulate it for the following gates. i) Two i/p AND Gates. ii) Two i/p OR Gates. iii) Two i/p NAND Gates iv) Two i/p NOR Gates. v) Two i/p EX-OR Gates. vi) NOT Gates.
Mentor graphics FPGA advantage software modelsim simulation tool.
i) Behavior Model if two i/p AND Gate.
Library IEEE; Use IEEE.std_logic_1164.all; Use IEEE.std_logic_arith.all;
Entity and2 is Port (a, b: in bit; z: out bit); End and2;
Architecture beh of and2 is Begin process (a, b) Begin If (a=‟0‟ and b=‟ 0 ‟) then Z<=‟0‟; ElsIf (a=‟0‟ and b=‟ 1 ‟) then Z<=‟0‟; ElsIf (a=‟1‟ and b=‟ 0 ‟) then Z<=‟0‟; ElsIf (a=‟1‟ and b=‟ 1 ‟) then Z<=‟1‟; End if; End process; End beh;
1
2
3
a b Z 0 0 0 0 1 1 1 0 1 1 1 1
Logic Equation: Z=a OR b
iii) Behavior Model if two i/p NAND Gate
Library IEEE; Use IEEE.std_logic_1164.all; Use IEEE.std_logic_arith.all;
Entity NAND_2 is Port (a, b: in bit; z: out bit); End NAND_2;
Architecture NAND_2_beh of NAND_2 is Begin process (a, b) Begin If (a=‟0‟ and b=‟ 0 ‟) then Z<=‟1‟; Elsif (a=‟0‟ and b=‟ 1 ‟) then Z<=‟1‟; Elsif (a=‟1‟ and b=‟ 0 ‟) then Z<=‟1‟; Elsif (a=‟1‟ and b=‟ 1 ‟) then Z<=‟0‟; End if; End process; End NAND_2_beh;
1 2
3
NAND_ TRUTH TABLE
a b Z 0 0 1 0 1 1 1 0 1 1 1 0
Logic Equation: Z=a AND b
iv) Behavior Model if two i/p NOR Gates
Library IEEE; Use IEEE.std_logic_1164.all; Use IEEE.std_logic_arith.all;
Entity NOR_2 is Port (a, b: in bit; z: out bit); End NOR_2;
Architecture NOR_2_beh of NOR_2 is Begin process (a, b) Begin If (a=‟0‟ and b=‟ 0 ‟) then Z<=‟1‟; Elsif (a=‟0‟ and b=‟ 1 ‟) then Z<=‟0‟; Elsif (a=‟1‟ and b=‟ 0 ‟) then Z<=‟0‟; Elsif (a=‟1‟ and b=‟ 1 ‟) then Z<=‟0‟; End if; End process; End NOR_2_beh;
1 2
3
a b Z 0 0 0 0 1 1 1 0 1 1 1 0
Logic Equation: Z= a EX-OR b
v) Behavior Model of NOT Gate
Library IEEE; Use IEEE.std_logic_1164_all; Use IEEE.std_logic_arith_all;
Entity NOT_2 is Port (a: in bit; z: out bit); End NOT_2;
Architecture EXOR_2_beh of EXOR_2 is Begin Process (a) Begin If (a=‟0‟) then Z<=‟1‟; Elsif (a=‟1‟) then Z<=‟0‟; End if; End process; End NOT_2_beh;
1 2
Make sure that there is no syntax and semantie error.
Result:- All the VHDL codes of AND, OR, NAND, NOR, EX-OR and NOT gates are simulated and find correct.
Make sure that there is no syntax and semantie error.
Result:- All the VHDL codes of 1- bit Comparator is simulated and synthesized.
1- Bit Comparator
Write a program for behavior model of 4- bit Comparator
Mentor Graphics FPGA Advantage Software Modelsim Simulation Tool.
Library IEEE; Use IEEE.std_logic_1164.all; Use IEEE.std_logic_arith.all;
Entity COM_2 is Port (a, b: in bit_Vector (3 down to 0); z: out bit_vector (2 down to 0)); End COM_2;
Architecture COM_2_beh of COM_2 is Begin Process (a, b) Begin If (a=b) then Z<=‟ 10 0‟; Elsif (a<b) then Z<=‟010‟; Elsif (a>b) then Z<=‟001‟; End if; End process; End COM_2_beh;
Make sure that there is no syntax and semantie error.
Result:- All the VHDL codes of 4- bit Comparator is simulated and synthesized.
Select Input’s S1 S
Output Y
0 0 I
0 1 I
1 0 I
1 1 I
Truth table of 4-to-1 Multiplexer
Library IEEE; Use IEEE.std_logic_1164_all; Use IEEE.std_logic_arith_all;
Entity DEMUX_2 is Port (a, s0, s1: in bit; z: out bit_vector (3 down to 0)); End DEMUX_2;
Architecture DEMUX_2_beh of DEMUX_2 is Begin Process (so, s1) Begin If (s1=‟0‟ and s0=‟0‟) then
A
A
A
A
I0 I
O
X
S0 BAR S1 BAR
Z (0) <=a; Z (1) <=‟0‟; Z (2) <=‟0‟; Z (3) <=‟0‟; Elsif (s1=‟0‟ and s0=‟1‟) then Z (0) <=‟0‟; Z (1) <=a; Z (2) <=‟0‟; Z (3) <=‟0‟; Elsif (s1=‟1‟ and s0=‟0‟) then Z (0) <=‟0‟; Z (1) <=‟0‟; Z (2) <=a; Z (3) <=‟0‟; Elsif (s1=‟1‟ and s0=‟1‟) then Z (0) <=‟0‟; Z (1) <=‟0‟; Z (2) <=‟0‟; Z (3) <=a; End if; End process; End DEMUX_2_beh;
Make sure that there is no syntax and semantic error.
Result:- A) All the VHDL codes of 4 to 1 Multiplexer is simulated and synthesized. B) All the VHDL codes of 4 to 1 Demultiplexer is simulated and synthesized.
BCD Input’s A B C D
Ou tput’s a b c d e f g 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 1 0 0 0 0 0 0 1 0 1 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 1 1 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1
Truth table of BCD-to-Seven Segment Decoder
BCD-to-Seven Segment Decoder
a b c d e f g
g
a
d
f
e
b
c
Make sure that there is no syntax and semantie error.
Result:- All the VHDL codes of BCD to Seven Segment is simulated and synthesized.
D Q FF
D Q FF
D Q FF
D Q FF
D(0) D(1) D(2) D(3)
PR
CLK
CR
Parallel Input's
Parallel Output's
Make sure that there is no syntax and semantie error.
Result:- All the VHDL codes of PIPO is simulated and synthesized.