0% found this document useful (0 votes)
18 views8 pages

Programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views8 pages

Programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

3.

NAND LOGIC GATE STRUCTURAL MODELLING


library ieee;
use ieee.std_logic_1164.all;

entity nand2 is
port (x,y: in std_logic;
z: out std_logic);
end nand2;

architecture nand2_ data of nand2 is


begin
z<=x nand y;
end nand2_ data;

Library ieee;
use ieee.std_logic_1164.all;

entity nand2_1 is
port(a,b:in std_logic;
c:out std_logic);
end nand2_1;

architecture nand2_1_struct of nand2_1 is


component nand2
port(x,y:in std_logic;
z:out std_logic);
end component;
begin
a1:nand2 port map(a,b,c);
end nand2_1_struct;
4. NOR LOGIC GATE STRUCTURAL MODELLING
library ieee;
use ieee.std_logic_1164.all;

entity nor2 is
port (x,y: in std_logic;
z: out std_logic);
end nor2;

architecture nor2_ data of nor2 is


begin
z<=x nor y;
end nor2_ data;

Library ieee;
use ieee.std_logic_1164.all;

entity nor2_1 is
port(a,b:in std_logic;
c:out std_logic);
end nor2_1;

architecture nor2_1_struct of nor2_1 is


component nor2
port(x,y:in std_logic;
z:out std_logic);
end component;
begin
a1:nor2 port map(a,b,c);
end nor2_1_struct;
5. XNOR LOGIC GATE STRUCTURAL MODELLING
library ieee;
use ieee.std_logic_1164.all;

entity xnor2 is
port (x,y: in std_logic;
z: out std_logic);
end xnor2;

architecture xnor2_ data of xnor2 is


begin
z<=x xnor y;
end xnor2_ data;

Library ieee;
use ieee.std_logic_1164.all;

entity xnor2_1 is
port(a,b:in std_logic;
c:out std_logic);
end xnor2_1;

architecture xnor2_1_struct of xnor2_1 is


component xnor2
port(x,y:in std_logic;
z:out std_logic);
end component;
begin
a1:xnor2 port map(a,b,c);
end xnor2_1_struct;
6. Design of 2 to 4 decoder
Library IEEE ;
use IEEE.STD_LOGIC_1164

entity decoder is
port(a : in STD_LOGIC_VECTOR(1 downto 0);
b : out STD_LOGIC_VECTOR(3 downto 0) );
end decoder ;

Architecture behavioral of decoder is


begin
Process(a)
begin
if (a = “00”)then
b <=”0001” ;
elsif (a= “01”)then
b <=”0010” ;
elsif (a= “10”)then
b <=”0100” ;
else
b <=”1000” ;
end if ;
end process ;
end behavioral ;
7. Design of 8 to 3 encoder

library IEEE;

use IEEE.STD_LOGIC_1164.all,

entity ENCODER8 is

port (A: in std_logic_vector (7 downto 0);

Y: out std_logic_vector (2 downto 0));

end ENCODER8;

architecture ARCH of ENCODER8 is

begin

process (A)

begin

case A is

when "00000001" => Y <= "000";

when "00000010" => Y <= "001";

when "00000100" => Y <= "010";

when "00001000" => Y <= "011";

when "00010000" => Y <= "100";

when "00100000" => Y <= "101";

when "01000000" => Y <= "110";

when "10000000" => Y <= "111";

when others => Y <= "XXX";

end case ;

end process ;

end ARCH;
9. Design of 8 to 1 multiplexer

library ieee;
use ieee.std_logic_1164.all;

entity mux8x1 is
port ( s : in std_logic_vector(2 downto 0);
d : in std_logic_vector(7 downto 0);
en : in std_logic;
y : out std_logic );
end mux8x1;

Architecture mux_8x1 of mux8x1 is


begin
process (s,d,en)
begin
if(en='0') then y<='0';
else
case s is
when "000"=> y<=d(0);
when "001"=> y<=d(1);
when "010"=> y<=d(2);
when "011"=> y<=d(3);
when "100"=> y<=d(4);
when "101"=> y<=d(5);
when "110"=> y<=d(6);
when "111"=> y<=d(7);
when others=> y<='0';
end case;
end if;
end process;
end mux_8x1;
10. Design of 4 bit binary to gray converter
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity binary_to_gray is
port(din : in STD_LOGIC_VECTOR(3 downto 0);
dout : out STD_LOGIC_VECTOR(3 downto 0));
end binary_to_gray;

architecture binary_to_gray_arc of binary_to_gray is


begin
process (din) is
begin
if (din="0000") then
dout <= "0000";
elsif (din="0001") then
dout <= "0001";
elsif (din="0010") then
dout <= "0011";
elsif (din="0011") then
dout <= "0010";
elsif (din="0100") then
dout <= "0110";
elsif (din="0101") then
dout <= "0111";
elsif (din="0110") then
dout <= "0101";
elsif (din="0111") then
dout <= "0100";
elsif (din="1000") then
dout <= "1100";
elsif (din="1001") then
dout <= "1101";
elsif (din="1010") then
dout <= "1111";
elsif (din="1011") then
dout <= "1110";
elsif (din="1100") then
dout <= "1010";
elsif (din="1101") then
dout <= "1011";
elsif (din="1110") then
dout <= "1001";
else dout <= "1000";
end if;
end process;

end binary_to_gray_arc;

You might also like