Dcs File With Output (BPIT)
Dcs File With Output (BPIT)
Lab
Faculty Name:
PROGRAM NO. 1
Write a program to implement the basic logic gates using
VHDL & simulate it using Xilinx.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity basic_gate is
Port ( x : in STD_LOGIC;
y : in STD_LOGIC;
or_out : out STD_LOGIC;
and_out : out STD_LOGIC;
xor_out : out STD_LOGIC;
nand_out : out STD_LOGIC;
nor_out : out STD_LOGIC;
xnor_out : out STD_LOGIC;
not_out : out STD_LOGIC);
end basic_gate;
architecture data_flow of basic_gate is
begin
or_out <= x or y;
and_out <= x and y;
xor_out <= x xor y;
xnor_out <= x xnor y;
nor_out <= x nor y;
nand_out <= x nand y;
not_out <= not x;
end data_flow;
OUTPUT:-
PROGRAM NO. 2
Write a program to implement half adder using VHDL &
simulate it using Xilinx.
a) USING DATAFLOW MODELLING STYLE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity half_adder is
Port ( x : in STD_LOGIC;
y : in STD_LOGIC;
sum : out STD_LOGIC;
carry : out STD_LOGIC);
end half_adder;
architecture dataflow of half_adder is
begin
sum <= x xor y;
carry <= x and y;
end dataflow;
OUTPUT:-
PROGRAM NO. 3
Write a program to implement full adder using VHDL &
simulate it using Xilinx.
a) USING DATAFLOW MODELLING STYLE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity full_adder is
Port ( x : in STD_LOGIC;
y : in STD_LOGIC;
z : in STD_LOGIC;
sum : out STD_LOGIC;
carry : out STD_LOGIC);
end full_adder;
architecture dataflow of full_adder is
begin
sum <= ((x xor y) xor z);
carry <= (( x and y ) or (y and z) or (z and x));
end dataflow;
OUTPUT:-
PROGRAM NO-4
TO DESIGN AND SIMULATE HALF SUBTRACTER AND
FULL SUBTRACTOR CIRCUIT USING XILINX
VHDL CODE:library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Subtractor is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
diff_halfsubtractor : out STD_LOGIC;
diff_fullsubtractor : out STD_LOGIC;
borr_halfsubtractor : out STD_LOGIC;
borr_fullsubtractor : out STD_LOGIC);
end Subtractor;
architecture Behavioral of Subtractor is
begin
diff_halfsubtractor <= a xor b;
borr_halfsubtractor <= (not a) and b;
diff_fullsubtractor <= a xor b xor c;
borr_fullsubtractor <= ((not a) and b) or ((not a) and c) or (b and c);
end Behavioral;
RTL Schematic
Waveform
PROGRAM NO-5
TO DESIGN AND SIMULATE 4X1 MULTIPLEXER USING XILINX
VHDL CODE:library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux_4_1 is
port(s: in bit_vector(0 to 1); d: in bit_vector(0 to 3);
y: out bit);
end mux_4_1;
architecture mux_4_1 of mux_4_1 is
begin
process(s,d)
begin
if s="00" then
y<=d(0);
elsif s="01" then
y<=d(1);
elsif s="10" then
y<=d(2);
else
y<=d(3);
end if;
end process;
end mux_4_1;
RTL Schematic
Technology Schematic
Waveform
PROGRAM NO-6
TO DESIGN AND SIMULATE 1X4 DEMULTIPLEXER
USING XILINX
VHDL CODE:library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity demux1_4 is
port (
out0 : out std_logic;
out1 : out std_logic;
out2 : out std_logic;
out3 : out std_logic;
sel : in std_logic_vector(1 downto 0);
bitin : in std_logic
);
end demux1_4;
architecture Behavioral of demux1_4 is
begin
process(bitin,sel)
begin
case sel is
when "00" => out0 <= bitin; out1 <= '0'; out2 <= '0'; out3 <='0';
when "01" => out1 <= bitin; out0 <= '0'; out2 <= '0'; out3 <='0';
when "10" => out2 <= bitin; out0 <= '0'; out1 <= '0'; out3 <='0';
when others => out3 <= bitin; out0 <= '0'; out1 <= '0'; out2 <='0';
end case;
end process;
end Behavioral;
RTL Schematic
Technology Schematic
Waveform
PROGRAM NO-8
Technology Schematic
Waveform
PROGRAM NO-9
TO DESIGN AND SIMILATE BCD TO GRAY CODE
CONVERTER
VHDL CODE :library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity gray is
Port ( i : in STD_LOGIC_VECTOR(3 downto 0);
o : out STD_LOGIC_VECTOR(3 downto 0));
end gray;
RTL Schematic
Technology Schematic
Waveform
PROGRAM NO-9
TO DESIGN AND SIMULATE BCD TO EXCESS 3 CODE
CINVERTER USING XILINX
VHDL CODE:library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity saurabh is
Port ( b : in STD_LOGIC_VECTOR(3 downto 0);
e : out STD_LOGIC_VECTOR( 3 downto 0));
end saurabh;
RTL Schematic
Technology Schematic
Waveform
PROGRAM NO-10
TO DESIGN AND SIMULATE 4 BIT MAGNITUDE COMPARATOR
VHDL CODE:library ieee;
USE ieee.Std_logic_1164.ALL;
ENTITY mag4comp IS
PORT(a,b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
greater,less,equal : OUT STD_LOGIC);
END mag4comp;
ARCHITECTURE behaviour OF mag4comp IS
BEGIN
PROCESS(a,b)
BEGIN
IF (a > b) THEN
greater <= '1';
equal <= '0' ;
less <= '0' ;
ELSIF (a < b) THEN
less <= '1' ;
equal <= '0' ;
greater <= '0';
ELSIF (a = b) THEN
equal <= '1';
greater <= '0';
less <= '0';
END IF;
END PROCESS;
END behaviour;
RTL Schematic
Technology Schematic
Waveform