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




                                   Session 6


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
http://www.bized.co.uk




Contents   -Scrambler mini project discussion

           -Finite State Machine
                     -What is FSM?
                     -Moore machine
                                                6
                     -Mealy machine
                     -FSM in VHDL




                                                 2
                                   Copyright 2006 – Biz/ed
Session 6

                                    http://www.bized.co.uk




Scrambler mini project discussion



  B(i)=[b(i)+c(i)]mod2




                                                     3
                                       Copyright 2006 – Biz/ed
Session 6

                  http://www.bized.co.uk




            FSM




                                   4
                     Copyright 2006 – Biz/ed
Session 6

                                                            http://www.bized.co.uk


What is FSM


 Any digital system consists of two part:

                                                            Data Part
 Data part
 Responsible for the processing of data. The      Inputs                       Outputs
 processing is done through some blocks such as (full
 adder, digital filter, decoder,…)
                                                                    Controls
 Control part
 Describes how and when these blocks will
 communicate with each other.
 The control part is generally described using a finite
                                                           Control Part
 state machine.



                                                                                5
                                                                Copyright 2006 – Biz/ed
Session 6

                                                     http://www.bized.co.uk


What is FSM
                                                       S1

Finite State Machine

FSM is simply a finite number of states that
                                                S3                     S2
each state describes a certain set of control
outputs that are connected to the data part
blocks.

The transition between these states depends
mainly on the inputs of the FSM.

There are two main types of FSM:
                                                     S4
Moore FSM
Mealy FSM


                                                                        6
                                                          Copyright 2006 – Biz/ed
Session 6

                                                             http://www.bized.co.uk



FSM in VHDL

Assigning Moore Outputs
                                                                  Output
Use a combinational ‘process’ to model Output Logic               Logic
Outputs are only dependant on the current state

Assigning Mealy Outputs                                       Outputs = f(State)


Use a combinatorial ‘process’ to model Output Logic
Outputs are dependant on the current state & the input   Outputs = f(Inputs, State)


                                                                 Output
                                                                 Logic



                                                                                   7
                                                                 Copyright 2006 – Biz/ed
Session 6

                                                               http://www.bized.co.uk


Moore FSM


 In a Moore finite state machine, the output of
 the circuit is dependent only on the state of
 the machine and not on its inputs.



Inputs                   Next                     Present
                         state                    state                    Outputs
           Next                  Machine                    Output
           State                  State                     Logic
           Logic                 Registers




                                                                                     8
                                                                     Copyright 2006 – Biz/ed
Session 6

                                                            http://www.bized.co.uk


Mealy FSM

 In a Mealy finite state machine, the output is
 dependent both on the machine state as well
 as on the inputs to the FSM.



Inputs                      Next                  Present
                            state                 state                  Outputs
              Next                  Machine                 Output
              State                  State                  Logic
              Logic                 Registers




                                                                             9
                                                               Copyright 2006 – Biz/ed
Session 6

                                             http://www.bized.co.uk



Moore FSM             transition
                      condition 1


     state 1                                state 2
                      transition
                      condition 2


Mealy FSM        transition condition 1 /
                         output 1


      state 1                               state 2
                 transition condition 2 /
                         output 2

                                                             10
                                                Copyright 2006 – Biz/ed
Session 6

                                        http://www.bized.co.uk




• Synchronous & asynchronous FSM
       -Moore (Synchronous )
       -Mealy(asynchronous )




                                   Example
                                      26




                                                          11
                                             Copyright 2006 – Biz/ed
Session 6

                                                       http://www.bized.co.uk



  Moore FSM that Recognizes Sequence “10”

              0                   1

                              1                  0
                   S0 / 0              S1 / 0             S2 / 1


         reset

                   S0: No             S1: “1”        S2: “10”
Meaning            elements           observed       observed
of states:         of the
                   sequence
                   observed

                                                                        12
                                                           Copyright 2006 – Biz/ed
Session 6

                                             http://www.bized.co.uk



Mealy FSM that Recognizes Sequence “10”

                    0/0         1/0         1/0

                          S0           S1


         reset                  0/1
                     S0: No           S1: “1”
 Meaning             elements         observed
 of states:          of the
                     sequence
                     observed
                                                               13
                                                  Copyright 2006 – Biz/ed
Session 6

                                   http://www.bized.co.uk




clock
            0       1    0    0     0
input

            S0      S1   S2   S0   S0
Moore
            S0      S1   S0   S0   S0
Mealy



                                                     14
                                        Copyright 2006 – Biz/ed
Session 6

                                                                  http://www.bized.co.uk

                                     3-FSM in VHDL


-Finite State Machines Can Be Easily Described With Processes

-Synthesis Tools Understand FSM Description if Certain Rules Are Followed

-----State transitions should be described in a process sensitive to clock and asynchronous
reset signals only
-----Output function described using rules for combinational logic, i.e. as concurrent
statements or a process with all inputs in the sensitivity list




                                                                                   15
                                                                      Copyright 2006 – Biz/ed
Session 6

                                                                http://www.bized.co.uk


FSM in VHDL

The “3 Processes, 1 Clocked + separate transitions/actions” style



1-Process modeling “Next State Logic”                       Next
                                                            State
                                                            Logic




2-Process modeling "Current State Registers"
                                                                     State
                                                                    Registers



3-Process modeling “Output Logic”
                                                                            Output
                                                                            Logic



                                                                                 16
                                                                    Copyright 2006 – Biz/ed
Session 6

                                                          http://www.bized.co.uk


FSM in VHDL
Next-State Logic
Use a combinational ‘process’ to model next state logic


process ( current_state, <in1>, <in2>, <in3> … )
Begin
  case ( Current_State ) is
    when <state1> =>
                                                                   Next
      if ( <condition (<in1>, <in2>...)> ) then                    State
        Next_State <= <state2>;                                    Logic
      elsif ( <condition (<in1>, <in2>...)> ) then
        Next_State <= <state3>;
        ...
end process;




                                                                           17
                                                             Copyright 2006 – Biz/ed
Session 6

                                                              http://www.bized.co.uk


FSM in VHDL
Current-State
Use a sequential ‘process’ to describe current state logic*


Process (clock)
Begin
  if rising_edge (clock) then
    if ( reset = '1' ) then -- synchronous reset
      Current_State <= <reset_state>;
    else
      Current_State <= Next_State;                                   State
                                                                    Registers
    end if;
  end if;
end process;




                                                                                18
                                                                 Copyright 2006 – Biz/ed
Session 6

                           http://www.bized.co.uk




• Vending Machine
       -Moore
       -Mealy




                      Example
                         27




                                             19
                                Copyright 2006 – Biz/ed
Session 6

                                                     http://www.bized.co.uk


Vending Machine
Specifications
-Deliver package of gum after 15 piaster deposited
-Single coin slot for 5 and 10 piasters



Step 1 : Understand the problem
 Draw a block diagram




                                                                     20
                                                        Copyright 2006 – Biz/ed
Session 6

                                                           http://www.bized.co.uk



Step 2 : Draw a state diagram
           Reset

               D        S0        N

          S6                          S1
     D           N                D            N              N = 5 piaster
    S8           S7          S3                S2             D = 10 piaster
   open          open        open          D        N
                                       S5           S4
                                       open         open


                                                                           21
                                                              Copyright 2006 – Biz/ed
Session 6

                                  http://www.bized.co.uk


Step 3 : State Minimization

            Reset
                     S0
                    N
                     S1       D
                    N             N = 5 piaster
           D                      D = 10 piaster
                     S2
                 N,D
                   S3
                    open

                                                  22
                                     Copyright 2006 – Biz/ed
Session 6

                                            http://www.bized.co.uk

Step 4
         Write VHDL code (Moore)
Inputs and Outputs                        Reset
                                                    S0
library IEEE;                                      N
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
                                                    S1           D
use IEEE.STD_LOGIC_UNSIGNED.ALL;
                                                   N
entity vend_machine_moore   is             D
    Port (N         : in    STD_LOGIC;              S2
          D         : in    STD_LOGIC;
         reset      : in    STD_LOGIC;            N,D
          clk       : in    STD_LOGIC;              S3
          tank_open : out   STD_LOGIC);
end vend_machine_moore;
                                                   open

                                                            23
                                               Copyright 2006 – Biz/ed
Session 6

                                                       http://www.bized.co.uk




Define the states                                      Reset
We need to define a new type for the names of the states
                                                                S0
                                                                N
                                                                 S1          D
architecture Behavioral of vend_machine_moore is
                                                                N
type states is (s0,s1,s2,s3);                          D        S2
signal n_state,p_state :states;
begin                                                          N,D
                                                                 S3
                                                                open

                                                                        24
                                                           Copyright 2006 – Biz/ed
Session 6

                                                                     http://www.bized.co.uk




The transition process                                            Reset
Responsible for the transition of states from present state to next state.
                                                                              S0
                                                                              N
  transition :process(clk,reset)                                               S1          D
  begin
   if reset='1' then                                                          N
      p_state <=s0 ;                                                D
   elsif rising_edge(clk) then                                                S2
      p_state <= n_state ;
   end if;                                                                   N,D
  end process transition;                                                      S3
                                                                              open

                                                                                      25
                                                                         Copyright 2006 – Biz/ed
Session 6

                                                              http://www.bized.co.uk


Next State logic process
Responsible for generating the next state logic.
                                                            Reset
next_state :process(N,D,p_state)
--p_state in list to trigger process if ips are constants             S0
begin
  case p_state is                                                    N
  when s0 =>                    when s2 =>
    if N='1' then                   if N='1' then                     S1           D
      n_state <= s1;                  n_state <= s3;
    elsif D='1' then                 elsif D='1' then
      n_state <= s2;                       n_state <= s3;
                                                                     N
    else
      n_state <= s0;
                                     else n_state <= s2;     D        S2
                                         end if;
    end if;
when s1 =>                       when s3 =>                         N,D
    if N='1' then                    n_state <= s0;
      n_state <= s2;            --------------                        S3
     elsif D='1' then           end case;
       n_state <= s3;
     else n_state <= s1;
                                end process next_state;              open
         end if;

                                                                              26
                                                                 Copyright 2006 – Biz/ed
Session 6

                                                 http://www.bized.co.uk



Output logic process
Responsible for generating the output logic.   Reset

output_logic :process(p_state)
                                                         S0
begin
  case p_state is                                       N
  when s0 => tank_open <='0';                            S1
  when s1 => tank_open <='0';
                                                                      D
  when s2 => tank_open <='0';
  when s3 => tank_open <='1';                           N
 end case;                                      D        S2
end process output_logic ;
                                                       N,D
end Behavioral;                                          S3
                                                        open

                                                                 27
                                                    Copyright 2006 – Biz/ed
Session 6

                                                        http://www.bized.co.uk

Step 4
         Write VHDL code (Mealy)
                                                Reset
Note : the number of states in Mealy FSM 3 !!
library IEEE;                                              S0
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;                        N, 0
entity vend_machine_moore is             N/D, 1    D, 1 S1           D, 0
    Port (N         : in STD_LOGIC;
          D         : in STD_LOGIC;
         reset      : in STD_LOGIC;
          clk       : in STD_LOGIC;
                                                        N, 0
          tank_open : out STD_LOGIC);
end vend_machine_moore;                                    S2
architecture Behavioral of vend_machine_mealy is
type states is (s0,s1,s2);
signal n_state,p_state :states;
begin
                                                                        28
                                                           Copyright 2006 – Biz/ed
Session 6

                                       http://www.bized.co.uk


transition :process(reset,clk)
begin
 if clr='1' then
   p_state <=s0 ;
         elsif rising_edge(clk) then
            p_state <= n_state ;
                  end if;
end process transition;

next_state :process(N,D,p_state)
begin
  case p_state is
  when s0 =>
    if N='1' then
       tank_open <='0';
       n_state <= s1;
      elsif D='1' then
                   n_state <= s2;
            tank_open <='0';
      else n_state <= s0;
                tank_open <='0';
         end if;

                                                       29
                                          Copyright 2006 – Biz/ed
Session 6

                                    http://www.bized.co.uk
when s1 =>
    if N='1' then
      n_state <= s2;
                 tank_open <='0';
     elsif D='1' then
       n_state <= s0;
       tank_open <='1';
     else n_state <= s1;
                tank_open <='0';
        end if;
 when s2 =>
    if N='1' then
      n_state <= s0;
                 tank_open <='1';
     elsif D='1' then
                   n_state <= s0;
           tank_open <='1';
     else n_state <= s2;
                tank_open <='0';
        end if;
end case;
end process next_state;
end Behavioral;

                                                    30
                                       Copyright 2006 – Biz/ed
Session 6

                                  http://www.bized.co.uk




• Gumball Vending Machine




                            lab
                             12




                                                  31
                                     Copyright 2006 – Biz/ed
Session 6

                                         http://www.bized.co.uk




• String Detector

 to detect input sequence (1110)

 draw state diagram
      (Mealy and Moore)            Exercise
                                      6




                                                           32
                                              Copyright 2006 – Biz/ed
Session 6

                                         http://www.bized.co.uk




• String Detector

 to detect input sequence (1110)
 Moore or Mealy




                                   lab
                                    13




                                                         33
                                            Copyright 2006 – Biz/ed
Session 6

                             http://www.bized.co.uk




Questions
                 Session-6




                                             34
                                Copyright 2006 – Biz/ed
Session 6

                                                                                                      http://www.bized.co.uk

Take Your Notes
              Print the slides and take your notes here

---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
                                                                                                                              35
                                                                                                           Copyright 2006 – Biz/ed
Session 6

                       http://www.bized.co.uk




See You Next Session




                                       36
                          Copyright 2006 – Biz/ed

Contenu connexe

En vedette

RESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º B
RESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º BRESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º B
RESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º Bpaloma59
 
10 things to do on instagram
10 things to do on instagram10 things to do on instagram
10 things to do on instagramAnthony Greene
 
Unitat 05 geografia_2a_part
Unitat 05 geografia_2a_partUnitat 05 geografia_2a_part
Unitat 05 geografia_2a_partescolalapau
 
Falsafah keperawatan
Falsafah keperawatanFalsafah keperawatan
Falsafah keperawatanmertayasa
 
Elizabeth tang hkctu disclourse of lobbying activities
Elizabeth tang   hkctu disclourse of lobbying activitiesElizabeth tang   hkctu disclourse of lobbying activities
Elizabeth tang hkctu disclourse of lobbying activitiesMongkok anonym
 
ΛΟΥΛΟΥΔΙΑ
ΛΟΥΛΟΥΔΙΑΛΟΥΛΟΥΔΙΑ
ΛΟΥΛΟΥΔΙΑdtsifts
 

En vedette (11)

RESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º B
RESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º BRESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º B
RESUMEN DE MUELLE Y LOS SALTAPIEDRA, POR IZAN SÁNCHEZ 1º B
 
Food and health
Food and healthFood and health
Food and health
 
VLAN ON PACKET TRACER
VLAN ON PACKET TRACERVLAN ON PACKET TRACER
VLAN ON PACKET TRACER
 
10 things to do on instagram
10 things to do on instagram10 things to do on instagram
10 things to do on instagram
 
Unitat 05 geografia_2a_part
Unitat 05 geografia_2a_partUnitat 05 geografia_2a_part
Unitat 05 geografia_2a_part
 
Falsafah keperawatan
Falsafah keperawatanFalsafah keperawatan
Falsafah keperawatan
 
Agua y salud
Agua y salud  Agua y salud
Agua y salud
 
Elizabeth tang hkctu disclourse of lobbying activities
Elizabeth tang   hkctu disclourse of lobbying activitiesElizabeth tang   hkctu disclourse of lobbying activities
Elizabeth tang hkctu disclourse of lobbying activities
 
Увімкни Україну
Увімкни УкраїнуУвімкни Україну
Увімкни Україну
 
ΛΟΥΛΟΥΔΙΑ
ΛΟΥΛΟΥΔΙΑΛΟΥΛΟΥΔΙΑ
ΛΟΥΛΟΥΔΙΑ
 
Mohammed Abou Elmagd
Mohammed Abou ElmagdMohammed Abou Elmagd
Mohammed Abou Elmagd
 

Plus de Mahmoud Abdellatif (13)

Start group tutorial [2]
Start group tutorial [2]Start group tutorial [2]
Start group tutorial [2]
 
Evaluation test
Evaluation testEvaluation test
Evaluation test
 
Session nine
Session nineSession nine
Session nine
 
Session eight
Session eightSession eight
Session eight
 
Session seven
Session sevenSession seven
Session seven
 
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
 
Session two
Session twoSession two
Session two
 
Session one
Session oneSession one
Session one
 
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

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Dernier (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Session six

  • 1. http://www.bized.co.uk Session 6 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. http://www.bized.co.uk Contents -Scrambler mini project discussion -Finite State Machine -What is FSM? -Moore machine 6 -Mealy machine -FSM in VHDL 2 Copyright 2006 – Biz/ed
  • 3. Session 6 http://www.bized.co.uk Scrambler mini project discussion B(i)=[b(i)+c(i)]mod2 3 Copyright 2006 – Biz/ed
  • 4. Session 6 http://www.bized.co.uk FSM 4 Copyright 2006 – Biz/ed
  • 5. Session 6 http://www.bized.co.uk What is FSM Any digital system consists of two part: Data Part Data part Responsible for the processing of data. The Inputs Outputs processing is done through some blocks such as (full adder, digital filter, decoder,…) Controls Control part Describes how and when these blocks will communicate with each other. The control part is generally described using a finite Control Part state machine. 5 Copyright 2006 – Biz/ed
  • 6. Session 6 http://www.bized.co.uk What is FSM S1 Finite State Machine FSM is simply a finite number of states that S3 S2 each state describes a certain set of control outputs that are connected to the data part blocks. The transition between these states depends mainly on the inputs of the FSM. There are two main types of FSM: S4 Moore FSM Mealy FSM 6 Copyright 2006 – Biz/ed
  • 7. Session 6 http://www.bized.co.uk FSM in VHDL Assigning Moore Outputs Output Use a combinational ‘process’ to model Output Logic Logic Outputs are only dependant on the current state Assigning Mealy Outputs Outputs = f(State) Use a combinatorial ‘process’ to model Output Logic Outputs are dependant on the current state & the input Outputs = f(Inputs, State) Output Logic 7 Copyright 2006 – Biz/ed
  • 8. Session 6 http://www.bized.co.uk Moore FSM In a Moore finite state machine, the output of the circuit is dependent only on the state of the machine and not on its inputs. Inputs Next Present state state Outputs Next Machine Output State State Logic Logic Registers 8 Copyright 2006 – Biz/ed
  • 9. Session 6 http://www.bized.co.uk Mealy FSM In a Mealy finite state machine, the output is dependent both on the machine state as well as on the inputs to the FSM. Inputs Next Present state state Outputs Next Machine Output State State Logic Logic Registers 9 Copyright 2006 – Biz/ed
  • 10. Session 6 http://www.bized.co.uk Moore FSM transition condition 1 state 1 state 2 transition condition 2 Mealy FSM transition condition 1 / output 1 state 1 state 2 transition condition 2 / output 2 10 Copyright 2006 – Biz/ed
  • 11. Session 6 http://www.bized.co.uk • Synchronous & asynchronous FSM -Moore (Synchronous ) -Mealy(asynchronous ) Example 26 11 Copyright 2006 – Biz/ed
  • 12. Session 6 http://www.bized.co.uk Moore FSM that Recognizes Sequence “10” 0 1 1 0 S0 / 0 S1 / 0 S2 / 1 reset S0: No S1: “1” S2: “10” Meaning elements observed observed of states: of the sequence observed 12 Copyright 2006 – Biz/ed
  • 13. Session 6 http://www.bized.co.uk Mealy FSM that Recognizes Sequence “10” 0/0 1/0 1/0 S0 S1 reset 0/1 S0: No S1: “1” Meaning elements observed of states: of the sequence observed 13 Copyright 2006 – Biz/ed
  • 14. Session 6 http://www.bized.co.uk clock 0 1 0 0 0 input S0 S1 S2 S0 S0 Moore S0 S1 S0 S0 S0 Mealy 14 Copyright 2006 – Biz/ed
  • 15. Session 6 http://www.bized.co.uk 3-FSM in VHDL -Finite State Machines Can Be Easily Described With Processes -Synthesis Tools Understand FSM Description if Certain Rules Are Followed -----State transitions should be described in a process sensitive to clock and asynchronous reset signals only -----Output function described using rules for combinational logic, i.e. as concurrent statements or a process with all inputs in the sensitivity list 15 Copyright 2006 – Biz/ed
  • 16. Session 6 http://www.bized.co.uk FSM in VHDL The “3 Processes, 1 Clocked + separate transitions/actions” style 1-Process modeling “Next State Logic” Next State Logic 2-Process modeling "Current State Registers" State Registers 3-Process modeling “Output Logic” Output Logic 16 Copyright 2006 – Biz/ed
  • 17. Session 6 http://www.bized.co.uk FSM in VHDL Next-State Logic Use a combinational ‘process’ to model next state logic process ( current_state, <in1>, <in2>, <in3> … ) Begin case ( Current_State ) is when <state1> => Next if ( <condition (<in1>, <in2>...)> ) then State Next_State <= <state2>; Logic elsif ( <condition (<in1>, <in2>...)> ) then Next_State <= <state3>; ... end process; 17 Copyright 2006 – Biz/ed
  • 18. Session 6 http://www.bized.co.uk FSM in VHDL Current-State Use a sequential ‘process’ to describe current state logic* Process (clock) Begin if rising_edge (clock) then if ( reset = '1' ) then -- synchronous reset Current_State <= <reset_state>; else Current_State <= Next_State; State Registers end if; end if; end process; 18 Copyright 2006 – Biz/ed
  • 19. Session 6 http://www.bized.co.uk • Vending Machine -Moore -Mealy Example 27 19 Copyright 2006 – Biz/ed
  • 20. Session 6 http://www.bized.co.uk Vending Machine Specifications -Deliver package of gum after 15 piaster deposited -Single coin slot for 5 and 10 piasters Step 1 : Understand the problem Draw a block diagram 20 Copyright 2006 – Biz/ed
  • 21. Session 6 http://www.bized.co.uk Step 2 : Draw a state diagram Reset D S0 N S6 S1 D N D N N = 5 piaster S8 S7 S3 S2 D = 10 piaster open open open D N S5 S4 open open 21 Copyright 2006 – Biz/ed
  • 22. Session 6 http://www.bized.co.uk Step 3 : State Minimization Reset S0 N S1 D N N = 5 piaster D D = 10 piaster S2 N,D S3 open 22 Copyright 2006 – Biz/ed
  • 23. Session 6 http://www.bized.co.uk Step 4 Write VHDL code (Moore) Inputs and Outputs Reset S0 library IEEE; N use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; S1 D use IEEE.STD_LOGIC_UNSIGNED.ALL; N entity vend_machine_moore is D Port (N : in STD_LOGIC; S2 D : in STD_LOGIC; reset : in STD_LOGIC; N,D clk : in STD_LOGIC; S3 tank_open : out STD_LOGIC); end vend_machine_moore; open 23 Copyright 2006 – Biz/ed
  • 24. Session 6 http://www.bized.co.uk Define the states Reset We need to define a new type for the names of the states S0 N S1 D architecture Behavioral of vend_machine_moore is N type states is (s0,s1,s2,s3); D S2 signal n_state,p_state :states; begin N,D S3 open 24 Copyright 2006 – Biz/ed
  • 25. Session 6 http://www.bized.co.uk The transition process Reset Responsible for the transition of states from present state to next state. S0 N transition :process(clk,reset) S1 D begin if reset='1' then N p_state <=s0 ; D elsif rising_edge(clk) then S2 p_state <= n_state ; end if; N,D end process transition; S3 open 25 Copyright 2006 – Biz/ed
  • 26. Session 6 http://www.bized.co.uk Next State logic process Responsible for generating the next state logic. Reset next_state :process(N,D,p_state) --p_state in list to trigger process if ips are constants S0 begin case p_state is N when s0 => when s2 => if N='1' then if N='1' then S1 D n_state <= s1; n_state <= s3; elsif D='1' then elsif D='1' then n_state <= s2; n_state <= s3; N else n_state <= s0; else n_state <= s2; D S2 end if; end if; when s1 => when s3 => N,D if N='1' then n_state <= s0; n_state <= s2; -------------- S3 elsif D='1' then end case; n_state <= s3; else n_state <= s1; end process next_state; open end if; 26 Copyright 2006 – Biz/ed
  • 27. Session 6 http://www.bized.co.uk Output logic process Responsible for generating the output logic. Reset output_logic :process(p_state) S0 begin case p_state is N when s0 => tank_open <='0'; S1 when s1 => tank_open <='0'; D when s2 => tank_open <='0'; when s3 => tank_open <='1'; N end case; D S2 end process output_logic ; N,D end Behavioral; S3 open 27 Copyright 2006 – Biz/ed
  • 28. Session 6 http://www.bized.co.uk Step 4 Write VHDL code (Mealy) Reset Note : the number of states in Mealy FSM 3 !! library IEEE; S0 use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; N, 0 entity vend_machine_moore is N/D, 1 D, 1 S1 D, 0 Port (N : in STD_LOGIC; D : in STD_LOGIC; reset : in STD_LOGIC; clk : in STD_LOGIC; N, 0 tank_open : out STD_LOGIC); end vend_machine_moore; S2 architecture Behavioral of vend_machine_mealy is type states is (s0,s1,s2); signal n_state,p_state :states; begin 28 Copyright 2006 – Biz/ed
  • 29. Session 6 http://www.bized.co.uk transition :process(reset,clk) begin if clr='1' then p_state <=s0 ; elsif rising_edge(clk) then p_state <= n_state ; end if; end process transition; next_state :process(N,D,p_state) begin case p_state is when s0 => if N='1' then tank_open <='0'; n_state <= s1; elsif D='1' then n_state <= s2; tank_open <='0'; else n_state <= s0; tank_open <='0'; end if; 29 Copyright 2006 – Biz/ed
  • 30. Session 6 http://www.bized.co.uk when s1 => if N='1' then n_state <= s2; tank_open <='0'; elsif D='1' then n_state <= s0; tank_open <='1'; else n_state <= s1; tank_open <='0'; end if; when s2 => if N='1' then n_state <= s0; tank_open <='1'; elsif D='1' then n_state <= s0; tank_open <='1'; else n_state <= s2; tank_open <='0'; end if; end case; end process next_state; end Behavioral; 30 Copyright 2006 – Biz/ed
  • 31. Session 6 http://www.bized.co.uk • Gumball Vending Machine lab 12 31 Copyright 2006 – Biz/ed
  • 32. Session 6 http://www.bized.co.uk • String Detector to detect input sequence (1110) draw state diagram (Mealy and Moore) Exercise 6 32 Copyright 2006 – Biz/ed
  • 33. Session 6 http://www.bized.co.uk • String Detector to detect input sequence (1110) Moore or Mealy lab 13 33 Copyright 2006 – Biz/ed
  • 34. Session 6 http://www.bized.co.uk Questions Session-6 34 Copyright 2006 – Biz/ed
  • 35. Session 6 http://www.bized.co.uk Take Your Notes Print the slides and take your notes here --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------- 35 Copyright 2006 – Biz/ed
  • 36. Session 6 http://www.bized.co.uk See You Next Session 36 Copyright 2006 – Biz/ed