eem 334 digital systems iieem.eskisehir.edu.tr/userfiles/atdogan/files/l10-fsm...3/21/12 2 finite...

25
3/21/12 1 EEM 334 Digital Systems II Outline • Finite State Machine (FSM) Overview • Algorithmic State Machine (ASM) • FSMs in VHDL • State Assignment • FSM Design Examples

Upload: others

Post on 28-Jul-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

1

EEM 334 Digital Systems II

Outline

•  Finite State Machine (FSM) Overview •  Algorithmic State Machine (ASM) •  FSMs in VHDL •  State Assignment •  FSM Design Examples

Page 2: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

2

Finite State Machine (FSM) Overview

Synchronous FSM

•  An FSM is specified by five entities: – Symbolic states –  Input signals – Output signals – Next state function – Output function

Page 3: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

3

Synchronous FSM

•  FSM transits from one state to another •  Transition is controlled by the triggering

edge of a global clock signal •  FSM can have both Meally and Moore

outputs

State Diagram

•  State diagram: A set of nodes •  Node

– A unique state of the FSM – A unique symbolic name (S0)

•  Arc – Transition from one state to another – Transition condition (logic expression)

Page 4: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

4

State Diagram

•  Moore output •  Mealy output •  List only the output signals that are

activated/asserted –  signal_name <= asserted value – Asserted signal is assumed to be logic ‘1’

•  Unlisted signal: Default/unasserted value

State Diagram Example

•  Controller between a processor and a memory chip

•  Processor commands –  mem (memory access) –  rw (read/write’) –  burst (4 consecutive read)

•  Memory chip control signals –  oe (output enable for read) –  we (write enable for write)

•  Artificial mealy output signal –  we_me

Page 5: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

5

State Diagram Example

•  mem’:no memory operation is required

•  mem.rw: a memory read operation is required

•  mem.rw’: a memory write operation is required

Algorithmic State Machine (ASM)

Page 6: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

6

ASM Chart

•  An alternative method for representing an FSM

•  ASM ≡ State diagram (information content) – ASMs are more descriptive – ASMs are for complex algorithms – ASMs can be easily converted to VHDL code

•  ASM can be converted to a state diagram and vice versa

•  A network of ASM blocks

ASM Block

•  One state box •  Optional network of decision boxes •  Optional conditional output boxes

Page 7: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

7

ASM Example - 1

ASM Example - 2

Page 8: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

8

ASM Example - 3

ASM Example - 4

Page 9: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

9

ASM Example - 5

ASM Errors

•  One unique exit path from the block per input combination

•  If a=1 and b=1, two exit paths exist

Page 10: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

10

ASM Errors

•  One unique exit path from the block per input combination

•  If a=0, there is no exit path

ASM Errors

•  Exit path of an ASM block must always lead to a state box

Page 11: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

11

FSMs in VHDL

Memory Controller FSM

Page 12: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

12

Multi-segment Coding

Memory Controller FSM

•  VHDL enumeration data type:

type type_name is (list of all possible values);

Page 13: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

13

State Register

Next State Logic

Page 14: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

14

Next State Logic

Moore Output Logic

Page 15: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

15

Mealy Output Logic

Two-segment Memory Controller FSM

Page 16: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

16

Next State Logic

Next State Logic

Page 17: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

17

Synchronous FSM Initialization

State Assignment

Page 18: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

18

Overview •  Binary assignment

– Assign states wrt a binary sequence – Minimal number of bits,

•  Gray assignment – Assign states wrt a Gray code sequence – Minimal number of bits

•  One-hot assignment – Assign one bit for each state – FSM with n states, n-bit register

•  Almost one-hot assignment – One-hot except that all zero is also included

Overview

•  One-hot and almost one-hot need more register bits

•  They reduce the circuit size of next state and output logic

Page 19: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

19

Manual State Assignment

•  Implicit assignment –  IEEE 1076.6 RTL synthesis standard defines an

attribute named enum_encoding – Encoding the values of enumaration data type – No effect on the semantics of VHDL code – Mapping performed during the synthesis – Preferred method for its ease of maintanence

Manual State Assignment

•  Explicit assignment – Alias for binary representation

•  Need to modify the next state and output logic (state_reg is of type std_logic_vector)

Page 20: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

20

Unused States •  Memory controller example (Six states)

– Binary assignment: 3 bits, 2 unused states – One-hot: 6 bits, 2^6-6= 58 unused states

•  What if an FSM reaches an unused state –  Ignore the case since the error will never hapen – The system can never recover since there is

nothing we can do with the error •  Fault-tolerant/Fault-safe FSM

– Can recover from the unused state – Easy to include into explicit state assignment

FSM Design Examples

Page 21: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

21

Edge Detection Circuit

Edge Detection Circuit

Page 22: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

22

Edge Detection Circuit - Moore

Edge Detection Circuit - Moore

Page 23: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

23

Fixed Priority Arbiter

Fixed Priority Arbiter

Page 24: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

24

Manchester Encoding

•  0: 0-to-1 transition •  1: 1-to-0 transition

Manchester Encoding

•  v: valid input (data on the line is valid) •  d: data input

Page 25: EEM 334 Digital Systems IIeem.eskisehir.edu.tr/userfiles/atdogan/files/L10-FSM...3/21/12 2 Finite State Machine (FSM) Overview Synchronous FSM • An FSM is specified by five entities:

3/21/12

25

Manchester Encoding

Manchester Encoding