SlideServe
Menu
Préférences
© SlideServe · v2026

Finite State Machine: Realization

carrie avatar
16 diapositives · 379 Views · Jul 26, 2014

Finite State Machine: Realization. Martinet Lee, Steve Chung. Outline. What is FSM? The theory Not only a theory Now, forget about FSM Implementing functions, by circuit Implementing functions, by logic When circuit meets logic, FSM A simple example : from functions to FSM to circuit.

Finite State Machine: Realization - slide 1
01 / 16Finite State Machine: Realization
1 / 17

Télécharger la présentation

Finite State Machine: Realization
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Finite State Machine:Realization Martinet Lee, SteveChung

  2. Outline • What is FSM? • The theory • Not only a theory • Now, forget about FSM • Implementing functions, by circuit • Implementing functions, by logic • When circuit meets logic, FSM • A simple example: from functions to FSM to circuit

  3. What is FSM?

  4. The Theory

  5. Not only a theory… • You know how it looks like  • But how to construct it?How to connect it with the target function?

  6. Now, Forget about FSM

  7. Implementing functions, by circuit • Function: Simple Traffic Light: Red Green  Yellow  Red(repeat) • Construct a counter which will reset on 2 : • 0  1  2  0 … • 2’b00  2’b01  2’b10  2’b00  … • Construct the lights according to the counter’s value.

  8. Implementing functions, by circuit • Function: Find target , identify target ( enemy and ally ) , act accordingly ( fire, supply ), then repeat. • How to construct? • Counter?

  9. Implementing functions, by Logic • Function: Find target , identify target ( enemy and ally ) , act accordingly ( fire, supply ), then repeat. • How to construct? • Search  Found  if( target == Enemy ) Fire; else Supply; Search

  10. When Circuit meets Logic:Finite State Machine

  11. Finite State Machine • Function: Find target , identify target ( enemy and ally ) , act accordingly ( fire, supply ), then repeat. • Aintuitive mapping from “function” to “FSM graph” • But how to implement?

  12. Finite State Machine Implementation • Create a set of registers, to store STATE • Assign each state on FSM to a number • Search  0  3’b000 • Found  1  3’b001 • Enemy  2  3’b010 • Ally  3  3’b011 • Fire  4  3’b100 • Supply  5  3’b101 • A circuit that could differentiate enemy and ally, will produce a 1-bit signal.

  13. FINITE STATE MACHINE IMPLEMENTATION • reg [2:0] State;reg [2:0] nextState;regdetected_smth;regisenemy;always@(posedgeclk)beginif(reset == 1’b1) State <= 3’b000; else begin State <= nextState; endendalways@(*) begincase(State) 3’b000: if(detected_smth == 1’b1) nextState = 3’b001; elsenextState = 3’b000; 3’b001: if( isenemy == 1’b1)nextstate = 3’b010; elsenextstate = 3’b011; 3’b010: nextState = 3’b100; 3’b011: nextState= 3’b101; 3’b100: nextState = 3’b000; 3’b101: nextState = 3’b000; default: nextState = 3’b000;endcaseend

  14. Code Not Clear enough… • Use parameter! • parameter S_Search = 3’b000;parameter S_Found = 3’b001;parameter S_Enemy = 3’b010;parameter S_Ally = 3’b011;parameter S_Fire = 3’b100;parameter S_Supply = 3’b101;

  15. Overall Code • reg [2:0] State;reg [2:0] nextState;regdetected_smth;regisenemy;parameter S_Search = 3’b000;parameter S_Found = 3’b001;parameter S_Enemy = 3’b010;parameter S_Ally = 3’b011;parameter S_Fire = 3’b100;parameter S_Supply = 3’b101;always@(posedgeclk)begin if(reset == 1’b1) State <= S_Search; else begin State <= nextState; endendalways@(*) begin case(State)S_Search: if(detected_smth == 1’b1) nextState = S_Found; elsenextState = S_Search;S_Found: if( isenemy == 1’b1)nextstate = S_Enemy; elsenextstate = S_Ally;S_Enemy:nextState = S_Fire;S_Ally:nextState = S_Supply;S_Fire:nextState = S_Search;S_Supply:nextState = S_Search; default: nextState = S_Search;endcaseend

  16. Any Questions? 