Docsity

State Machines - Sequential Logic Design - Lecture Slides, Slides of Digital Logic Design and Programming

Partial preview of the text

Download State Machines - Sequential Logic Design - Lecture Slides and more Slides Digital Logic Design and Programming in PDF only on Docsity!

Logic Design

Lecture

  • Agenda
    1. State Machines Review
  • Announcements
    1. n/a

State Machines

  • State Machines
    • there is a basic structure for a Clocked, Synchronous State Machine
  1. State Memory (i.e., flip-flops)
  2. Next State Logic “G” (combinational logic)
  3. Output Logic “F” (combinational logic) we’ll revisit F later…
  • if we keep this structure in mind while designing digital machines in VHDL, then it is a very straight forward task
  • Each of the parts of the State Machine are modeled with individual processes
  • let’s start by reviewing the design of a state machine using a manual method

State Machines

  • State Machines

“Moore Outputs” – outputs depend on the Current_State only

State Machines

  • State Machines
    • the steps in a state machine design are:
  1. Word Description of the Problem
  2. State Diagram
  3. State/Output Table
  4. State Variable Assignment
  5. Choose Flip-Flop type
  6. Construct F
  7. Construct G
  8. Logic Diagram

State Machines

  • State Machine Example “Sequence Detector”
  1. State/Output Table

Current_State In Next_State Out (Found)

S0 0 S0 0 1 S1 0 S1 0 S2 0 1 S0 0 S2 0 S0 0 1 S3 0 S3 0 S0 0 1 S0 1

State Machines

  • State Machine Example “Sequence Detector”
  1. State Variable Assignment – let’s use binary

Current_State In Next_State Out Q1 Q0 Q1* Q0* Found

0 0 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 1 0 0 1

  1. Choose Flip-Flop Type
  • 99% of the time we use D-Flip-Flops

State Machines

  • State Machine Example “Sequence Detector”
  1. Construct Output Logic “G”

Found = Q1∙Q0∙In

  1. Logic Diagram
  • for large designs, this becomes impractical

Q1 Q

In 00

0

1

2

3 In

Q

6

7

4

5

Q

State Machines in VHDL

  • State Memory
    • we use a process that updates the “Current_State” with the “Next_State”
    • we describe DFF’s using (CLK’event and CLK=‘1’)
    • this will make the assignment on the rising edge of CLK

STATE_MEMORY : process (CLK) begin if (CLK’event and CLK='1') then Current_State <= Next_State; end if; end process;

  • at this point, we need to discuss State Names

State Machines in VHDL

  • State Memory with “Synchronous RESET”

STATE_MEMORY : process (CLK) begin if (CLK’event and CLK='1') then

if (Reset = ‘1’) then Current_State <= S0; -- name of “reset” state to go to else Current_State <= Next_State; end if;

end if; end process;

  • this design will only observe RESET on the positive edge of clock (i.e., synchronous)

State Machines in VHDL

  • State Memory with “Asynchronous RESET”

STATE_MEMORY : process (CLK, Reset) begin if (Reset = ‘1’) then

Current_State <= S0; -- name of “reset” state to go to

elsif (CLK’event and CLK='1') then

Current_State <= Next_State;

end if;

end process;

  • this design is sensitive to both RESET and the positive edge of clock (i.e., asynchronous)