SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Q 1:– Design All Logical Gates Using VHDL.

Solution: -

AND Gate:-
                                                     Source Code: -

--------------------------------------------------

-- AND gate

-- two descriptions provided

--------------------------------------------------

library ieee;

use ieee.std_logic_1164.all;

--------------------------------------------------

entity AND_ent is

port(        x: in std_logic;

             y: in std_logic;

             F: out std_logic

);

end AND_ent;

--------------------------------------------------

architecture AND_behav1 of AND_ent is

begin

     process(x, y)

     begin

       -- compare to truth table

       if ((x='1') and (y='1')) then

               F <= '1';

             else

               F <= '0';

             end if;

     end process;
end behav1;

architecture AND_behav2 of AND_ent is

begin

     F <= x and y;

end behav2;

                                         Sample Waveform Output: -




OR Gate:-
                                              Source Code: -

--------------------------------------

-- OR gate

--

-- two descriptions provided

--------------------------------------

library ieee;

use ieee.std_logic_1164.all;

--------------------------------------

entity OR_ent is

port(      x: in std_logic;

           y: in std_logic;

           F: out std_logic
);

end OR_ent;

---------------------------------------

architecture OR_arch of OR_ent is

begin

     process(x, y)

           begin

                -- compare to truth table

                if ((x='0') and (y='0')) then

                     F <= '0';

                     else

                     F <= '1';

                     end if;

           end process;

end OR_arch;

architecture OR_beh of OR_ent is

begin

     F <= x or y;

end OR_beh;

                                                Sample Waveform Output: -




NOT Gate:-
                                                     Source Code: -
--------------------------------------

-- NOT gate

--

-- two descriptions provided

--------------------------------------

library ieee;

use ieee.std_logic_1164.all;

--------------------------------------

entity NOT_ent is

port(      x: in std_logic;

           F: out std_logic

);

end NOT_ent;

---------------------------------------

architecture NOT_arch of NOT_ent is

begin

     F <= not x;

end NOT_beh;

                                          Sample Waveform Output: -




NAND Gate:-
Source Code: -

-----------------------------------------

-- NAND gate

--

-- two descriptions provided

-----------------------------------------

library ieee;

use ieee.std_logic_1164.all;

------------------------------------------

entity NAND_ent is

port(        x: in std_logic;

             y: in std_logic;

             F: out std_logic

);

end NAND_ent;

------------------------------------------

architecture behv1 of NAND_ent is

begin

     process(x, y)

     begin

       -- compare to truth table

       if (x='1' and y='1') then

               F <= '0';

             else

               F <= '1';

             end if;

     end process;

end behv1;
-----------------------------------------

architecture behv2 of NAND_ent is

begin

          F <= x nand y;

end behv2;

                                            Sample Waveform Output: -




NOR Gate:-
                                                 Source Code: -

-----------------------------------------

-- NOR gate

--

-- two descriptions provided

-----------------------------------------

library ieee;

use ieee.std_logic_1164.all;

-----------------------------------------

entity NOR_ent is

port(     x: in std_logic;

          y: in std_logic;

          F: out std_logic

);
end NOR_ent;

------------------------------------------

architecture behv1 of NOR_ent is

begin

  process(x, y)

  begin

     -- compare to truth table

          if (x='0' and y='0') then

        F <= '1';

          else

             F <= '0';

          end if;

  end process;

end behv1;

architecture behv2 of NOR_ent is

begin

  F <= x nor y;

end behv2;

                                             Sample Waveform Output: -




XOR Gate:-
Source Code: -

--------------------------------------

-- XOR gate

--

-- two descriptions provided

--------------------------------------

library ieee;

use ieee.std_logic_1164.all;

--------------------------------------

entity XOR_ent is

port(        x: in std_logic;

             y: in std_logic;

             F: out std_logic

);

end XOR_ent;



--------------------------------------

architecture behv1 of XOR_ent is

begin

     process(x, y)

     begin

       -- compare to truth table

             if (x/=y) then

         F <= '1';

             else

               F <= '0';

             end if;

     end process;
end behv1;

architecture behv2 of XOR_ent is

begin

     F <= x xor y;

end behv2;

                                         Sample Waveform Output: -




XNOR Gate:-
                                              Source Code: -

--------------------------------------

-- XOR gate

--

-- two descriptions provided

--------------------------------------

library ieee;

use ieee.std_logic_1164.all;

--------------------------------------

entity XNOR_ent is

port(      x: in std_logic;

           y: in std_logic;

           F: out std_logic
);

end XNOR_ent;

---------------------------------------

architecture behv1 of XNOR_ent is

begin

     process(x, y)

     begin

       -- compare to truth table

       if (x/=y) then

               F <= '0';

             else

               F <= '1';

             end if;

     end process;

end behv1;

architecture behv2 of XNOR_ent is

begin

     F <= x xnor y;

end behv2;

---------------------------------------

                                          Sample Waveform Output: -
Q 2:– Write VHDL Programs for the following and check simulation –
1. Half Adder
2. Full Adder

Solution: -

Half Adder:-
                                         Source Code: -
-- =============================================================================
-- file name is : ha (ha=half adder)
-- Author       : Soumya
-- =============================================================================
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_unsigned.ALL;

entity ha is
   port (X           : in std_logic;
         Y           : in std_logic;
         Z           : out std_logic; -- sum out of X+Y
         C           : out std_logic -- carry out from X+Y
        );
end ha;
-- =============================================================================
-- =============================================================================
architecture rtl of ha is
-- =============================================================================
begin
   Z <= (X XOR Y);
   C <= X AND Y;    -- the logical operator "AND" and "XOR" is defined in VHDL.
end rtl;
                                  Sample Waveform Output: -




Full Adder:-
                                         Source Code: -
--   =============================================================================
--   file name is : fa (fa=full adder)
--   Author       : Soumya
--   =============================================================================
library ieee;
use ieee.std_logic_1164.ALL;       -- can be different dependent on tool used.
use ieee.std_logic_unsigned.ALL;   -- can be different dependent on tool used.

entity fa is
   port (a           : in std_logic;
         b           : in std_logic;
         c_in        : in std_logic;
         sum         : out std_logic; -- sum out of X+Y
         c_out       : out std_logic -- carry out
        );
end fa;
-- =============================================================================
-- =============================================================================
architecture rtl of fa is
              -- Define internal signals
  signal sum_low : std_logic;
  signal c_low   : std_logic;
  signal c_high : std_logic;

              -- Define the entity of the half adder to instansiate
component ha -- "ha" must be same name as used in the entity for the file
   port (X           : in std_logic;
         Y           : in std_logic;
         Z           : out std_logic; -- sum out of X+Y
         C           : out std_logic -- carry out
        );
end component;   --------- end of entity for ha ----------
-- =============================================================================
begin

ha_low : ha
   port map (
   -- ha-side      fa-side
         X    =>    a,
         Y    =>    b,
         Z    =>    sum_low,
         C    =>    c_low
    );           --------- end of port map for "ha_low" ----------

ha_high : ha
   port map (
   -- ha-side      fa-side
         X    =>    sum_low,
         Y    =>    c_in,
         Z    =>    sum,
         C    =>    c_high
    );           --------- end of port map for "ha_high" ----------

  c_out <= (c_low OR c_high);

end rtl;
Sample Waveform Output: -
Q 3:– Write VHDL Programs for the following and check simulation –
1. Multiplexer
2. Demultiplexer

Solution: -

Multiplexer (4 X 1):-
                                                        Source Code: -

-------------------------------------------------

-- VHDL code for 4:1 multiplexor

-- Multiplexor is a device to select different

-- inputs to outputs. we use 3 bits vector to

-- describe its I/O ports

-------------------------------------------------

library ieee;

use ieee.std_logic_1164.all;

-------------------------------------------------

entity Mux is

port(        I3:     in std_logic_vector(2 downto 0);

             I2:     in std_logic_vector(2 downto 0);

             I1:     in std_logic_vector(2 downto 0);

             I0:     in std_logic_vector(2 downto 0);

             S:      in std_logic_vector(1 downto 0);

             O:      out std_logic_vector(2 downto 0)

);

end Mux;

-------------------------------------------------

architecture behv1 of Mux is

begin

     process(I3,I2,I1,I0,S)

     begin
-- use case statement

    case S is

          when "00" => O <= I0;

          when "01" => O <= I1;

          when "10" => O <= I2;

          when "11" => O <= I3;

          when others =>          O <= "ZZZ";

        end case;

  end process;

end behv1;

architecture behv2 of Mux is

begin

  -- use when.. else statement

  O <= I0 when S="00" else

                 I1 when S="01" else

                 I2 when S="10" else

                 I3 when S="11" else

                 "ZZZ";

end behv2;

                                            Sample Waveform Output: -
Demultiplexer (1 X 4):-
                                                           Source Code: -

library ieee;

use ieee.std_logic_1164.all;

entity Demux_4_to_1 is

     port(     E : in std_logic; -- the signal source

         S0, S1 : in std_logic; -- the selector switches

     D0, D1, D2, D3 : out std_logic);-- the output data lines

end Demux_4_to_1;

--

architecture Func of Demux_4_to_1 is

     component andGate is              --import AND Gate entity

      port(         A, B, C : in std_logic;

              F : out std_logic);

     end component;

     component notGate is            --import NOT Gate entity

      port( inPort : in std_logic;

         outPort : out std_logic);
end component;

  signal invOut0, invOut1 : std_logic;

begin

  --Just like the real circuit, there are

  --four components: G1 to G4

  GI1: notGate port map(S0, invOut0);

  GI2: notGate port map(S1, invOut1);

  GA1: andGate port map(E, invOut1, invOut0, D0); -- D0

  GA2: andGate port map(E, S0, invOut1, D1);                   -- D1

  GA3: andGate port map(E, invOut0, S1, D2);                   -- D2

  GA4: andGate port map(E, S0, S1, D3);                    -- D3

end Func;

---------------------------------------------------------END

---------------------------------------------------------END

                                                      Sample Waveform Output: -
Q 4:– Write VHDL Programs for the following and check simulation –
1. Decoder
2. Encoder

Solution: -

DECODER (2 to 4 line):-
                                                    Source Code: -

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

entity decoder is

port( input : in std_logic_vector(2 downto 0); --3 bit input

      output : out std_logic_vector(7 downto 0) -- 8 bit ouput

 );

end decoder;

architecture arch of decoder is

begin

output(0) <= (not input(2)) and (not input(1)) and (not input(0));

output(1) <= (not input(2)) and (not input(1)) and input(0);

output(2) <= (not input(2)) and input(1) and (not input(0));

output(3) <= (not input(2)) and input(1) and input(0);

output(4) <= input(2) and (not input(1)) and (not input(0));

output(5) <= input(2) and (not input(1)) and input(0);

output(6) <= input(2) and input(1) and (not input(0));

output(7) <= input(2) and input(1) and input(0);

end arch;

                                            Sample Waveform Output: -
ENCODER (4 Input Priority Encoder):-
                                                  Source Code: -

library ieee;

use ieee.std_logic_1164.all;

entity Encoder_8x3 is

port(d0,d1,d2,d3,d4,d5,d6,d7:in std_logic;

a0,a1,a2:out std_logic);

end Encoder_8x3;

architecture arch of Encoder_8x3 is

begin

a2<= d4 or d5 or d6 or d7;

a1<= d2 or d3 or d6 or d7;

a0<= d1 or d3 or d5 or d7;

end arch;

                                             Sample Waveform Output: -
Q 5:– Write a VHDL Program for a Comparator and check the simulation.

Solution: -

COMPARATOR:-
                                             Source Code: -

LIBRARY ieee ;

USE ieee.std_logic_1164.all ;

USE ieee.std_logic_arith.all ;

ENTITY compare IS

PORT ( A, B : IN SIGNED(3 DOWNTO 0) ;

AeqB, AgtB, AltB : OUT STD_LOGIC ) ;

END compare ;

ARCHITECTURE Behavior OF compare IS

BEGIN

AeqB <= '1' WHEN A = B ELSE '0' ;

AgtB <= '1' WHEN A > B ELSE '0' ;

AltB <= '1' WHEN A < B ELSE '0' ;

END Behavior ;

                                        Sample Waveform Output: -
Q 6:– Write a VHDL Program for a Code Convertor and check the simulation.

Solution: -

BCD to BINARY CODE CONVERTOR:-
                                                Source Code: -
library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

entity BCD2BIN is

  Port ( bcd : in STD_LOGIC_VECTOR (4 downto 0);

      binary : out STD_LOGIC_VECTOR (3 downto 0));

end BCD2BIN;

architecture Behavioral of BCD2BIN is

        begin

                process (bcd)

                       begin

                                case bcd is

                                              when "00000" => binary <= "0000";

                                              when "00001" => binary <= "0001";

                                              when "00010" => binary <= "0010";

                                              when "00011" => binary <= "0011";

                                              when "00100" => binary <= "0100";

                                              when "00101" => binary <= "0101";

                                              when "00110" => binary <= "0110";

                                              when "00111" => binary <= "0111";

                                              when "01000" => binary <= "1000";

                                              when "01001" => binary <= "1001";

                                              when "10000" => binary <= "1010";

                                              when "10001" => binary <= "1011";

                                              when "10010" => binary <= "1100";

                                              when "10011" => binary <= "1101";

                                              when "10100" => binary <= "1110";

                                              when "10101" => binary <= "1111";
when others => binary <= "XXXX";

                                 end case;

                  end process;

end Behavioral;

                                             Sample Waveform Output: -
Q 7:– Write a VHDL Program for a Flip-Flop and check the simulation.

Solution: -

JK FLIP FLOP:-
                                              Source Code: -
library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

entity jk is

  Port ( J : in STD_LOGIC;

        K : in STD_LOGIC;

        clock : in STD_LOGIC;

        reset : in STD_LOGIC;

        Q : out STD_LOGIC;

        Qbar : out STD_LOGIC);

end jk;

architecture Behavioral of jk is

signal state: std_logic;

signal input: std_logic_vector(1 downto 0);

begin

input <= J & K;

p: process(clock, reset) is

begin

if (reset='1') then

state <= '0';

elsif (rising_edge(clock)) then

case (input) is

when "11" =>

state <= not state;

when "10" =>

state <= '1';

when "01" =>

state <= '0';
when others =>

null;

end case;

end if;

end process;

Q <= state;

Qbar <= not state;

end Behavioral;
                     Sample Waveform Output: -
Q 8:– Write a VHDL Program for a Counter and check the simulation.

Solution: -

N BIT COUNTER:-
                                               Source Code: -
----------------------------------------------------
-- VHDL code for n-bit counter
--
-- this is the behavior description of n-bit counter
-- another way can be used is FSM model.
----------------------------------------------------
library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
----------------------------------------------------
entity counter is
generic(n: natural :=2);
port( clock: in std_logic;
         clear: in std_logic;
         count: in std_logic;
         Q:       out std_logic_vector(n-1 downto 0)
);
end counter;
----------------------------------------------------
architecture behv of counter is
    signal Pre_Q: std_logic_vector(n-1 downto 0);
begin
    -- behavior describe the counter
    process(clock, count, clear)
    begin
         if clear = '1' then
             Pre_Q <= Pre_Q - Pre_Q;
         elsif (clock='1' and clock'event) then
             if count = '1' then
                  Pre_Q <= Pre_Q + 1;
             end if;
         end if;
    end process;
    -- concurrent assignment statement
    Q <= Pre_Q;
end behv;
                                                Sample Waveform Output: -
Q 9:– Write VHDL Programs for the following and check simulation –
1. Register
2. Shift Register

Solution: -

N-Bit Register:-
                                                       Source Code: -
---------------------------------------------------
-- n-bit Register (ESD book figure 2.6)
--
-- KEY WORD: concurrent, generic and range
---------------------------------------------------

library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

---------------------------------------------------

entity reg is

generic(n: natural :=2);
port( I:      in std_logic_vector(n-1 downto 0);
      clock: in std_logic;
      load: in std_logic;
      clear: in std_logic;
      Q:      out std_logic_vector(n-1 downto 0)
);
end reg;

----------------------------------------------------

architecture behv of reg is

   signal Q_tmp: std_logic_vector(n-1 downto 0);

begin

   process(I, clock, load, clear)
   begin

         if clear = '0' then
          -- use 'range in signal assigment
          Q_tmp <= (Q_tmp'range => '0');
         elsif (clock='1' and clock'event) then
             if load = '1' then
                   Q_tmp <= I;
             end if;
         end if;

   end process;
-- concurrent statement
   Q <= Q_tmp;

end behv;

---------------------------------------------------
                                                Sample Waveform Output: -




3-Bit Shift Register:-
                                                      Source Code: -
---------------------------------------------------
-- 3-bit Shift-Register/Shifter
--
-- reset is ignored according to the figure
---------------------------------------------------

library ieee ;
use ieee.std_logic_1164.all;

---------------------------------------------------

entity shift_reg is
port( I:                   in std_logic;
        clock:             in std_logic;
        shift:             in std_logic;
        Q:                 out std_logic
);
end shift_reg;

---------------------------------------------------

architecture behv of shift_reg is

   -- initialize the declared signal
   signal S: std_logic_vector(2 downto 0):="111";

begin
process(I, clock, shift, S)
  begin

      -- everything happens upon the clock changing
      if clock'event and clock='1' then
          if shift = '1' then
               S <= I & S(2 downto 1);
          end if;
      end if;

  end process;

  -- concurrent assignment
  Q <= S(0);

end behv;

                                  Sample Waveform Output: -
PRACTICAL FILE




        DIGITAL SYSTEM
          DESIGN LAB
                    Softwares Used – 1. Xilinx 13.4
                         2. ActiveHDL 7.2 SE




Submitted To:-                                        Submitted By:-
Mr. Manoj Ahlawat                                     Soumya S. Behera
Asst. Professor                                       1826
                                                      6th Semester, CSE
                                                      UIET, Mdu, Rohtak

Contenu connexe

Tendances

Multiplexers and Demultiplexers
Multiplexers and DemultiplexersMultiplexers and Demultiplexers
Multiplexers and DemultiplexersGargiKhanna1
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic ProgrammingFenil Shah
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Flip flop conversions
Flip flop conversionsFlip flop conversions
Flip flop conversionsuma jangaman
 
basic logic gates
 basic logic gates basic logic gates
basic logic gatesvishal gupta
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.pptRatnakar Mikkili
 
Python If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaPython If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaEdureka!
 
Lecture 13 Criptarithmetic problem
Lecture 13 Criptarithmetic problemLecture 13 Criptarithmetic problem
Lecture 13 Criptarithmetic problemHema Kashyap
 
Presentation on Scaling
Presentation on ScalingPresentation on Scaling
Presentation on ScalingRaviraj Kaur
 
Finite state machines
Finite state machinesFinite state machines
Finite state machinesdennis gookyi
 
Differential equations of first order
Differential equations of first orderDifferential equations of first order
Differential equations of first ordervishalgohel12195
 
FATTREE: A scalable Commodity Data Center Network Architecture
FATTREE: A scalable Commodity Data Center Network ArchitectureFATTREE: A scalable Commodity Data Center Network Architecture
FATTREE: A scalable Commodity Data Center Network ArchitectureAnkita Mahajan
 

Tendances (20)

Multiplexers and Demultiplexers
Multiplexers and DemultiplexersMultiplexers and Demultiplexers
Multiplexers and Demultiplexers
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
 
Floyd Warshall Algorithm
Floyd Warshall AlgorithmFloyd Warshall Algorithm
Floyd Warshall Algorithm
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Velosity saturation
Velosity saturationVelosity saturation
Velosity saturation
 
Flip flop conversions
Flip flop conversionsFlip flop conversions
Flip flop conversions
 
basic logic gates
 basic logic gates basic logic gates
basic logic gates
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt
 
Python If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaPython If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | Edureka
 
Lecture 13 Criptarithmetic problem
Lecture 13 Criptarithmetic problemLecture 13 Criptarithmetic problem
Lecture 13 Criptarithmetic problem
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
 
Presentation on Scaling
Presentation on ScalingPresentation on Scaling
Presentation on Scaling
 
Finite state machines
Finite state machinesFinite state machines
Finite state machines
 
Type conversion
Type conversionType conversion
Type conversion
 
Differential equations of first order
Differential equations of first orderDifferential equations of first order
Differential equations of first order
 
FATTREE: A scalable Commodity Data Center Network Architecture
FATTREE: A scalable Commodity Data Center Network ArchitectureFATTREE: A scalable Commodity Data Center Network Architecture
FATTREE: A scalable Commodity Data Center Network Architecture
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuits
 

En vedette

Computer Networking Lab File
Computer Networking Lab FileComputer Networking Lab File
Computer Networking Lab FileNitin Bhasin
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab FileKandarp Tiwari
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manualPrabhu D
 
Talent Gradient Construction Based on Competency
Talent Gradient Construction Based on CompetencyTalent Gradient Construction Based on Competency
Talent Gradient Construction Based on CompetencyVincent T. ZHAO
 
Corporate Image Consulting
Corporate Image ConsultingCorporate Image Consulting
Corporate Image Consultingrobertsol
 
A guide to prayer
A guide to prayerA guide to prayer
A guide to prayerHelmon Chan
 
8 habits of highly effective language learners
8 habits of highly effective language learners8 habits of highly effective language learners
8 habits of highly effective language learnersPhilip Seifi
 
Qtp important frameworks
Qtp important frameworksQtp important frameworks
Qtp important frameworksprs0302
 
WASH United India | Fellowships | Round 2
WASH United India | Fellowships | Round 2WASH United India | Fellowships | Round 2
WASH United India | Fellowships | Round 2WASH United
 
스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙ 실시간토토 실 시간배팅
스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙  실시간토토  실  시간배팅스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙  실시간토토  실  시간배팅
스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙ 실시간토토 실 시간배팅fdghjhj
 

En vedette (20)

Computer Networking Lab File
Computer Networking Lab FileComputer Networking Lab File
Computer Networking Lab File
 
Modeling and Simulation Lab Manual ME PED
Modeling and Simulation Lab Manual ME PEDModeling and Simulation Lab Manual ME PED
Modeling and Simulation Lab Manual ME PED
 
C n practical file
C n practical fileC n practical file
C n practical file
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
 
Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
Elearning v.0.0
Elearning v.0.0Elearning v.0.0
Elearning v.0.0
 
Talent Gradient Construction Based on Competency
Talent Gradient Construction Based on CompetencyTalent Gradient Construction Based on Competency
Talent Gradient Construction Based on Competency
 
Corporate Image Consulting
Corporate Image ConsultingCorporate Image Consulting
Corporate Image Consulting
 
Immigration, Women, and Children: Part II – Sample Situations
Immigration, Women, and Children: Part II – Sample Situations Immigration, Women, and Children: Part II – Sample Situations
Immigration, Women, and Children: Part II – Sample Situations
 
A guide to prayer
A guide to prayerA guide to prayer
A guide to prayer
 
8 habits of highly effective language learners
8 habits of highly effective language learners8 habits of highly effective language learners
8 habits of highly effective language learners
 
Qtp important frameworks
Qtp important frameworksQtp important frameworks
Qtp important frameworks
 
DGAE
DGAEDGAE
DGAE
 
Saz1
Saz1Saz1
Saz1
 
BDPA LA: Google Sites
BDPA LA: Google SitesBDPA LA: Google Sites
BDPA LA: Google Sites
 
Rescue1.asd
Rescue1.asdRescue1.asd
Rescue1.asd
 
4g5
4g54g5
4g5
 
WASH United India | Fellowships | Round 2
WASH United India | Fellowships | Round 2WASH United India | Fellowships | Round 2
WASH United India | Fellowships | Round 2
 
스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙ 실시간토토 실 시간배팅
스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙  실시간토토  실  시간배팅스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙  실시간토토  실  시간배팅
스타토토⊙o⊙Wifi89,cOm(카톡: XaZa⊙o⊙ 실시간토토 실 시간배팅
 

Similaire à Design Logical Gates Using VHDL

Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01Shilpa Sharma
 
Ecet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comEcet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comamaranthbeg100
 
Ecet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comEcet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comamaranthbeg60
 
Ecet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comEcet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comamaranthbeg120
 
Ecet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comEcet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comamaranthbeg80
 
Loopback.vhd
Loopback.vhdLoopback.vhd
Loopback.vhdsachindb9
 
Kernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering OopsiesKernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering OopsiesAnne Nicolas
 
Laboratory Report Sample
Laboratory Report SampleLaboratory Report Sample
Laboratory Report SampleMarkus Flicke
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesRicardo Castro
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64FFRI, Inc.
 
A whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerA whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerNikita Popov
 
Real Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGAReal Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGAMafaz Ahmed
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorDaniel Roggen
 
Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4Phil Sturgeon
 

Similaire à Design Logical Gates Using VHDL (20)

Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01
 
Q 1
Q 1Q 1
Q 1
 
Session1
Session1Session1
Session1
 
Ecet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.comEcet 340 Your world/newtonhelp.com
Ecet 340 Your world/newtonhelp.com
 
Ecet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.comEcet 340 Motivated Minds/newtonhelp.com
Ecet 340 Motivated Minds/newtonhelp.com
 
Ecet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.comEcet 340 Extraordinary Success/newtonhelp.com
Ecet 340 Extraordinary Success/newtonhelp.com
 
Ecet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.comEcet 340 Education is Power/newtonhelp.com
Ecet 340 Education is Power/newtonhelp.com
 
Loopback.vhd
Loopback.vhdLoopback.vhd
Loopback.vhd
 
Kernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering OopsiesKernel Recipes 2013 - Deciphering Oopsies
Kernel Recipes 2013 - Deciphering Oopsies
 
Unix executable buffer overflow
Unix executable buffer overflowUnix executable buffer overflow
Unix executable buffer overflow
 
Laboratory Report Sample
Laboratory Report SampleLaboratory Report Sample
Laboratory Report Sample
 
Hspice tut
Hspice tutHspice tut
Hspice tut
 
MySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB StatusMySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB Status
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
A whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerA whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizer
 
1-300-206 (SENSS)=Firewall (642-618)
1-300-206 (SENSS)=Firewall (642-618) 1-300-206 (SENSS)=Firewall (642-618)
1-300-206 (SENSS)=Firewall (642-618)
 
Real Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGAReal Time Clock Interfacing with FPGA
Real Time Clock Interfacing with FPGA
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4
 

Plus de Soumya Behera

Lead Designer Credential
Lead Designer CredentialLead Designer Credential
Lead Designer CredentialSoumya Behera
 
Appian Designer Credential Certificate
Appian Designer Credential CertificateAppian Designer Credential Certificate
Appian Designer Credential CertificateSoumya Behera
 
Credential for Soumya Behera1
Credential for Soumya Behera1Credential for Soumya Behera1
Credential for Soumya Behera1Soumya Behera
 
Visual programming lab
Visual programming labVisual programming lab
Visual programming labSoumya Behera
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
School management system
School management systemSchool management system
School management systemSoumya Behera
 

Plus de Soumya Behera (11)

Lead Designer Credential
Lead Designer CredentialLead Designer Credential
Lead Designer Credential
 
Appian Designer Credential Certificate
Appian Designer Credential CertificateAppian Designer Credential Certificate
Appian Designer Credential Certificate
 
Credential for Soumya Behera1
Credential for Soumya Behera1Credential for Soumya Behera1
Credential for Soumya Behera1
 
Visual programming lab
Visual programming labVisual programming lab
Visual programming lab
 
Computer network
Computer networkComputer network
Computer network
 
Cn assignment
Cn assignmentCn assignment
Cn assignment
 
Matlab file
Matlab fileMatlab file
Matlab file
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
School management system
School management systemSchool management system
School management system
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Unix practical file
Unix practical fileUnix practical file
Unix practical file
 

Dernier

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Design Logical Gates Using VHDL

  • 1. Q 1:– Design All Logical Gates Using VHDL. Solution: - AND Gate:- Source Code: - -------------------------------------------------- -- AND gate -- two descriptions provided -------------------------------------------------- library ieee; use ieee.std_logic_1164.all; -------------------------------------------------- entity AND_ent is port( x: in std_logic; y: in std_logic; F: out std_logic ); end AND_ent; -------------------------------------------------- architecture AND_behav1 of AND_ent is begin process(x, y) begin -- compare to truth table if ((x='1') and (y='1')) then F <= '1'; else F <= '0'; end if; end process;
  • 2. end behav1; architecture AND_behav2 of AND_ent is begin F <= x and y; end behav2; Sample Waveform Output: - OR Gate:- Source Code: - -------------------------------------- -- OR gate -- -- two descriptions provided -------------------------------------- library ieee; use ieee.std_logic_1164.all; -------------------------------------- entity OR_ent is port( x: in std_logic; y: in std_logic; F: out std_logic
  • 3. ); end OR_ent; --------------------------------------- architecture OR_arch of OR_ent is begin process(x, y) begin -- compare to truth table if ((x='0') and (y='0')) then F <= '0'; else F <= '1'; end if; end process; end OR_arch; architecture OR_beh of OR_ent is begin F <= x or y; end OR_beh; Sample Waveform Output: - NOT Gate:- Source Code: -
  • 4. -------------------------------------- -- NOT gate -- -- two descriptions provided -------------------------------------- library ieee; use ieee.std_logic_1164.all; -------------------------------------- entity NOT_ent is port( x: in std_logic; F: out std_logic ); end NOT_ent; --------------------------------------- architecture NOT_arch of NOT_ent is begin F <= not x; end NOT_beh; Sample Waveform Output: - NAND Gate:-
  • 5. Source Code: - ----------------------------------------- -- NAND gate -- -- two descriptions provided ----------------------------------------- library ieee; use ieee.std_logic_1164.all; ------------------------------------------ entity NAND_ent is port( x: in std_logic; y: in std_logic; F: out std_logic ); end NAND_ent; ------------------------------------------ architecture behv1 of NAND_ent is begin process(x, y) begin -- compare to truth table if (x='1' and y='1') then F <= '0'; else F <= '1'; end if; end process; end behv1;
  • 6. ----------------------------------------- architecture behv2 of NAND_ent is begin F <= x nand y; end behv2; Sample Waveform Output: - NOR Gate:- Source Code: - ----------------------------------------- -- NOR gate -- -- two descriptions provided ----------------------------------------- library ieee; use ieee.std_logic_1164.all; ----------------------------------------- entity NOR_ent is port( x: in std_logic; y: in std_logic; F: out std_logic );
  • 7. end NOR_ent; ------------------------------------------ architecture behv1 of NOR_ent is begin process(x, y) begin -- compare to truth table if (x='0' and y='0') then F <= '1'; else F <= '0'; end if; end process; end behv1; architecture behv2 of NOR_ent is begin F <= x nor y; end behv2; Sample Waveform Output: - XOR Gate:-
  • 8. Source Code: - -------------------------------------- -- XOR gate -- -- two descriptions provided -------------------------------------- library ieee; use ieee.std_logic_1164.all; -------------------------------------- entity XOR_ent is port( x: in std_logic; y: in std_logic; F: out std_logic ); end XOR_ent; -------------------------------------- architecture behv1 of XOR_ent is begin process(x, y) begin -- compare to truth table if (x/=y) then F <= '1'; else F <= '0'; end if; end process;
  • 9. end behv1; architecture behv2 of XOR_ent is begin F <= x xor y; end behv2; Sample Waveform Output: - XNOR Gate:- Source Code: - -------------------------------------- -- XOR gate -- -- two descriptions provided -------------------------------------- library ieee; use ieee.std_logic_1164.all; -------------------------------------- entity XNOR_ent is port( x: in std_logic; y: in std_logic; F: out std_logic
  • 10. ); end XNOR_ent; --------------------------------------- architecture behv1 of XNOR_ent is begin process(x, y) begin -- compare to truth table if (x/=y) then F <= '0'; else F <= '1'; end if; end process; end behv1; architecture behv2 of XNOR_ent is begin F <= x xnor y; end behv2; --------------------------------------- Sample Waveform Output: -
  • 11. Q 2:– Write VHDL Programs for the following and check simulation – 1. Half Adder 2. Full Adder Solution: - Half Adder:- Source Code: - -- ============================================================================= -- file name is : ha (ha=half adder) -- Author : Soumya -- ============================================================================= library ieee; use ieee.std_logic_1164.ALL; use ieee.std_logic_unsigned.ALL; entity ha is port (X : in std_logic; Y : in std_logic; Z : out std_logic; -- sum out of X+Y C : out std_logic -- carry out from X+Y ); end ha; -- ============================================================================= -- ============================================================================= architecture rtl of ha is -- ============================================================================= begin Z <= (X XOR Y); C <= X AND Y; -- the logical operator "AND" and "XOR" is defined in VHDL. end rtl; Sample Waveform Output: - Full Adder:- Source Code: - -- ============================================================================= -- file name is : fa (fa=full adder) -- Author : Soumya -- =============================================================================
  • 12. library ieee; use ieee.std_logic_1164.ALL; -- can be different dependent on tool used. use ieee.std_logic_unsigned.ALL; -- can be different dependent on tool used. entity fa is port (a : in std_logic; b : in std_logic; c_in : in std_logic; sum : out std_logic; -- sum out of X+Y c_out : out std_logic -- carry out ); end fa; -- ============================================================================= -- ============================================================================= architecture rtl of fa is -- Define internal signals signal sum_low : std_logic; signal c_low : std_logic; signal c_high : std_logic; -- Define the entity of the half adder to instansiate component ha -- "ha" must be same name as used in the entity for the file port (X : in std_logic; Y : in std_logic; Z : out std_logic; -- sum out of X+Y C : out std_logic -- carry out ); end component; --------- end of entity for ha ---------- -- ============================================================================= begin ha_low : ha port map ( -- ha-side fa-side X => a, Y => b, Z => sum_low, C => c_low ); --------- end of port map for "ha_low" ---------- ha_high : ha port map ( -- ha-side fa-side X => sum_low, Y => c_in, Z => sum, C => c_high ); --------- end of port map for "ha_high" ---------- c_out <= (c_low OR c_high); end rtl;
  • 14. Q 3:– Write VHDL Programs for the following and check simulation – 1. Multiplexer 2. Demultiplexer Solution: - Multiplexer (4 X 1):- Source Code: - ------------------------------------------------- -- VHDL code for 4:1 multiplexor -- Multiplexor is a device to select different -- inputs to outputs. we use 3 bits vector to -- describe its I/O ports ------------------------------------------------- library ieee; use ieee.std_logic_1164.all; ------------------------------------------------- entity Mux is port( I3: in std_logic_vector(2 downto 0); I2: in std_logic_vector(2 downto 0); I1: in std_logic_vector(2 downto 0); I0: in std_logic_vector(2 downto 0); S: in std_logic_vector(1 downto 0); O: out std_logic_vector(2 downto 0) ); end Mux; ------------------------------------------------- architecture behv1 of Mux is begin process(I3,I2,I1,I0,S) begin
  • 15. -- use case statement case S is when "00" => O <= I0; when "01" => O <= I1; when "10" => O <= I2; when "11" => O <= I3; when others => O <= "ZZZ"; end case; end process; end behv1; architecture behv2 of Mux is begin -- use when.. else statement O <= I0 when S="00" else I1 when S="01" else I2 when S="10" else I3 when S="11" else "ZZZ"; end behv2; Sample Waveform Output: -
  • 16. Demultiplexer (1 X 4):- Source Code: - library ieee; use ieee.std_logic_1164.all; entity Demux_4_to_1 is port( E : in std_logic; -- the signal source S0, S1 : in std_logic; -- the selector switches D0, D1, D2, D3 : out std_logic);-- the output data lines end Demux_4_to_1; -- architecture Func of Demux_4_to_1 is component andGate is --import AND Gate entity port( A, B, C : in std_logic; F : out std_logic); end component; component notGate is --import NOT Gate entity port( inPort : in std_logic; outPort : out std_logic);
  • 17. end component; signal invOut0, invOut1 : std_logic; begin --Just like the real circuit, there are --four components: G1 to G4 GI1: notGate port map(S0, invOut0); GI2: notGate port map(S1, invOut1); GA1: andGate port map(E, invOut1, invOut0, D0); -- D0 GA2: andGate port map(E, S0, invOut1, D1); -- D1 GA3: andGate port map(E, invOut0, S1, D2); -- D2 GA4: andGate port map(E, S0, S1, D3); -- D3 end Func; ---------------------------------------------------------END ---------------------------------------------------------END Sample Waveform Output: -
  • 18. Q 4:– Write VHDL Programs for the following and check simulation – 1. Decoder 2. Encoder Solution: - DECODER (2 to 4 line):- Source Code: - library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity decoder is port( input : in std_logic_vector(2 downto 0); --3 bit input output : out std_logic_vector(7 downto 0) -- 8 bit ouput ); end decoder; architecture arch of decoder is begin output(0) <= (not input(2)) and (not input(1)) and (not input(0)); output(1) <= (not input(2)) and (not input(1)) and input(0); output(2) <= (not input(2)) and input(1) and (not input(0)); output(3) <= (not input(2)) and input(1) and input(0); output(4) <= input(2) and (not input(1)) and (not input(0)); output(5) <= input(2) and (not input(1)) and input(0); output(6) <= input(2) and input(1) and (not input(0)); output(7) <= input(2) and input(1) and input(0); end arch; Sample Waveform Output: -
  • 19. ENCODER (4 Input Priority Encoder):- Source Code: - library ieee; use ieee.std_logic_1164.all; entity Encoder_8x3 is port(d0,d1,d2,d3,d4,d5,d6,d7:in std_logic; a0,a1,a2:out std_logic); end Encoder_8x3; architecture arch of Encoder_8x3 is begin a2<= d4 or d5 or d6 or d7; a1<= d2 or d3 or d6 or d7; a0<= d1 or d3 or d5 or d7; end arch; Sample Waveform Output: -
  • 20.
  • 21. Q 5:– Write a VHDL Program for a Comparator and check the simulation. Solution: - COMPARATOR:- Source Code: - LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_arith.all ; ENTITY compare IS PORT ( A, B : IN SIGNED(3 DOWNTO 0) ; AeqB, AgtB, AltB : OUT STD_LOGIC ) ; END compare ; ARCHITECTURE Behavior OF compare IS BEGIN AeqB <= '1' WHEN A = B ELSE '0' ; AgtB <= '1' WHEN A > B ELSE '0' ; AltB <= '1' WHEN A < B ELSE '0' ; END Behavior ; Sample Waveform Output: -
  • 22. Q 6:– Write a VHDL Program for a Code Convertor and check the simulation. Solution: - BCD to BINARY CODE CONVERTOR:- Source Code: - library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity BCD2BIN is Port ( bcd : in STD_LOGIC_VECTOR (4 downto 0); binary : out STD_LOGIC_VECTOR (3 downto 0)); end BCD2BIN; architecture Behavioral of BCD2BIN is begin process (bcd) begin case bcd is when "00000" => binary <= "0000"; when "00001" => binary <= "0001"; when "00010" => binary <= "0010"; when "00011" => binary <= "0011"; when "00100" => binary <= "0100"; when "00101" => binary <= "0101"; when "00110" => binary <= "0110"; when "00111" => binary <= "0111"; when "01000" => binary <= "1000"; when "01001" => binary <= "1001"; when "10000" => binary <= "1010"; when "10001" => binary <= "1011"; when "10010" => binary <= "1100"; when "10011" => binary <= "1101"; when "10100" => binary <= "1110"; when "10101" => binary <= "1111";
  • 23. when others => binary <= "XXXX"; end case; end process; end Behavioral; Sample Waveform Output: -
  • 24. Q 7:– Write a VHDL Program for a Flip-Flop and check the simulation. Solution: - JK FLIP FLOP:- Source Code: - library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity jk is Port ( J : in STD_LOGIC; K : in STD_LOGIC; clock : in STD_LOGIC; reset : in STD_LOGIC; Q : out STD_LOGIC; Qbar : out STD_LOGIC); end jk; architecture Behavioral of jk is signal state: std_logic; signal input: std_logic_vector(1 downto 0); begin input <= J & K; p: process(clock, reset) is begin if (reset='1') then state <= '0'; elsif (rising_edge(clock)) then case (input) is when "11" => state <= not state; when "10" => state <= '1'; when "01" => state <= '0';
  • 25. when others => null; end case; end if; end process; Q <= state; Qbar <= not state; end Behavioral; Sample Waveform Output: -
  • 26. Q 8:– Write a VHDL Program for a Counter and check the simulation. Solution: - N BIT COUNTER:- Source Code: - ---------------------------------------------------- -- VHDL code for n-bit counter -- -- this is the behavior description of n-bit counter -- another way can be used is FSM model. ---------------------------------------------------- library ieee ; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; ---------------------------------------------------- entity counter is generic(n: natural :=2); port( clock: in std_logic; clear: in std_logic; count: in std_logic; Q: out std_logic_vector(n-1 downto 0) ); end counter; ---------------------------------------------------- architecture behv of counter is signal Pre_Q: std_logic_vector(n-1 downto 0); begin -- behavior describe the counter process(clock, count, clear) begin if clear = '1' then Pre_Q <= Pre_Q - Pre_Q; elsif (clock='1' and clock'event) then if count = '1' then Pre_Q <= Pre_Q + 1; end if; end if; end process; -- concurrent assignment statement Q <= Pre_Q; end behv; Sample Waveform Output: -
  • 27.
  • 28. Q 9:– Write VHDL Programs for the following and check simulation – 1. Register 2. Shift Register Solution: - N-Bit Register:- Source Code: - --------------------------------------------------- -- n-bit Register (ESD book figure 2.6) -- -- KEY WORD: concurrent, generic and range --------------------------------------------------- library ieee ; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; --------------------------------------------------- entity reg is generic(n: natural :=2); port( I: in std_logic_vector(n-1 downto 0); clock: in std_logic; load: in std_logic; clear: in std_logic; Q: out std_logic_vector(n-1 downto 0) ); end reg; ---------------------------------------------------- architecture behv of reg is signal Q_tmp: std_logic_vector(n-1 downto 0); begin process(I, clock, load, clear) begin if clear = '0' then -- use 'range in signal assigment Q_tmp <= (Q_tmp'range => '0'); elsif (clock='1' and clock'event) then if load = '1' then Q_tmp <= I; end if; end if; end process;
  • 29. -- concurrent statement Q <= Q_tmp; end behv; --------------------------------------------------- Sample Waveform Output: - 3-Bit Shift Register:- Source Code: - --------------------------------------------------- -- 3-bit Shift-Register/Shifter -- -- reset is ignored according to the figure --------------------------------------------------- library ieee ; use ieee.std_logic_1164.all; --------------------------------------------------- entity shift_reg is port( I: in std_logic; clock: in std_logic; shift: in std_logic; Q: out std_logic ); end shift_reg; --------------------------------------------------- architecture behv of shift_reg is -- initialize the declared signal signal S: std_logic_vector(2 downto 0):="111"; begin
  • 30. process(I, clock, shift, S) begin -- everything happens upon the clock changing if clock'event and clock='1' then if shift = '1' then S <= I & S(2 downto 1); end if; end if; end process; -- concurrent assignment Q <= S(0); end behv; Sample Waveform Output: -
  • 31. PRACTICAL FILE DIGITAL SYSTEM DESIGN LAB Softwares Used – 1. Xilinx 13.4 2. ActiveHDL 7.2 SE Submitted To:- Submitted By:- Mr. Manoj Ahlawat Soumya S. Behera Asst. Professor 1826 6th Semester, CSE UIET, Mdu, Rohtak