SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
http://www.bized.co.uk




                                   Session 2


Prepared by
          Alaa Salah Shehata
          Mahmoud A. M. Abd El Latif
          Mohamed Mohamed Tala’t
          Mohamed Salah Mahmoud

                                                     Version 02 – October 2011
                                                  Copyright 2006 – Biz/ed
Session 2

                            http://www.bized.co.uk



Refresh Your Memory
                Session-2




                                             2
                               Copyright 2006 – Biz/ed
Session 2

                                                            http://www.bized.co.uk



Refresh Your Memory              Answer
    library IEEE;
    USE ieee.std_logic_1164.all;

    Entity    AND_GATE     is
    Port (
        X1       :   in    std_logic_vector(4 downto 0 );
        X2       :   in    std_logic_vector(4 downto 0 );
        Y        :   out   std_logic_vector(4 downto 0 )
        );
    END AND_GATE;

    Architecture Behave of AND_GATE IS
    begin
                         Y <= X1 AND X2 ;
    END Behave ;




                                                                             3
                                                               Copyright 2006 – Biz/ed
http://www.bized.co.uk




                                             2
           - Demo no. 2
                  SPARTON_3 FPGA starter board

Contents   - Combinational vs Sequential

           -Data Objects
                  -Signals

           -VHDL Statements
               -Sequential Statements
                   -What is Process
                   -IF Statement
                   -CASE Statement
           -Combinational Logic
           -Sequential Logic


                                                 4
                                  Copyright 2006 – Biz/ed
Session 2

                           http://www.bized.co.uk




Xilinx Spartan 3-FPGA Starter Board


                                            5
                              Copyright 2006 – Biz/ed
Session 2

            http://www.bized.co.uk




                             6
               Copyright 2006 – Biz/ed
Session 2

                                                             http://www.bized.co.uk


Combinational Vs. Sequential logic circuit

 in any digital system we can divide the circuits into two
 types :



 Combinational logic circuits
 implement Boolean functions, so the output in this
 circuits is function only on their inputs, and are not
 based on clocks.



 Sequential circuits
 compute their output based on input and state, and that
 the state is updated based on a clock.



                                                                              7
                                                                Copyright 2006 – Biz/ed
Session 2

                                                                   http://www.bized.co.uk


Signals

 Signals used to connect between systems or connect components inside systems

 Types of signals
           --External Signals
                     -In,Out ports
                     -Internal connections in structuraldiscussed later
           --Internal Signals
                      -connect devices inside the block
                      -used for Intermediate calculations
 Note
 We use Internal Signals for:
          Avoid illegal port usage situations like Read Output port




                                                                                     8
                                                                       Copyright 2006 – Biz/ed
Session 2

                                                       http://www.bized.co.uk


Signals

Signal declaration

        architecture <arch_name> of <entity_name> is
               -- architecture declarations
        signal <sig_name> : <sig_type>;
                       .
                       .
                       .
        begin

                <Architecture body>

        End <arch_name> ;




                                                                        9
                                                          Copyright 2006 – Biz/ed
Session 2

                             http://www.bized.co.uk



• NAND Gate




A
              C     D
B                       Example
                           5




                                               10
                                  Copyright 2006 – Biz/ed
Session 2

                                               http://www.bized.co.uk


NAND Gate
     LIBRARY ieee;
     USE ieee.std_logic_1164.all;
                                        A
     ENTITY NAND_GATE IS                       C                     D
       port ( A       : in STD_LOGIC;
              B       : in STD_LOGIC;
                                           B
              D       : out STD_LOGIC
              );
     END ENTITY NAND_GATE ;

     ARCHITECTURE behave OF NAND_GATE IS

              SIGNAL C : std_logic;

     BEGIN
               C <= A and B ;
               D <= not C   ;
     END behave;

                                                                11
                                                   Copyright 2006 – Biz/ed
Session 2

                                                         http://www.bized.co.uk




• Write the VHDL code for this logic circuit




A
                                     D
B                                                  Exercise
                                                      1
C


D                                              F

                                                                           12
                                                              Copyright 2006 – Biz/ed
Session 2

                                                       http://www.bized.co.uk


Write the VHDL code for this logic circuit
                                           A
    LIBRARY ieee;
    USE ieee.std_logic_1164.all;                       SIG_1          G
                                           B
    ENTITY NAND_GATE IS
      port ( A,B,C,D : in STD_LOGIC;
             G,F     : out STD_LOGIC
             );
    END ENTITY NAND_GATE ;                     C                 SIG_2
    ARCHITECTURE behave OF NAND_GATE IS

             SIGNAL SIG_1     : std_logic;                                      F
             SIGNAL SIG_2     : std_logic;         D
    BEGIN
              SIG_1     <=     A and B ;
              SIG_2     <= SIG_1 and C ;
              F         <= SIG_2 and D ;
              G         <= SIG_1 ;
    END behave;

                                                                       13
                                                          Copyright 2006 – Biz/ed
Session 2

                                              http://www.bized.co.uk


•VHDL has concurrent statements
        and sequential statements

•Concurrent statements are executed
        in parallel w.r.t each other.
        With – select
        When – else
        Process statement
        Assign statement

•Sequential statements are executed
        in sequence w.r.t each other.
                                        Statements
•Sequential statements should be
         written inside a “process”

         If statement
         loop statement
         Case statement
         Wait and Null statement

                                                              14
                                                 Copyright 2006 – Biz/ed
Session 2

                                                                 http://www.bized.co.uk


Process

-What is a Process
          Process allows writing sequential statements within concurrent environment
          Process is like a container that include the sequential statements
Process declaration

process (sensitivity list)
begin
         sequential statements ;
end process ;


Note
<sensitivity_list>:
           List of signals/ports that cause the process to be executed whenever there is a
change in their values



                                                                                  15
                                                                     Copyright 2006 – Biz/ed
Session 2

                                                             http://www.bized.co.uk


Process
 Architecture behave of comb_ct is
 Begin
    process (x,y)
    begin
        z <= x and y;
        h <= x or y;
        t <= x xor y;
                …

    end process;
 End behave ;

 Statements inside a “process” are read sequentially and executed
   when the process suspends (“end process” is reached)

 very important note:

 What is this statement differs from   z<= x and y;


                                                                             16
                                                                Copyright 2006 – Biz/ed
Session 2

                                                                http://www.bized.co.uk


Question

  Statements shown at left are inside a process and at right are outside it what
  is the result in the two cases



  Process ()
  begin
        A <= B ;                                A <= B ;
        A <= C ;                                A <= C ;
  end



                                                                                   17
                                                                    Copyright 2006 – Biz/ed
Session 2

                                                                http://www.bized.co.uk


Question

  Statements shown at left are inside a process and at right are outside it what
  is the result in the two cases


  Architecture                         Architecture
  Process ()                           begin
  begin                                        A <= B ;
          A <= B ;                             A <= C ;
          A <= C ;                     end
  end
  end
       B                                            B
                    A
                                                               A
       C            A                               C
                                                                                   18
                                                                    Copyright 2006 – Biz/ed
Session 2

                                                                http://www.bized.co.uk


Question

  Statements shown at left are inside a process and at right are outside it what
  is the result in the two cases



  Process ()
  begin
        A <= B ;                                A <= B ;
        B <= A ;                                B <= A ;
  end



                                                                                   19
                                                                    Copyright 2006 – Biz/ed
Session 2

                                                                http://www.bized.co.uk


IF Statement
 Executes a list of sequential statements when the corresponding condition
 evaluates to true

 V.IMPORTANT ROLE
         The branches order is important as they imply a priority
 Syntax
         If <condition> then
                          -- list of sequential statements
         elsif <condition> then
                          -- list of sequential statements
         else
                  -- list of sequential statements
         end if;

 <condition> Boolean expression that evaluates to either TRUE or FALSE


                                                                                 20
                                                                    Copyright 2006 – Biz/ed
Session 2

                                               http://www.bized.co.uk



• Adder/Subtractor




 A
                                 Result
  B           Adder_Subtractor
                                          Example
                                             6
                Operation

      Operation =1  a+b
      Operation =0  a-b


                                                                 21
                                                    Copyright 2006 – Biz/ed
Session 2

                                                         http://www.bized.co.uk


Adder/Subtractor
      LIBRARY ieee;
      USE ieee.std_logic_1164.all;
      USE ieee.std_logic_arith.all;
      ENTITY add_sub IS
        port ( a, b             : in integer;
               result           : out integer;
               operation        : in std_logic); -- add or subtract
      END ENTITY add_sub;
      ARCHITECTURE behave OF add_sub IS
        BEGIN
          process (         a, b, operation
                      What is sensitivity list !! )
          begin
               if (operation = '1') then        -- Add when operation = '1'
                        result <= a + b;
               else                             -- Subtract otherwise
                       result <= a - b;
               end if;
          end process;
      END ARCHITECTURE behave;
                                                                         22
                                                            Copyright 2006 – Biz/ed
Session 2

                                                         http://www.bized.co.uk


Adder/Subtractor
      LIBRARY ieee;
      USE ieee.std_logic_1164.all;
      USE ieee.std_logic_arith.all;
      ENTITY add_sub IS
        port ( a, b             : in integer;
               result           : out integer;
               operation        : in std_logic); -- add or subtract
      END ENTITY add_sub;
      ARCHITECTURE behave OF add_sub IS
        BEGIN
          process (         a, b, operation      )
          begin
               if (operation = '1') then        -- Add when operation = '1'
                        result <= a + b;
               else                             -- Subtract otherwise
                       result <= a - b;
               end if;
          end process;
      END ARCHITECTURE behave;
                                                                         23
                                                            Copyright 2006 – Biz/ed
Session 2

                                     http://www.bized.co.uk




• Simple Comparator




   A
                            C
   B           Comparator
                                Example
                                   7

         A=B C=“00”
         A>B C=“01”
         A<B C=“10”
                                                       24
                                          Copyright 2006 – Biz/ed
Session 2

                                                        http://www.bized.co.uk


Simple Comparator
LIBRARY ieee;
USE ieee.std_logic_1164.all;

ENTITY comparator IS
   port( a, b     : in std_logic_vector(7 downto 0);
         c        : out std_logic_vector(1 downto 0);
                  );
END ENTITY;
ARCHITECTURE behave OF comparator IS
BEGIN
  process (a, b)
  begin
    if (A = B ) then      -- equality
      c <= "00";
    elsif (A > B) then -- greater than
      c <= "01";
    elsif (A < B) then -- greater than
      c <= "10";
    else                 -- covers other cases
      c <= “ZZ";
    end if;
  end process;
END ARCHITECTURE;
                                                                        25
                                                           Copyright 2006 – Biz/ed
Session 2

                                                             http://www.bized.co.uk


CASE Statement

Makes several conditions on the same signal

Syntax


         case <expression> is
                 when <choice> =>
                          -- list of sequential statements
                 when <choice> =>
                          -- list of sequential statements
                 when others =>
                         -- list of sequential statements
          end case;

                                                                             26
                                                                Copyright 2006 – Biz/ed
Session 2

                                                                http://www.bized.co.uk


CASE Statement



<expression> can be a signal or a variable (discussed later)

<choice> constants representing one of possible <expression> values.

V.IMPORTANT ROLE

-“When others” is a must if not all values of <expression> are covered

-Each branch of a Case statement can have any number of sequential statements




                                                                                 27
                                                                    Copyright 2006 – Biz/ed
Session 2

                            http://www.bized.co.uk



• 4 x 1 Multiplexer




                       Example
                          8




                                              28
                                 Copyright 2006 – Biz/ed
Session 2

                                                                    http://www.bized.co.uk


4 x 1 Multiplexer

  Architecture rtl of mux_case is
  begin
    process (a,b,c,d,sel)
  begin
  Case sel is
    When "00" =>
           f <= a;
    When "01" =>
           f <= b;                    Do we need all these signals? On sensitivity list ??
    When "10" =>
           f <= c;
    When "11" =>
           f <= d;
    when others =>   -- is "when others" a must?
           f <= „Z‟;
  End case;
    End process;
  End architecture;
                                                                                      29
                                                                         Copyright 2006 – Biz/ed
Session 2

                                             http://www.bized.co.uk




• Simulate 2 x 4 Decoder on Modelsim




                                       lab
                                        1




                                                             30
                                                Copyright 2006 – Biz/ed
Session 2

                                          http://www.bized.co.uk


2 x 4 Decoder
    Architecture rtl of dec is
    begin
      process (a)
      begin
    Case a is
      When "00" =>
             f <= “0001”;
      When "01" =>
              f <= “0010”;
      When "10" =>
              f <= “0100”;
      When "11" =>
              f <= “1000”;
      when others =>
              f <= “ZZZZ”;
    End case;
      End process;
    End rtl ;                    How to make 4 x 2 Encoder !
                                                           31
                                              Copyright 2006 – Biz/ed
Session 2

                                                                  http://www.bized.co.uk

                                     1-Area Optimization

During writing a code for implementation you must save your resources

Example
         Write a code describing this Adder



                          OpSel                        Function
                           00                            A+B
                           01                            C+D
                           10                            E+F
                           11                            G+H
Note that the selector can select one addition at a time, the operators are mutually
exclusive

                                                                                   32
                                                                      Copyright 2006 – Biz/ed
Session 2

                                                                    http://www.bized.co.uk




It is better to write a code that describe the circuit on the right as adders take much bigger
area than multiplexers
his transformation of operators is called Resource Sharing

                                                                                     33
                                                                        Copyright 2006 – Biz/ed
Session 2

                                                                 http://www.bized.co.uk




Possible solutions
 Solution 1
process (OpSel,A,B,C,D,E,F,G,H)
begin
         case OpSel is
                  when "00" => Z   <= A   + B ;
                  when "01" => Z   <= C   + D ;
                  when "10" => Z   <= E   + F ;
                  when "11" => Z   <= G   + H ;
                  when others =>   Z <=   (others => 'X') ;
         end case ;
end process ;

Here the code is Tool Driven Resource Sharing, the tool understand that we don’t need to
make four adders and one Adder is implemented.

General Note
To ensure resource sharing, operators must be coded in the same process, and same code
(case or if) structure.
                                                                                  34
                                                                     Copyright 2006 – Biz/ed
Session 2

                                                                           http://www.bized.co.uk




  Solution 2
X <= Mux4(OpSel, A, C, E, G) ;
Y <= Mux4(OpSel, B, D, F, H) ;
Z <= X + Y ;

Here the code is Code Driven Resource Sharing, You forced the tool to use only one Adder.


  Solution 3
Process (OpSel, A,    B, C, D, E, F, G, H)
begin
         if (OpSel    =   "00")   then   Z   <=   A   +   B;   end   if;
         if (OpSel    =   "01")   then   Z   <=   C   +   D;   end   if;
         if (OpSel    =   "10")   then   Z   <=   E   +   F;   end   if;
         if (OpSel    =   "11")   then   Z   <=   G   +   H;   end   if;
end process ;

Bad Code that may defeat Resource Sharing.
Synthesis tool may create a separate resource for each adder.              Don’t do that!
                                                                                             35
                                                                                Copyright 2006 – Biz/ed
Session 2

                                                                    http://www.bized.co.uk


Sequential Circuits



  Clock period

A digital clock signal is a square wave voltage.
In complex circuits a clock with a fixed frequency is used for timing.
To store and pass the data or digital signals through, some specific gates are used which
are called latches or flip-flops. These are some kind of memory that store their input over
their output by a specific level or edge of the clock.

Asynchronous Operation
        don’t wait clock
Synchronous
        wait clock to get an input and to produce an output


                                                                                     36
                                                                        Copyright 2006 – Biz/ed
Session 2

                                                             http://www.bized.co.uk



D-Flip Flop

                                        D
                                                                         Q
Reset         Clk        Enable   Q+
                                        Reset         D_FF
  1            -           -      0
  0     No rising_edge     -      Q     enable
  0       Rising_edge      0      Q
  0       Rising_edge      1      D
                                                clk



Asynchronous reset
Synchronous enable
                                       Clock period

                                                                             37
                                                                Copyright 2006 – Biz/ed
Session 2

                                  http://www.bized.co.uk



• Simple D-Flip Flop




  D
                         Q
                  D_FF
                             Example
                                9

        clk



                                                    38
                                       Copyright 2006 – Biz/ed
Session 2

                                                                  http://www.bized.co.uk


Simple D-FF
 Library ieee;
 use ieee.std_logic_1164.all;

 Entity d_ff is
    Port( D, clk     : in std_logic;
          Q          : out std_logic );
 end entity;

 Architecture behav of d_ff is

 Begin
    process(clk)
    begin
                                          rising_edge() : defined for std_logic type
           if rising_edge(clk) then
                   Q <= D;
           end if;
    end process;

 end behav;




                                                                                        39
                                                                       Copyright 2006 – Biz/ed
Session 2

                                     http://www.bized.co.uk


• D-FF
  with Asynchronous reset




 D
                            Q
 Reset           D_FF
                                Example
                                   10

        clk



                                                       40
                                          Copyright 2006 – Biz/ed
Session 2

                                                                http://www.bized.co.uk


D-FF with Asynchronous reset
 Library ieee;
 use ieee.std_logic_1164.all;

 Entity d_ff is
    Port( d, clk, rst : in std_logic;
          Q : out std_logic);
 end entity;
 Architecture behav of d_ff is

 Begin
    process(clk, rst)
    begin
       If (rst = '1') then              Since rst has higher priority over the clk edge
          Q <= '0';                     We put it on sensitivity list
       elsif rising_edge(clk) then
          Q <= d;                       We have now a D Flip Flop with asynchronous
       end if;                          reset
    end process;

 end behav;


                                                                                  41
                                                                    Copyright 2006 – Biz/ed
Session 2

                                     http://www.bized.co.uk


• D-FF
  with Asynchronous reset
  and Synchronous enable




   D
                            Q
   Reset          D_FF
                                Example
   enable                          11

         clk



                                                       42
                                          Copyright 2006 – Biz/ed
Session 2

                                                                     http://www.bized.co.uk


D-FF with Asynchronous reset and Synchronous enable
 Library ieee;
 use ieee.std_logic_1164.all;
                                                Reset           Clk         Enable     Q+
 Entity d_ff is
                                                  1              -              -        0
    Port( d, clk, rst,en   : in std_logic;
          Q                : out std_logic        0      No rising_edge         -       Q
          );                                      0        Rising_edge          0       Q
 end entity;                                      0        Rising_edge          1       D

 Architecture behav of d_ff is
 Begin
    process(clk, rst)
    begin
       If (rst = '1') then               Enable has lower priority w.r.t the clk edge
            Q <= '0';                    So we don’t put it in sensitivity list as it will slow the
       elsif rising_edge(clk) then       simulation
            If (en = '1') then
                Q <= d;
            end if;                      We have now a D Flip Flop with asynchronous
       end if;                           reset and synchronous enable
    end process;
 end behav;
                                                                                        43
                                                                         Copyright 2006 – Biz/ed
Session 2

                                                                    http://www.bized.co.uk

D-Latch vs D-Flip Flop

With a latch, a signal can’t propagate through until the clock is high .

With a Flip-flop, the signal only propagates through on the rising edge.




                                                                                        44
                                                                           Copyright 2006 – Biz/ed
Session 2

                                      http://www.bized.co.uk




• D_Latch (positive level)




   D
                             Q
   Reset            D_FF
                                 Example
   enable                           12

          clk



                                                        45
                                           Copyright 2006 – Biz/ed
Session 2

                                          http://www.bized.co.uk


D-Latch with Asynchronous reset and Synchronous enable
 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;

 entity d_ff is
 port( clk,reset,enable: in std_logic;
                  d: in std_logic;
                  q: out std_logic);
 end d_ff;

 architecture Behavioral of d_ff is
 begin
   process(clk,reset,d)
   begin
          if reset = '1' then
                   q<= '0';
          elsif clk = '1' then
                   if enable = '1' then
                            q<= d;
                   end if;
          end if;
   end process;
 end Behavioral;
                                                          46
                                             Copyright 2006 – Biz/ed
Session 2

                                                                 http://www.bized.co.uk




Assignment
                                                Session-2
Write a code describing a T-Flip Flop
                                                     T
If the T input is high, the T flip-flop changes                                  Q
state ("toggles") whenever the clock input is
stored. If the T input is low, the flip-flop holds   Reset     D_FF
the previous value.                                                              Q’


                                                         clk
                                                                                   47
                                                                      Copyright 2006 – Biz/ed
Session 2

                  http://www.bized.co.uk




Mini Project-1




                                  48
                     Copyright 2006 – Biz/ed
Session 2

                                                                   http://www.bized.co.uk



ALU Arithmetic Logic Unit
It is a circuit capable of executing both kinds of operations, arithmetic as well as
logical.
Its operation is described next slide as follow :
            The output (arithmetic or logical) is selected by the MSB of sel
            The specific operation is selected by sel’s other three bits.




                                                                                       49
                                                                       Copyright 2006 – Biz/ed
Session 2

                                         http://www.bized.co.uk

Sel        Operation      Function                     Unit
0000       Y<= a          Transfer A
0001       Y<= a+1        Increment A
0010       Y<= a-1        Decrement A
0011       Y<= b          Transfer B
                                                       Athematic
0100       Y<= b+1        Increment A
0101       Y<= b-1        Decrement A
0110       Y<= a+b        Add a and b
0111       Y<= a+b+cin    Add a and b and carry
1000       Y<= not a      Complement a
1001       Y<= not b      Complement b
1010       Y<= a AND b    AND
1011       Y<= a OR b     OR
                                                          logic
1100       Y<= a NAND b   NAND
1101       Y<= a NOR b    NOR
1110       Y<= a XOR b    XOR
1111       Y<= a XNOR b   XNOR

                                                          50
                                             Copyright 2006 – Biz/ed
Session 2

                                            http://www.bized.co.uk




Required
     -VHDL code of this ALU
     -Verify functionality using Modelsim


Deadline
     -Next session




                                                            51
                                               Copyright 2006 – Biz/ed
Session 2

                                         http://www.bized.co.uk

Download Session 2 material



        Session 2.pdf

        Modelsim tuotorial.pdf

        Xilinx ISE tuotorial.pdf

        lab1.txt




Ask for the material through mail
          start.courses@gmail.com

Facebook group
       start.group@groups.facebook.com


                                                         52
                                            Copyright 2006 – Biz/ed
Session 2

                             http://www.bized.co.uk




Questions
                 Session-2




                                             53
                                Copyright 2006 – Biz/ed
Session 2

                                                                                                      http://www.bized.co.uk

Take Your Notes
              Print the slides and take your notes here

---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
                                                                                                                              54
                                                                                                           Copyright 2006 – Biz/ed
Session 2

                       http://www.bized.co.uk




See You Next Session




                                       55
                          Copyright 2006 – Biz/ed

Contenu connexe

Tendances

vlsi design summer training ppt
vlsi design summer training pptvlsi design summer training ppt
vlsi design summer training pptBhagwan Lal Teli
 
Vlsi & embedded systems
Vlsi & embedded systemsVlsi & embedded systems
Vlsi & embedded systemsDeepak Yadav
 
Vlsi Summer training report pdf
Vlsi Summer training report pdfVlsi Summer training report pdf
Vlsi Summer training report pdfGirjeshVerma2
 
Session 01 _rtl_design_with_vhdl 101
Session 01 _rtl_design_with_vhdl 101Session 01 _rtl_design_with_vhdl 101
Session 01 _rtl_design_with_vhdl 101Mahmoud Abdellatif
 
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its ApplicationsComplex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its Applicationselprocus
 
ASIC Design and Implementation
ASIC Design and ImplementationASIC Design and Implementation
ASIC Design and Implementationskerlj
 
CV-RENJINIK-27062016
CV-RENJINIK-27062016CV-RENJINIK-27062016
CV-RENJINIK-27062016Renjini K
 
generate IP CORES
generate IP CORESgenerate IP CORES
generate IP CORESguest296013
 
Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...
Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...
Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...Revathi Subramaniam
 
Programmable logic device (PLD)
Programmable logic device (PLD)Programmable logic device (PLD)
Programmable logic device (PLD)Sɐɐp ɐɥɯǝp
 
Short.course.introduction.to.vhdl for beginners
Short.course.introduction.to.vhdl for beginners Short.course.introduction.to.vhdl for beginners
Short.course.introduction.to.vhdl for beginners Ravi Sony
 

Tendances (20)

Vhdl 1 ppg
Vhdl 1 ppgVhdl 1 ppg
Vhdl 1 ppg
 
vlsi design summer training ppt
vlsi design summer training pptvlsi design summer training ppt
vlsi design summer training ppt
 
Spdas2 vlsibput
Spdas2 vlsibputSpdas2 vlsibput
Spdas2 vlsibput
 
VLSI VHDL
VLSI VHDLVLSI VHDL
VLSI VHDL
 
vhdl
vhdlvhdl
vhdl
 
VLSI
VLSIVLSI
VLSI
 
CPLDs
CPLDsCPLDs
CPLDs
 
Vlsi & embedded systems
Vlsi & embedded systemsVlsi & embedded systems
Vlsi & embedded systems
 
Vlsi Summer training report pdf
Vlsi Summer training report pdfVlsi Summer training report pdf
Vlsi Summer training report pdf
 
Session 01 _rtl_design_with_vhdl 101
Session 01 _rtl_design_with_vhdl 101Session 01 _rtl_design_with_vhdl 101
Session 01 _rtl_design_with_vhdl 101
 
Vlsi
VlsiVlsi
Vlsi
 
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its ApplicationsComplex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
 
ASIC Design and Implementation
ASIC Design and ImplementationASIC Design and Implementation
ASIC Design and Implementation
 
CV-RENJINIK-27062016
CV-RENJINIK-27062016CV-RENJINIK-27062016
CV-RENJINIK-27062016
 
generate IP CORES
generate IP CORESgenerate IP CORES
generate IP CORES
 
Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...
Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...
Complex Programmable Logic Devices(CPLD) & Field Programmable Logic Devices (...
 
Fpga
FpgaFpga
Fpga
 
CPLD & FPLD
CPLD & FPLDCPLD & FPLD
CPLD & FPLD
 
Programmable logic device (PLD)
Programmable logic device (PLD)Programmable logic device (PLD)
Programmable logic device (PLD)
 
Short.course.introduction.to.vhdl for beginners
Short.course.introduction.to.vhdl for beginners Short.course.introduction.to.vhdl for beginners
Short.course.introduction.to.vhdl for beginners
 

Similaire à Session two

CMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodologyCMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodologyIkhwan_Fakrudin
 
Lecture Slide (1).pptx
Lecture Slide (1).pptxLecture Slide (1).pptx
Lecture Slide (1).pptxBilalMumtaz9
 
[MakerHN] [IoT] [01] Intro 2
[MakerHN] [IoT] [01] Intro 2[MakerHN] [IoT] [01] Intro 2
[MakerHN] [IoT] [01] Intro 2Công Hoàng Văn
 
57798_Lectures1415.pptx
57798_Lectures1415.pptx57798_Lectures1415.pptx
57798_Lectures1415.pptxSheerazAli55
 
Introduction to Advanced embedded systems course
Introduction to Advanced embedded systems courseIntroduction to Advanced embedded systems course
Introduction to Advanced embedded systems courseanishgoel
 
Chapter 6 : Network layer
Chapter 6 : Network layerChapter 6 : Network layer
Chapter 6 : Network layerteknetir
 
Chapter 06 - Network Layer
Chapter 06 - Network LayerChapter 06 - Network Layer
Chapter 06 - Network LayerYaser Rahmati
 
CCNAv5 - S1: Chapter 6 - Network Layer
CCNAv5 - S1: Chapter 6 - Network LayerCCNAv5 - S1: Chapter 6 - Network Layer
CCNAv5 - S1: Chapter 6 - Network LayerVuz Dở Hơi
 
IRJET- ARGON2id IP Core
IRJET- ARGON2id IP CoreIRJET- ARGON2id IP Core
IRJET- ARGON2id IP CoreIRJET Journal
 
2013 09-02 senzations-bimschas-part2-smart-santander-experimentation
2013 09-02 senzations-bimschas-part2-smart-santander-experimentation2013 09-02 senzations-bimschas-part2-smart-santander-experimentation
2013 09-02 senzations-bimschas-part2-smart-santander-experimentationDaniel Bimschas
 
Testing CAN network with help of CANToolz
Testing CAN network with help of CANToolzTesting CAN network with help of CANToolz
Testing CAN network with help of CANToolzAlexey Sintsov
 
Nobuya Okada presentation
Nobuya Okada presentationNobuya Okada presentation
Nobuya Okada presentationkazu_papasan
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924polyGary Dare
 
ARM uVisor Debug Refinement Project(debugging facility improvements)
ARM uVisor Debug Refinement Project(debugging facility improvements)ARM uVisor Debug Refinement Project(debugging facility improvements)
ARM uVisor Debug Refinement Project(debugging facility improvements)家榮 張
 

Similaire à Session two (20)

Session seven
Session sevenSession seven
Session seven
 
Start group tutorial [2]
Start group tutorial [2]Start group tutorial [2]
Start group tutorial [2]
 
CMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodologyCMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodology
 
Lecture Slide (1).pptx
Lecture Slide (1).pptxLecture Slide (1).pptx
Lecture Slide (1).pptx
 
Session nine
Session nineSession nine
Session nine
 
[MakerHN] [IoT] [01] Intro 2
[MakerHN] [IoT] [01] Intro 2[MakerHN] [IoT] [01] Intro 2
[MakerHN] [IoT] [01] Intro 2
 
57798_Lectures1415.pptx
57798_Lectures1415.pptx57798_Lectures1415.pptx
57798_Lectures1415.pptx
 
Introduction to Advanced embedded systems course
Introduction to Advanced embedded systems courseIntroduction to Advanced embedded systems course
Introduction to Advanced embedded systems course
 
Chapter 6 : Network layer
Chapter 6 : Network layerChapter 6 : Network layer
Chapter 6 : Network layer
 
Chapter 06 - Network Layer
Chapter 06 - Network LayerChapter 06 - Network Layer
Chapter 06 - Network Layer
 
CCNAv5 - S1: Chapter 6 - Network Layer
CCNAv5 - S1: Chapter 6 - Network LayerCCNAv5 - S1: Chapter 6 - Network Layer
CCNAv5 - S1: Chapter 6 - Network Layer
 
IRJET- ARGON2id IP Core
IRJET- ARGON2id IP CoreIRJET- ARGON2id IP Core
IRJET- ARGON2id IP Core
 
2013 09-02 senzations-bimschas-part2-smart-santander-experimentation
2013 09-02 senzations-bimschas-part2-smart-santander-experimentation2013 09-02 senzations-bimschas-part2-smart-santander-experimentation
2013 09-02 senzations-bimschas-part2-smart-santander-experimentation
 
Testing CAN network with help of CANToolz
Testing CAN network with help of CANToolzTesting CAN network with help of CANToolz
Testing CAN network with help of CANToolz
 
Session1pdf
Session1pdfSession1pdf
Session1pdf
 
Syntutic
SyntuticSyntutic
Syntutic
 
Nobuya Okada presentation
Nobuya Okada presentationNobuya Okada presentation
Nobuya Okada presentation
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924poly
 
Session1
Session1Session1
Session1
 
ARM uVisor Debug Refinement Project(debugging facility improvements)
ARM uVisor Debug Refinement Project(debugging facility improvements)ARM uVisor Debug Refinement Project(debugging facility improvements)
ARM uVisor Debug Refinement Project(debugging facility improvements)
 

Plus de Mahmoud Abdellatif (8)

Evaluation test
Evaluation testEvaluation test
Evaluation test
 
Session six
Session sixSession six
Session six
 
Session five
Session fiveSession five
Session five
 
Session four
Session fourSession four
Session four
 
Session three
Session threeSession three
Session three
 
Xilinx ise tutorial-a
Xilinx ise tutorial-aXilinx ise tutorial-a
Xilinx ise tutorial-a
 
Intrduction To The Course
Intrduction To The  CourseIntrduction To The  Course
Intrduction To The Course
 
Intrduction to the course
Intrduction to the courseIntrduction to the course
Intrduction to the course
 

Dernier

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Dernier (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

Session two

  • 1. http://www.bized.co.uk Session 2 Prepared by Alaa Salah Shehata Mahmoud A. M. Abd El Latif Mohamed Mohamed Tala’t Mohamed Salah Mahmoud Version 02 – October 2011 Copyright 2006 – Biz/ed
  • 2. Session 2 http://www.bized.co.uk Refresh Your Memory Session-2 2 Copyright 2006 – Biz/ed
  • 3. Session 2 http://www.bized.co.uk Refresh Your Memory Answer library IEEE; USE ieee.std_logic_1164.all; Entity AND_GATE is Port ( X1 : in std_logic_vector(4 downto 0 ); X2 : in std_logic_vector(4 downto 0 ); Y : out std_logic_vector(4 downto 0 ) ); END AND_GATE; Architecture Behave of AND_GATE IS begin Y <= X1 AND X2 ; END Behave ; 3 Copyright 2006 – Biz/ed
  • 4. http://www.bized.co.uk 2 - Demo no. 2 SPARTON_3 FPGA starter board Contents - Combinational vs Sequential -Data Objects -Signals -VHDL Statements -Sequential Statements -What is Process -IF Statement -CASE Statement -Combinational Logic -Sequential Logic 4 Copyright 2006 – Biz/ed
  • 5. Session 2 http://www.bized.co.uk Xilinx Spartan 3-FPGA Starter Board 5 Copyright 2006 – Biz/ed
  • 6. Session 2 http://www.bized.co.uk 6 Copyright 2006 – Biz/ed
  • 7. Session 2 http://www.bized.co.uk Combinational Vs. Sequential logic circuit in any digital system we can divide the circuits into two types : Combinational logic circuits implement Boolean functions, so the output in this circuits is function only on their inputs, and are not based on clocks. Sequential circuits compute their output based on input and state, and that the state is updated based on a clock. 7 Copyright 2006 – Biz/ed
  • 8. Session 2 http://www.bized.co.uk Signals Signals used to connect between systems or connect components inside systems Types of signals --External Signals -In,Out ports -Internal connections in structuraldiscussed later --Internal Signals -connect devices inside the block -used for Intermediate calculations Note We use Internal Signals for: Avoid illegal port usage situations like Read Output port 8 Copyright 2006 – Biz/ed
  • 9. Session 2 http://www.bized.co.uk Signals Signal declaration architecture <arch_name> of <entity_name> is -- architecture declarations signal <sig_name> : <sig_type>; . . . begin <Architecture body> End <arch_name> ; 9 Copyright 2006 – Biz/ed
  • 10. Session 2 http://www.bized.co.uk • NAND Gate A C D B Example 5 10 Copyright 2006 – Biz/ed
  • 11. Session 2 http://www.bized.co.uk NAND Gate LIBRARY ieee; USE ieee.std_logic_1164.all; A ENTITY NAND_GATE IS C D port ( A : in STD_LOGIC; B : in STD_LOGIC; B D : out STD_LOGIC ); END ENTITY NAND_GATE ; ARCHITECTURE behave OF NAND_GATE IS SIGNAL C : std_logic; BEGIN C <= A and B ; D <= not C ; END behave; 11 Copyright 2006 – Biz/ed
  • 12. Session 2 http://www.bized.co.uk • Write the VHDL code for this logic circuit A D B Exercise 1 C D F 12 Copyright 2006 – Biz/ed
  • 13. Session 2 http://www.bized.co.uk Write the VHDL code for this logic circuit A LIBRARY ieee; USE ieee.std_logic_1164.all; SIG_1 G B ENTITY NAND_GATE IS port ( A,B,C,D : in STD_LOGIC; G,F : out STD_LOGIC ); END ENTITY NAND_GATE ; C SIG_2 ARCHITECTURE behave OF NAND_GATE IS SIGNAL SIG_1 : std_logic; F SIGNAL SIG_2 : std_logic; D BEGIN SIG_1 <= A and B ; SIG_2 <= SIG_1 and C ; F <= SIG_2 and D ; G <= SIG_1 ; END behave; 13 Copyright 2006 – Biz/ed
  • 14. Session 2 http://www.bized.co.uk •VHDL has concurrent statements and sequential statements •Concurrent statements are executed in parallel w.r.t each other. With – select When – else Process statement Assign statement •Sequential statements are executed in sequence w.r.t each other. Statements •Sequential statements should be written inside a “process” If statement loop statement Case statement Wait and Null statement 14 Copyright 2006 – Biz/ed
  • 15. Session 2 http://www.bized.co.uk Process -What is a Process Process allows writing sequential statements within concurrent environment Process is like a container that include the sequential statements Process declaration process (sensitivity list) begin sequential statements ; end process ; Note <sensitivity_list>: List of signals/ports that cause the process to be executed whenever there is a change in their values 15 Copyright 2006 – Biz/ed
  • 16. Session 2 http://www.bized.co.uk Process Architecture behave of comb_ct is Begin process (x,y) begin z <= x and y; h <= x or y; t <= x xor y; … end process; End behave ; Statements inside a “process” are read sequentially and executed when the process suspends (“end process” is reached) very important note: What is this statement differs from z<= x and y; 16 Copyright 2006 – Biz/ed
  • 17. Session 2 http://www.bized.co.uk Question Statements shown at left are inside a process and at right are outside it what is the result in the two cases Process () begin A <= B ; A <= B ; A <= C ; A <= C ; end 17 Copyright 2006 – Biz/ed
  • 18. Session 2 http://www.bized.co.uk Question Statements shown at left are inside a process and at right are outside it what is the result in the two cases Architecture Architecture Process () begin begin A <= B ; A <= B ; A <= C ; A <= C ; end end end B B A A C A C 18 Copyright 2006 – Biz/ed
  • 19. Session 2 http://www.bized.co.uk Question Statements shown at left are inside a process and at right are outside it what is the result in the two cases Process () begin A <= B ; A <= B ; B <= A ; B <= A ; end 19 Copyright 2006 – Biz/ed
  • 20. Session 2 http://www.bized.co.uk IF Statement Executes a list of sequential statements when the corresponding condition evaluates to true V.IMPORTANT ROLE The branches order is important as they imply a priority Syntax If <condition> then -- list of sequential statements elsif <condition> then -- list of sequential statements else -- list of sequential statements end if; <condition> Boolean expression that evaluates to either TRUE or FALSE 20 Copyright 2006 – Biz/ed
  • 21. Session 2 http://www.bized.co.uk • Adder/Subtractor A Result B Adder_Subtractor Example 6 Operation Operation =1  a+b Operation =0  a-b 21 Copyright 2006 – Biz/ed
  • 22. Session 2 http://www.bized.co.uk Adder/Subtractor LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; ENTITY add_sub IS port ( a, b : in integer; result : out integer; operation : in std_logic); -- add or subtract END ENTITY add_sub; ARCHITECTURE behave OF add_sub IS BEGIN process ( a, b, operation What is sensitivity list !! ) begin if (operation = '1') then -- Add when operation = '1' result <= a + b; else -- Subtract otherwise result <= a - b; end if; end process; END ARCHITECTURE behave; 22 Copyright 2006 – Biz/ed
  • 23. Session 2 http://www.bized.co.uk Adder/Subtractor LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; ENTITY add_sub IS port ( a, b : in integer; result : out integer; operation : in std_logic); -- add or subtract END ENTITY add_sub; ARCHITECTURE behave OF add_sub IS BEGIN process ( a, b, operation ) begin if (operation = '1') then -- Add when operation = '1' result <= a + b; else -- Subtract otherwise result <= a - b; end if; end process; END ARCHITECTURE behave; 23 Copyright 2006 – Biz/ed
  • 24. Session 2 http://www.bized.co.uk • Simple Comparator A C B Comparator Example 7 A=B C=“00” A>B C=“01” A<B C=“10” 24 Copyright 2006 – Biz/ed
  • 25. Session 2 http://www.bized.co.uk Simple Comparator LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY comparator IS port( a, b : in std_logic_vector(7 downto 0); c : out std_logic_vector(1 downto 0); ); END ENTITY; ARCHITECTURE behave OF comparator IS BEGIN process (a, b) begin if (A = B ) then -- equality c <= "00"; elsif (A > B) then -- greater than c <= "01"; elsif (A < B) then -- greater than c <= "10"; else -- covers other cases c <= “ZZ"; end if; end process; END ARCHITECTURE; 25 Copyright 2006 – Biz/ed
  • 26. Session 2 http://www.bized.co.uk CASE Statement Makes several conditions on the same signal Syntax case <expression> is when <choice> => -- list of sequential statements when <choice> => -- list of sequential statements when others => -- list of sequential statements end case; 26 Copyright 2006 – Biz/ed
  • 27. Session 2 http://www.bized.co.uk CASE Statement <expression> can be a signal or a variable (discussed later) <choice> constants representing one of possible <expression> values. V.IMPORTANT ROLE -“When others” is a must if not all values of <expression> are covered -Each branch of a Case statement can have any number of sequential statements 27 Copyright 2006 – Biz/ed
  • 28. Session 2 http://www.bized.co.uk • 4 x 1 Multiplexer Example 8 28 Copyright 2006 – Biz/ed
  • 29. Session 2 http://www.bized.co.uk 4 x 1 Multiplexer Architecture rtl of mux_case is begin process (a,b,c,d,sel) begin Case sel is When "00" => f <= a; When "01" => f <= b; Do we need all these signals? On sensitivity list ?? When "10" => f <= c; When "11" => f <= d; when others => -- is "when others" a must? f <= „Z‟; End case; End process; End architecture; 29 Copyright 2006 – Biz/ed
  • 30. Session 2 http://www.bized.co.uk • Simulate 2 x 4 Decoder on Modelsim lab 1 30 Copyright 2006 – Biz/ed
  • 31. Session 2 http://www.bized.co.uk 2 x 4 Decoder Architecture rtl of dec is begin process (a) begin Case a is When "00" => f <= “0001”; When "01" => f <= “0010”; When "10" => f <= “0100”; When "11" => f <= “1000”; when others => f <= “ZZZZ”; End case; End process; End rtl ; How to make 4 x 2 Encoder ! 31 Copyright 2006 – Biz/ed
  • 32. Session 2 http://www.bized.co.uk 1-Area Optimization During writing a code for implementation you must save your resources Example Write a code describing this Adder OpSel Function 00 A+B 01 C+D 10 E+F 11 G+H Note that the selector can select one addition at a time, the operators are mutually exclusive 32 Copyright 2006 – Biz/ed
  • 33. Session 2 http://www.bized.co.uk It is better to write a code that describe the circuit on the right as adders take much bigger area than multiplexers his transformation of operators is called Resource Sharing 33 Copyright 2006 – Biz/ed
  • 34. Session 2 http://www.bized.co.uk Possible solutions Solution 1 process (OpSel,A,B,C,D,E,F,G,H) begin case OpSel is when "00" => Z <= A + B ; when "01" => Z <= C + D ; when "10" => Z <= E + F ; when "11" => Z <= G + H ; when others => Z <= (others => 'X') ; end case ; end process ; Here the code is Tool Driven Resource Sharing, the tool understand that we don’t need to make four adders and one Adder is implemented. General Note To ensure resource sharing, operators must be coded in the same process, and same code (case or if) structure. 34 Copyright 2006 – Biz/ed
  • 35. Session 2 http://www.bized.co.uk Solution 2 X <= Mux4(OpSel, A, C, E, G) ; Y <= Mux4(OpSel, B, D, F, H) ; Z <= X + Y ; Here the code is Code Driven Resource Sharing, You forced the tool to use only one Adder. Solution 3 Process (OpSel, A, B, C, D, E, F, G, H) begin if (OpSel = "00") then Z <= A + B; end if; if (OpSel = "01") then Z <= C + D; end if; if (OpSel = "10") then Z <= E + F; end if; if (OpSel = "11") then Z <= G + H; end if; end process ; Bad Code that may defeat Resource Sharing. Synthesis tool may create a separate resource for each adder. Don’t do that! 35 Copyright 2006 – Biz/ed
  • 36. Session 2 http://www.bized.co.uk Sequential Circuits Clock period A digital clock signal is a square wave voltage. In complex circuits a clock with a fixed frequency is used for timing. To store and pass the data or digital signals through, some specific gates are used which are called latches or flip-flops. These are some kind of memory that store their input over their output by a specific level or edge of the clock. Asynchronous Operation don’t wait clock Synchronous wait clock to get an input and to produce an output 36 Copyright 2006 – Biz/ed
  • 37. Session 2 http://www.bized.co.uk D-Flip Flop D Q Reset Clk Enable Q+ Reset D_FF 1 - - 0 0 No rising_edge - Q enable 0 Rising_edge 0 Q 0 Rising_edge 1 D clk Asynchronous reset Synchronous enable Clock period 37 Copyright 2006 – Biz/ed
  • 38. Session 2 http://www.bized.co.uk • Simple D-Flip Flop D Q D_FF Example 9 clk 38 Copyright 2006 – Biz/ed
  • 39. Session 2 http://www.bized.co.uk Simple D-FF Library ieee; use ieee.std_logic_1164.all; Entity d_ff is Port( D, clk : in std_logic; Q : out std_logic ); end entity; Architecture behav of d_ff is Begin process(clk) begin rising_edge() : defined for std_logic type if rising_edge(clk) then Q <= D; end if; end process; end behav; 39 Copyright 2006 – Biz/ed
  • 40. Session 2 http://www.bized.co.uk • D-FF with Asynchronous reset D Q Reset D_FF Example 10 clk 40 Copyright 2006 – Biz/ed
  • 41. Session 2 http://www.bized.co.uk D-FF with Asynchronous reset Library ieee; use ieee.std_logic_1164.all; Entity d_ff is Port( d, clk, rst : in std_logic; Q : out std_logic); end entity; Architecture behav of d_ff is Begin process(clk, rst) begin If (rst = '1') then Since rst has higher priority over the clk edge Q <= '0'; We put it on sensitivity list elsif rising_edge(clk) then Q <= d; We have now a D Flip Flop with asynchronous end if; reset end process; end behav; 41 Copyright 2006 – Biz/ed
  • 42. Session 2 http://www.bized.co.uk • D-FF with Asynchronous reset and Synchronous enable D Q Reset D_FF Example enable 11 clk 42 Copyright 2006 – Biz/ed
  • 43. Session 2 http://www.bized.co.uk D-FF with Asynchronous reset and Synchronous enable Library ieee; use ieee.std_logic_1164.all; Reset Clk Enable Q+ Entity d_ff is 1 - - 0 Port( d, clk, rst,en : in std_logic; Q : out std_logic 0 No rising_edge - Q ); 0 Rising_edge 0 Q end entity; 0 Rising_edge 1 D Architecture behav of d_ff is Begin process(clk, rst) begin If (rst = '1') then Enable has lower priority w.r.t the clk edge Q <= '0'; So we don’t put it in sensitivity list as it will slow the elsif rising_edge(clk) then simulation If (en = '1') then Q <= d; end if; We have now a D Flip Flop with asynchronous end if; reset and synchronous enable end process; end behav; 43 Copyright 2006 – Biz/ed
  • 44. Session 2 http://www.bized.co.uk D-Latch vs D-Flip Flop With a latch, a signal can’t propagate through until the clock is high . With a Flip-flop, the signal only propagates through on the rising edge. 44 Copyright 2006 – Biz/ed
  • 45. Session 2 http://www.bized.co.uk • D_Latch (positive level) D Q Reset D_FF Example enable 12 clk 45 Copyright 2006 – Biz/ed
  • 46. Session 2 http://www.bized.co.uk D-Latch with Asynchronous reset and Synchronous enable library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity d_ff is port( clk,reset,enable: in std_logic; d: in std_logic; q: out std_logic); end d_ff; architecture Behavioral of d_ff is begin process(clk,reset,d) begin if reset = '1' then q<= '0'; elsif clk = '1' then if enable = '1' then q<= d; end if; end if; end process; end Behavioral; 46 Copyright 2006 – Biz/ed
  • 47. Session 2 http://www.bized.co.uk Assignment Session-2 Write a code describing a T-Flip Flop T If the T input is high, the T flip-flop changes Q state ("toggles") whenever the clock input is stored. If the T input is low, the flip-flop holds Reset D_FF the previous value. Q’ clk 47 Copyright 2006 – Biz/ed
  • 48. Session 2 http://www.bized.co.uk Mini Project-1 48 Copyright 2006 – Biz/ed
  • 49. Session 2 http://www.bized.co.uk ALU Arithmetic Logic Unit It is a circuit capable of executing both kinds of operations, arithmetic as well as logical. Its operation is described next slide as follow : The output (arithmetic or logical) is selected by the MSB of sel The specific operation is selected by sel’s other three bits. 49 Copyright 2006 – Biz/ed
  • 50. Session 2 http://www.bized.co.uk Sel Operation Function Unit 0000 Y<= a Transfer A 0001 Y<= a+1 Increment A 0010 Y<= a-1 Decrement A 0011 Y<= b Transfer B Athematic 0100 Y<= b+1 Increment A 0101 Y<= b-1 Decrement A 0110 Y<= a+b Add a and b 0111 Y<= a+b+cin Add a and b and carry 1000 Y<= not a Complement a 1001 Y<= not b Complement b 1010 Y<= a AND b AND 1011 Y<= a OR b OR logic 1100 Y<= a NAND b NAND 1101 Y<= a NOR b NOR 1110 Y<= a XOR b XOR 1111 Y<= a XNOR b XNOR 50 Copyright 2006 – Biz/ed
  • 51. Session 2 http://www.bized.co.uk Required -VHDL code of this ALU -Verify functionality using Modelsim Deadline -Next session 51 Copyright 2006 – Biz/ed
  • 52. Session 2 http://www.bized.co.uk Download Session 2 material Session 2.pdf Modelsim tuotorial.pdf Xilinx ISE tuotorial.pdf lab1.txt Ask for the material through mail start.courses@gmail.com Facebook group start.group@groups.facebook.com 52 Copyright 2006 – Biz/ed
  • 53. Session 2 http://www.bized.co.uk Questions Session-2 53 Copyright 2006 – Biz/ed
  • 54. Session 2 http://www.bized.co.uk Take Your Notes Print the slides and take your notes here --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- 54 Copyright 2006 – Biz/ed
  • 55. Session 2 http://www.bized.co.uk See You Next Session 55 Copyright 2006 – Biz/ed