140 likes | 287 Views
ELEC1700 Computer Engineering 1 Week 9 Wednesday lecture Design of state machines Semester 1, 2013. 00. 11. J 1. Q 1. K 1. J 0. Q 0. 01. 10. K 0. Previous lecture…. Analysis of state machines: from this to this. Design of state machines: from this to this.
E N D
ELEC1700Computer Engineering 1Week 9 Wednesday lectureDesign of state machines Semester 1, 2013
00 11 J1 Q1 K1 J0 Q0 01 10 K0 Previous lecture… Analysis of state machines: from this to this Design of state machines: from this to this
Step 1: State diagram Aim: design a counter with a specified sequence 000,001,011,010,110, 111,101,100,000,… • Next state is uniquely determined by present state • so no labels on edges 3-bit Gray code sequence
Step 2: Next-state table Before CLK (Present state) After CLK (Next state) This table contains the same information as the state diagram Q2 Q1 Q0Q2+ Q1+ Q1+ 0 0 0 0 0 1 0 0 1 0 1 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0
Step 3: Excitation table Q Q+ J K 0 0 0 X hold or reset 0 1 1 X set or toggle 1 0 X 1 reset or toggle 1 1 X 0 hold or set Excitation table shows how we need to “excite” flip-flop inputs to achieve desired transitions on next CLK edge J = SET and K = RESET Q2 Q1 Q0Q2+ Q1+ Q1+ J2 K2J1 K1J0 K0 0 0 0 0 0 1 0 X 0 X1 X 0 0 1 0 1 10 X 1 XX 0 0 1 1 0 1 00 XX 0X 1 0 1 0 1 1 01 XX 00 X 1 1 0 1 1 1 X 0X 01 X 1 1 1 1 0 1X 0X 1X 0 1 0 1 1 0 0X 00 XX 1 1 0 0 0 0 0X 10 X0 X
Step 4: Karnaugh maps forflip-flop inputs Flip-flop inputs also called excitation logic
Step 5: Simplify expressions for flip-flop inputs Flip-flop inputs depend only on Q2, Q1, Q0 And because next-states of flip-flops depend only on flip-flop inputs… The next state of this counter depends only on the present state Sometimes the next state depends also on inputs to state machine — see next example (and Project #2)
Flip-flop inputs = excitation logic Week09Wed_Gray3.circ
Summary: state machine design • Draw state diagram • Derive next-state table from state diagram • Develop excitation table — shows flip-flop inputs needed to achieve desired transitions • Transfer excitation table contents into Karnaugh maps — one map for each flip-flop input • Use Karnaugh maps to simplify expressions for flip-flop inputs — the excitation logic • Implement state machine using flip-flops driven by excitation logic Follows §8-4 of textbook by Floyd very closely
State machines with external inputs • What if the counter can count up or down? • Required count direction specified by external input, Y • Y=1 → count “up” • Y=0 → count “down”
Next-state table Present state Input Next state Next state depends on present state and input Y Q2 Q1 Q0 Y Q2+ Q1+ Q1+ 0 0 0 01 0 0 0 0 0 10 0 1 0 0 1 00 0 0 0 0 11 0 1 1 0 1 1 00 0 1 0 1 1 1 0 1 0 … … …… … … … 1 0 0 0 1 0 1 1 0 01 0 0 0 Flip-flop inputs also depend on present state Q2Q1Q0 and input Y Excitation table now has 16 rows: 2 count directions (up/down) for each of the 8 values of the present state
External input Regular structure for excitation logic — highly recommended!