one-hot encoded finite state machines

22
17 ONEHOT Page 1 ECEn 224 © 2003-2008 BYU One-Hot Encoded Finite State Machines

Upload: fell

Post on 02-Feb-2016

29 views

Category:

Documents


0 download

DESCRIPTION

One-Hot Encoded Finite State Machines. InA’. A. InA’. InA. D. B. Z. InA. InB. C. Z. InB’. Example State Machine. State A = 00 State B = 01 State C = 10 State D = 11. D Q. D Q. Example Machine Implementation. Q1. N1 = Q1•Q0’ + Q1’•Q0•InA N0 = Q1•Q0’•InB + Q1’•Q0’•InA - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: One-Hot Encoded Finite State Machines

17 ONEHOT Page 1

ECEn 224 © 2003-2008BYU

One-Hot EncodedFinite State Machines

Page 2: One-Hot Encoded Finite State Machines

17 ONEHOT Page 2

ECEn 224 © 2003-2008BYU

Example State Machine

C

B

InA

InA’

Z

A

D

InA

InB

InA’

InB’

Z

InA InB CS NS Z

0 - A A 01 - A B 00 - B A 11 - B C 1- 0 C C 1- 1 C D 1- - D A 0

InA InB CS NS Z

0 - 00 00 01 - 00 01 00 - 01 00 11 - 01 10 1- 0 10 10 1- 1 10 11 1- - 11 00 0

State A = 00State B = 01State C = 10State D = 11

Page 3: One-Hot Encoded Finite State Machines

17 ONEHOT Page 3

ECEn 224 © 2003-2008BYU

Example Machine Implementation

N1 = Q1•Q0’ + Q1’•Q0•InAN0 = Q1•Q0’•InB + Q1’•Q0’•InAZ = Q1’•Q0 + Q1•Q0’

Logic Used:• 9 gates• 21 gate inputs• 2 flip flops

D Q

D Q Q0

Q1

CLK

CLK

N1

N0

Q1

Q0’

InA

Q1’Q0

InB

Q1Q0’

InA

Q1’Q0’

ZQ1

Q0’

Q1’

Q0

Page 4: One-Hot Encoded Finite State Machines

17 ONEHOT Page 4

ECEn 224 © 2003-2008BYU

Choose a Different Encoding

• A=1000, B=0100, C=0010, D=0001

InA InB CS NS Z

0 - 1000 1000 01 - 1000 0100 00 - 0100 1000 11 - 0100 0010 1- 0 0010 0010 1- 1 0010 0001 1- - 0001 1000 0

InA InB CS NS Z

0 - 1--- 1000 01 - 1--- 0100 00 - -1-- 1000 11 - -1-- 0010 1- 0 --1- 0010 1- 1 --1- 0001 1- - ---1 1000 0

Because of the state encodings,there are many illegal states.

This TT with all these input don’t cares is the result

This is called a one-hot encoding.

Only one state bit is on at a time

Page 5: One-Hot Encoded Finite State Machines

17 ONEHOT Page 5

ECEn 224 © 2003-2008BYU

One-Hot Encoding Results

By inspection we see:

NA = A•InA’ + B•InA’ + D NB = A•InA NC = B•InA + C•InB’ ND = C•InB Z = B + C

• Will require 4 flip flops– One per state– Call the current state bits A, B, C, and D– Call the next state bits NA, NB, NC, and ND

C

B

InA

InA’

Z

A

D

InA

InB

InA’

InB’

Z

Page 6: One-Hot Encoded Finite State Machines

17 ONEHOT Page 6

ECEn 224 © 2003-2008BYU

One-Hot Implementation

Logic Used:• 9 gates• 19 gate inputs• 4 flip flops

D Q

D Q B

A

CLK

CLK

NA

NB

ZB

C

D Q

D Q D

C

CLK

CLK

NC

ND

B

InA’

D

A

InA

C

InB

A

InA’ B

InA

C

InB’

Page 7: One-Hot Encoded Finite State Machines

17 ONEHOT Page 7

ECEn 224 © 2003-2008BYU

One-Hot Observations

• Choosing a one-hot encoding results in many, many don’t cares in transition table

• Minimization results in simpler IFL and OFL

• Requires more flip flops

• Can do one-hot design by inspection– Without using transition tables…

Page 8: One-Hot Encoded Finite State Machines

17 ONEHOT Page 8

ECEn 224 © 2003-2008BYU

State EncodingA 100B 010C 001

Another One-Hot Example

C

B

y

x’

Ax

y’z’

y’z

Page 9: One-Hot Encoded Finite State Machines

17 ONEHOT Page 9

ECEn 224 © 2003-2008BYU

D Q ANA

D Q BNB

D Q CNC

With one-hot encoding, each state has its own flip flop.

‘A’ is the name of a state and it is the name of the wire coming out of the flip flop for state ‘A’.

The same holds true for states ‘B’ and ‘C’

State EncodingA 100B 010C 001

State Encoding and Structure

Page 10: One-Hot Encoded Finite State Machines

17 ONEHOT Page 10

ECEn 224 © 2003-2008BYU

When is A the next state?

Look at the arcs entering state A

NA = A•x’ + B•y’z + C

One-Hot Encodings By Inspection

C

B

y

x’

Ax

y’z’

y’z

Page 11: One-Hot Encoded Finite State Machines

17 ONEHOT Page 11

ECEn 224 © 2003-2008BYU

When is A the next state?

Look at the arcs entering state A

NA = A•x’ + B•y’z + C

One-Hot Encodings By Inspection

C

B

y

x’

Ax

y’z’

y’z

Page 12: One-Hot Encoded Finite State Machines

17 ONEHOT Page 12

ECEn 224 © 2003-2008BYU

When is A the next state?

Look at the arcs entering state A

NA = A•x’ + B•y’z + C

One-Hot Encodings By Inspection

C

B

y

x’

Ax

y’z’

y’z

Page 13: One-Hot Encoded Finite State Machines

17 ONEHOT Page 13

ECEn 224 © 2003-2008BYU

When is A the next state?

Look at the arcs entering state A

NA = A•x’ + B•y’z + C

One-Hot Encodings By Inspection

C

B

y

x’

Ax

y’z’

y’z

Similar reasoning leads to:NB = A•x + B•y’z’NC = B•y

Page 14: One-Hot Encoded Finite State Machines

17 ONEHOT Page 14

ECEn 224 © 2003-2008BYU

The Key Lock Problem – One-Hot Version

There will be 6 flip flops

One for each state

Page 15: One-Hot Encoded Finite State Machines

17 ONEHOT Page 15

ECEn 224 © 2003-2008BYU

NA = (PUSHED’•A) + (ECNT3’•E) + (WAITDONE•F) + (LOCKED•D)NB = (PUSHED’•B)+(PUSHED•7•A)NC = (PUSHED’•C)+(PUSHED•8•B)ND = (LOCKED’•D)+(PUSHED•9•C)NE = (PUSHED•7’•A) + (PUSHED•8’•B) + (PUSHED•9’•C)NF = (ECNT3•E) + (WAITDONE’•F)

Key Lock Input Forming Logic

Page 16: One-Hot Encoded Finite State Machines

17 ONEHOT Page 16

ECEn 224 © 2003-2008BYU

ERROR =

Key Lock Output Forming Logic

Page 17: One-Hot Encoded Finite State Machines

17 ONEHOT Page 17

ECEn 224 © 2003-2008BYU

ERROR = EINC =

Key Lock Output Forming Logic

Page 18: One-Hot Encoded Finite State Machines

17 ONEHOT Page 18

ECEn 224 © 2003-2008BYU

ERROR = EINC = (PUSHED•7’•A) + (PUSHED•8’•B) + (PUSHED•9’•C)CLRTIMER =

Key Lock Output Forming Logic

Page 19: One-Hot Encoded Finite State Machines

17 ONEHOT Page 19

ECEn 224 © 2003-2008BYU

ERROR = EINC = (PUSHED•7’•A) + (PUSHED•8’•B) + (PUSHED•9’•C)CLRTIMER = ECNT3•ECLRCNTR =

Key Lock Output Forming Logic

Page 20: One-Hot Encoded Finite State Machines

17 ONEHOT Page 20

ECEn 224 © 2003-2008BYU

ERROR = EINC = (PUSHED•7’•A) + (PUSHED•8’•B) + (PUSHED•9’•C)CLRTIMER = ECNT3•ECLRCNTR = (WAITDONE•F) + (LOCKED•D)UNLOCK =

Key Lock Output Forming Logic

Page 21: One-Hot Encoded Finite State Machines

17 ONEHOT Page 21

ECEn 224 © 2003-2008BYU

ERROR = EINC = (PUSHED•7’•A) + (PUSHED•8’•B) + (PUSHED•9’•C)CLRTIMER = ECNT3•ECLRCNTR = (WAITDONE•F) + (LOCKED•D)UNLOCK = (PUSHED•9•C)

Key Lock Output Forming Logic

Page 22: One-Hot Encoded Finite State Machines

17 ONEHOT Page 22

ECEn 224 © 2003-2008BYU

Other State Encoding Techniques

• You have learned the 2 extremes– Fully encoded (8 states 3 state bits)– One-hot encoded (8 states 8 state bits)

• A range of options exist in between

• A good choice of encoding– Can minimize IFL and OFL complexity– Algorithms have been developed for this…– Beyond the scope of this class