Wa0000.
Wa0000.
Wa0000.
RAJASTHAN
Laboratory Manual
B. Tech (ECE), Year – III, Semester -V
Digital Circuit &System-II Lab – BEC 521
AIM: To implement VHDL code for all the basic gates and test their simulation with
signal.
CODES:
1.XOR gate
IEEE.STD_LOGIC_1164.ALL;
entity ssr1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; y:
Behavioral;
2. AND gate
Code for AND gate library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
( a : in STD_LOGIC;
b : in STD_LOGIC; y
andgate;
begin y<=a
AND b; end
Behavioral;
3. OR gate
Code for OR gate library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity orgate is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; y : out
begin y<=a or b;
end Behavioral;
4. NAND gate
IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity nandgate is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; y
nandgate;
begin y<=a
nand b;
end Behavioral;
5. NOR gate
use IEEE.STD_LOGIC_1164.ALL;
entity norgate is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; y
norgate;
begin y<=a
nor b; end
Behavioral;
6. XNOR gate
IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity xnorgate is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; y
xnorgate;
use IEEE.STD_LOGIC_1164.ALL;
entity notgate is
Port ( a : in STD_LOGIC;
notgate;
begin y<=not a;
end behavio
Experiment:-
AIM: To implement VHDL code for half adder using different types of programming
modeling and test simulation with signal.
IEEE.STD_LOGIC_1164.ALL;
entity ssr is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; s
: out STD_LOGIC;
begin s<=a
xor b; c<=a
and b;
end Behavioral;
Code using structural modelling
library IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity HA2 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; s
: out STD_LOGIC;
HA2;
begin
entity ssr is
Port ( a : in STD_LOGIC;
b : out STD_LOGIC; c:
in STD_LOGIC; d : out
IEEE.STD_LOGIC_1164.ALL;
b<=c;
else d<=not
c; b<= '0';
end Behavioral;
Experiment - 4
Aim : To implement VHDL code for Full adder using different types of programming
modeling and test their simulation with signal.
Modeling
entity fab is
Port ( a : in std_logic; b : in
std_logic; cin : in std_logic;
Out put:
Structural Modeling
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use
IEEE.STD_LOGIC_ARITH.ALL; use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity HA is
Port ( A,B : in STD_LOGIC;
S,C : out STD_LOGIC);
end HA;
architecture dataflow of HA is
begin
S <= A XOR B; C
<= A AND B;
end dataflow;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use
IEEE.STD_LOGIC_ARITH.ALL; use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ORGATE is
Port ( X,Y : in STD_LOGIC;
Z : out STD_LOGIC);
end ORGATE;
architecture dataflow of ORGATE is
begin Z <= X OR Y; end dataflow;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use
IEEE.STD_LOGIC_ARITH.ALL; use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity FAdder is
Port ( FA, FB, FC : in STD_LOGIC;
FS, FCA : out STD_LOGIC); end
FAdder;
AIM : To implement VHDL code for Binary to Grey converter and test their
simulations with signal.
entity ssrB-A is
Port ( b0 : in STD_LOGIC;
b1 : in STD_LOGIC; b2 : in
STD_LOGIC; b3 : in
STD_LOGIC; g0 : out
STD_LOGIC; g1 : out
STD_LOGIC; g2 : out
STD_LOGIC; g3 : out
STD_LOGIC); end ssrB-A;
Behavioral;
Experiment – 6
AIM: To implement VHDL code for 1-bit comparator using different types of
programming modeling and test simulation with signal.
APPARATUS REQUIRED: Xilinx software.
IEEE.STD_LOGIC_1164.ALL;
entity ssr1bit is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; g : out
STD_LOGIC; e : out
STD_LOGIC; l : out
IEEE.STD_LOGIC_1164.ALL;
entity ssr1bit is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; g : out
STD_LOGIC; e : out
STD_LOGIC; l : out
Experiment - 7
Aim : To implement VHDL code for 2-bit comparator using different types of
programming modeling and test simulation with signal.
Apparatus Required : Xilinx software.
Code for 2-bit comparator :
IEEE.STD_LOGIC_1164.ALL;
entity ssr is
b1 : in STD_LOGIC; b0 : in STD_LOGIC;
g : out STD_LOGIC; e : out STD_LOGIC; l:
is begin g<=(a1 and (not b1)) or ((a1 xnor b1) and (a0 and
(not b0))); e<=(a1 xnor b1) and (a0 xnor b0); l<=((not a1)
and b1) or ((a1 xnor b1) and ((not a0) and b0)); end
Behavioral;
STRUCTURAL MODELING :
library IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity ssr is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; g:
STD_LOGIC; l : out
STD_LOGIC; d:out
STD_LOGIC; h:in
STD_LOGIC;
i:out STD_LOGIC);
end component;
component xnor1
port(j:in STD_LOGIC;
k:in STD_LOGIC;
m:out STD_LOGIC);
Behavioral;
Experiment – 8
Aim : To implement VHDL code for 4:1 multiplexer and test their simulations with
signal.
IEEE.STD_LOGIC_1164.ALL;
entity mp is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC; c : in
STD_LOGIC; d : in
STD_LOGIC; s1 : in
STD_LOGIC; s0 : in
STD_LOGIC; y : out
architecture Behavioral of mp is
begin
y<=(a and (not s1) and (not s0)) or (b and (not s1) and s0) or (c and s1 and (not s0))
or (d and s1 and s0); end Behavioral;
Experiment - 9
Aim : To implement VHDL code for Full Subtractor using different types of
modeling and test their simulation with signal.
IEEE.STD_LOGIC_1164.ALL;
entity sai is
Port ( a : in STD_LOGIC; bi : in
STD_LOGIC; c : in STD_LOGIC; d:
out STD_LOGIC; bo : out STD_LOGIC);
<= a xor (bi xor c); bo <= (bi and c) or ((not a) and
IEEE.STD_LOGIC_1164.ALL;
STD_LOGIC; bi : in
STD_LOGIC; c : in
STD_LOGIC; d : out
STD_LOGIC; bo : out
Behavioral;
Structural Modelling :
library IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity rama is
Port ( a : in STD_LOGIC;
bi : in STD_LOGIC; c : in
STD_LOGIC; d : out
STD_LOGIC; bo : out
STD_LOGIC;
component; signal
s1,s2,s3:STD_LOGIC; begin
end Behavioral;
Experiment - 10
Aim : To implement VHDL code for SR flip flop and test simulation with
signal.
APPARATUS REQUIRED: Xilinx software.
entity SR is
Port ( S : in STD_LOGIC;
R : in STD_LOGIC;
CLK : in STD_LOGIC;
Q : out STD_LOGIC); end SR;
architecture Behavioral of SR is
signal p : std_logic;
Q<=p;
end if; end
process; end
Behavioral;
Experiment - 11
Aim: To implement VHDL code for JK flip flop and test simulation with
signal.
APPARATUS REQUIRED: Xilink software.
library IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity ssr is
Port (j: in STD_LOGIC;
k: in STD_LOGIC; clk: in
STD_LOGIC; q: out
signal p: std_logic;
end Behavioural;
EXPERIMENT -12
AIM: To implement VHDL code for 2*2 binary multiplier and test their
simulation with signal.
APPARATUS REQUIRED: Xilink software, simulation tool
entity ssr is
Port ( A1,A0,B1,B0 : in STD_LOGIC;
P0,P1,P2,P3 : out STD_LOGIC); end
component andgate1
W: out std_logic);
end component;
component ssrHA1
port (a,b : in std_logic;
s,c : out std_logic);
behavioural;
HALF ADDER CODE
library IEEE; use
IEEE.STD_LOGIC_1164.ALL;
entity ssrHA1 is
Port ( a ,b : in STD_LOGIC ;
s ,c : out STD_LOGIC);
begin
if (a='0') then
s <= b;
c <= '0';
else
s <= NOT b;
c <= b; end if;
end process;
end behavioural;
ssrandgate1 is Port ( u : in
STD_LOGIC; v : in STD_LOGIC;