Visvesvaraya National Institute of Technology Nagpur: Vlsi Design MTECH 2021-23 VHDL Lab
Visvesvaraya National Institute of Technology Nagpur: Vlsi Design MTECH 2021-23 VHDL Lab
OF TECHNOLOGY NAGPUR
VLSI DESIGN
MTECH 2021-23
VHDL LAB
ASSIGNMENT 1
Submitted by
Rutvik Patel
MT21MVD022
1. Write program, simulate and synthesize the 4×2 Encoder
using Data-flow modelling.
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ENCODER is
Port ( D0 : IN STD_LOGIC;
D1 : IN STD_LOGIC;
D2 : IN STD_LOGIC;
D3 : IN STD_LOGIC;
a : OUT STD_LOGIC;
b : OUT STD_LOGIC );
end ENCODER;
architecture Behavioral of ENCODER is
begin
A <= D2 OR D3;
B <= D1 OR D3;
end Behavioral;
Test_Bench:-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_ENCODER IS
END tb_ENCODER;
ARCHITECTURE behavior OF tb_ENCODER IS
COMPONENT ENCODER
PORT(
D0 : IN std_logic;
D1 : IN std_logic;
D2 : IN std_logic;
D3 : IN std_logic;
a : OUT std_logic;
b : OUT std_logic );
END COMPONENT;
BEGIN
Output:-
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity DECODER is
Port ( D0 : out STD_LOGIC;
D1 : out STD_LOGIC;
D2 : out STD_LOGIC;
D3 : out STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC );
end DECODER;
begin
end Behavioral;
Test_Bench:-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_DECODER IS
END tb_DECODER;
COMPONENT DECODER
PORT(
D0 : out std_logic;
D1 : out std_logic;
D2 : out std_logic;
D3 : out std_logic;
a : IN std_logic;
b : IN std_logic );
END COMPONENT;
signal a : std_logic := '0';
signal b : std_logic := '0';
signal D0 : std_logic;
signal D1 : std_logic;
signal D2 : std_logic;
signal D3 : std_logic;
BEGIN
uut: DECODER PORT MAP (
D0 => D0,
D1 => D1,
D2 => D2,
D3 => D3,
a => a,
b => b);
stim_proc: process
begin
wait for 100 ns;
a <= '0'; b <= '0';
wait for 100 ns;
a <= '1'; b <= '0';
wait for 100 ns;
a <= '0'; b <= '1';
wait for 100 ns;
a <= '1'; b <= '1';
end process;
END;
Output :-
3. Write program, simulate and synthesize the 2×1
multiplexer using Data-flow modelling.
Code :-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity MUX is
Port ( D0 : in STD_LOGIC;
D1 : in STD_LOGIC;
a : in STD_LOGIC;
Y : out STD_LOGIC);
end MUX;
begin
end Behavioral;
Test_bench :-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_mux IS
END tb_mux;
ARCHITECTURE behavior OF tb_mux IS
COMPONENT MUX
PORT(
D0 : IN std_logic;
D1 : IN std_logic;
A : IN std_logic;
Y : OUT std_logic );
END COMPONENT;
signal D0 : std_logic := '0';
signal D1 : std_logic := '0';
signal A : std_logic := '0';
signal Y : std_logic;
BEGIN
uut: MUX PORT MAP (
D0 => D0,
D1 => D1,
A => A,
Y => Y );
stim_proc: process
begin
wait for 100 ns;
D0 <= '1';
D1 <= '0';
A <= '0';
wait for 100 ns;
A <= '1';
wait for 100 ns;
D0 <= '0';
D1 <= '1';
A <= '0';
wait for 100 ns;
A <= '1';
end process;
END;
Output:-
4. Write program, simulate and synthesize the 1×2
demultiplexer using Data-flow modelling.
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity DEMUX is
Port ( D0 : out STD_LOGIC;
D1 : out STD_LOGIC;
a : in STD_LOGIC;
Y : in STD_LOGIC);
end DEMUX;
architecture Behavioral of DEMUX is
begin
end Behavioral;
Test_bench:-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_demux IS
END tb_demux;
COMPONENT DEMUX
PORT(
D0 : out std_logic;
D1 : out std_logic;
a : IN std_logic;
Y : IN std_logi);
END COMPONENT;
signal Y : std_logic := '0';
signal a : std_logic := '0';
signal D0 : std_logic;
signal D1 : std_logic;
BEGIN
stim_proc: process
begin
Y <= '1';
a <= '0';
wait for 100 ns;
a <= '1';
end process;
END;
Output:-
5. Write program, simulate and synthesize the 1bit
comparator using Data-flow modelling.
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity comparator is
Port ( A : IN STD_LOGIC;
B : IN STD_LOGIC;
AGB : OUT STD_LOGIC; --A greather than B
AEB : OUT STD_LOGIC; --A equals to B
ALB : OUT STD_LOGIC ); -- A less than B
end comparator;
architecture Behavioral of comparator is
begin
end Behavioral;
Test_Bench:-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_Comperator IS
END tb_Comperator;
ARCHITECTURE behavior OF tb_Comperator IS
COMPONENT comparator
PORT(
A : IN std_logic;
B : IN std_logic;
AGB : OUT std_logic;
ALB : OUT std_logic;
AEB : OUT std_logic );
END COMPONENT;
signal A : std_logic := '0';
signal B : std_logic := '0';
signal AGB : std_logic;
signal ALB : std_logic;
signal AEB : std_logic;
BEGIN
uut: comparator PORT MAP (
A => A,
B => B,
AGB => AGB,
ALB => ALB,
AEB => AEB);
stim_proc: process
begin
wait for 100 ns;
A <= '0'; B <= '0';
wait for 100 ns;
A <= '0'; B <= '1';
wait for 100 ns;
A <= '1'; B <= '0';
wait for 100 ns;
A <= '1'; B <= '1';
end process;
Test_Output:-
Function: - BC + AC + AB:-
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity IPMAJORITY is
Port ( A : IN STD_LOGIC;
B : IN STD_LOGIC;
C : IN STD_LOGIC;
Y : OUT STD_LOGIC);
end IPMAJORITY;
begin
end Behavioral;
Test_Bench:-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_Majority IS
END tb_Majority;
BEGIN
uut: IPMAJORITY PORT MAP (
A => A,
B => B,
C => C,
Y => Y);
stim_proc: process
begin
END;
Output:-
7. Write program, simulate and synthesize the Full
adder and Full substractor using Data-flow modelling.
Full Adder:-
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity FA is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
C : in STD_LOGIC;
sum : out STD_LOGIC;
carry : out STD_LOGIC);
end FA;
architecture Behavioral of FA is
begin
end Behavioral;
Test_Bench:-
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity full_adder_tb is
end full_adder_tb;
process is
begin
r_BIT1 <= '0';
r_BIT2 <= '0';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '0';
r_BIT2 <= '0';
r_BIT3 <= '1';
wait for 50 ns;
r_BIT1 <= '0';
r_BIT2 <= '1';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '0';
r_BIT2 <= '1';
r_BIT3 <= '1';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '0';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '0';
r_BIT3 <= '1';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '1';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '1';
r_BIT3 <= '1';
wait for 50 ns;
end process;
end behave;
Output:-
Full Subtractor:-
Code:-
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity FS is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
C : in STD_LOGIC;
difference : out STD_LOGIC;
borrow : out STD_LOGIC);
end FS;
architecture Behavioral of FS is
begin
end Behavioral;
Test_Bench:-
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity full_subtractor_tb is
end full_subtractor_tb;
process is
begin
r_BIT1 <= '0';
r_BIT2 <= '0';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '0';
r_BIT2 <= '0';
r_BIT3 <= '1';
wait for 50 ns;
r_BIT1 <= '0';
r_BIT2 <= '1';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '0';
r_BIT2 <= '1';
r_BIT3 <= '1';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '0';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '0';
r_BIT3 <= '1';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '1';
r_BIT3 <= '0';
wait for 50 ns;
r_BIT1 <= '1';
r_BIT2 <= '1';
r_BIT3 <= '1';
wait for 50 ns;
end process;
end behave;
Output:-
D0 (a) = ~B~D + C + BD + A
D1 (b) = ~B + ~C~D + CD
D2 (c) = ~C + D + B
begin
end Behavioral;
Test_BENCH:-
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_Majority IS
END tb_Majority;
BEGIN
uut: BCD PORT MAP (
A => A,
B => B,
C => C,
D => D,
D0 => D0,
D1 => D1,
D2 => D2,
D3 => D3,
D4 => D4,
D5 => D5,
D6 => D6);
stim_proc: process
begin
END;
Output:-
Conclusion:-
Hence the given combinational circuits 4*2 encoder, 2*4
decode, 2*1 MUX, 1*2 DEMUX, 1 bit comparator, 3 input
majority gate, full adder, full subtractor and 7 segment
display codes are simulated and observed the outputs as per
their corresponding truthtables.