Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise Q3.17 Design an FSM to keep track of the mood of four students working in the digital design lab. Each Student is either: 1. Happy (the circuit.

Similar presentations


Presentation on theme: "Exercise Q3.17 Design an FSM to keep track of the mood of four students working in the digital design lab. Each Student is either: 1. Happy (the circuit."— Presentation transcript:

1 Exercise Q3.17 Design an FSM to keep track of the mood of four students working in the digital design lab. Each Student is either: 1. Happy (the circuit works) 2. Sad (the circuit blew up) 3. Busy (working on the circuit) 4. Clueless (confused about the circuit) 5. Asleep (face down on the circuit board) How many states does the FSM have ? What is the minimum number of bits necessary to represent these states ?

2 Each Student can either be: 1. Happy (the circuit works). 2. Sad (the circuit blew up). 3. Busy (working on the circuit). 4. Clueless (confused about the circuit). 5. Asleep (face down on the circuit board). So each student can be in five different states. Hence, we can say that overall we have 625 distinct states (5 possible states for 4 students, 5 4 = 625). For 625 distinct states, we need a minimum of ceiling(log 2 625) = 10 bits. Exercise Q3.17 Solution

3 Exercise Q3.22 Design an FSM that recognizes 1101 or 1110. – Draw state transition diagram (use as few states as possible). – Choose state encodings. – Write state transition and output table using the encodings. – Write next state equations and output equations.

4 Exercise Q3.22 Solutuon “ ” 0 “1” 0 “11” 0 “110” 0 “1101” 1 “111” 0 “1110” 1 11 0 1 0 1 Reset 0 0 0 0 1 1 0 1

5 “ ” 0 “1” 0 “11” 0 “110” 0 “1101” 1 “111” 0 “1110” 1 11 0 1 0 1 0 Reset 1 0 0 0 0 1 1 State encoding: A = 000 ; B = 001 ; C = 010 ; D = 011; E = 100 ; F = 101 ; G = 110

6 State transition and output table: Present State S2 S1 S0 X = 0X = 1 F NS S2+ S1+ S0+ NS S2+ S1+ S0+ 0 0 0 0 0 10 0 0 00 1 00 0 1 11 0 10 0 1 10 0 01 0 00 0 0 00 1 01 1 0 11 1 01 0 10 1 1 00 0 01 0 01

7 K-Maps: 0100 1100 00XX 0010 S0+ S0 X S2 S1 00011110 00 01 11 10 S0+ = S0’.S1.S2’ + X.S0’.S2’ + X.S0.S2 0010 1000 00XX 0101 S1+ S0 X S2 S1 00011110 00 01 11 10 S1+ = X.S0.S1’.S2’ + X’.S0’.S1.S2’ + X.S0’.S1’.S2 + X’.S0.S2 0000 0110 01XX 0011 S2+ S0 X S2 S1 00011110 00 01 11 10 S2+ = S0.S2 + X.S1 00 00 1X 10 F S0 X S2 S1 0001 00 01 11 10 F = S0’.S2

8 Interview Q 3.1 (textbook) Design an FSM that recognizes 01010 when it is received serially. “1” ---- 0 “0” ---- 0 “01” ---- 0 “010” ---- 0 “0101” ---- 0 “01010 ----- 1 01 0 1 0 0 Reset 1 0 0 1 1 1

9 Exercise Q3.27 (textbook) Design an FSM with one input, A, and two outputs, X and Y. X should be 1 if A has been 1 for at least three cycles altogether (not necessarily consecutively). Y should be 1 if A has been 1 for at least two consecutive cycles. Show your state transition diagram, encoded state transition table, next state and output equations, and schematic.

10 Important : Understand the problem correctly X should be 1 if A has been 1 for at least three cycles altogether (not necessarily consecutively). Y should be 1 if A has been 1 for at least two consecutive cycles. Sample Pattern1 (assuming Moore Machine, output is 1 cycle delayed) Input A01 1 0 1 1 1 Output Y0 001111 Output X0000011 Sample Pattern2 A01 1 1 0 0 1 Y0 001111 X0000111 Sample Pattern3 A10 1 0 1 1 0 Y0 000001 X0000011 Sample Pattern4 A10 1 1 1 1 0 Y0 000111 X0000111

11 0 A ---- X = 0 Y = 0 0 B ---- X = 0 Y = 0 0 C ----- X = 0 Y = 1 1 1 1 A ---- X = 0 Y = 0 1 B ---- X = 0 Y = 0 1 C ----- X = 1 Y = 1 1 1 2 A ---- X = 0 Y = 0 2 B ---- X = 1 Y = 0 2 C ----- X = 1 Y = 1 1 1 0 0 +3 A ---- X = 1 Y = 0 +3 B ---- X = 1 Y = 0 +3 C ----- X = 1 Y = 1 1 1 ― ― ― 0 0 1 0 0 0 0 0 Are there any equivalent states? Redundant/Equivalent states are those which can not be observed/distinguished from the FSM I/O behavior

12 0 A ---- X = 0 Y = 0 0 B ---- X = 0 Y = 0 0 C ----- X = 0 Y = 1 1 1 1 A ---- X = 0 Y = 0 1 B ---- X = 0 Y = 0 1 C ----- X = 1 Y = 1 1 1 2 A ---- X = 0 Y = 0 2 B ---- X = 1 Y = 0 2 C ----- X = 1 Y = 1 1 1 0 0 +3 A ---- X = 1 Y = 0 +3 B ---- X = 1 Y = 0 +3 C ----- X = 1 Y = 1 1 1 ― ― ― 0 0 1 0 0 0 0 0 Combining equivalent states 1c, 2c, 3c Reason : once these states are reached, output is always X=1, Y=1 for any input sequence.

13 0 A ---- X = 0 Y = 0 0 B ---- X = 0 Y = 0 0 C ----- X = 0 Y = 1 1 1 0 1 A ---- X = 0 Y = 0 1 B ---- X = 0 Y = 0 1 C ----- X = 1 Y = 1 1 1 ― 2 A ---- X = 0 Y = 0 2 B ---- X = 1 Y = 0 1 1 0 0 1 +3 A ---- X = 1 Y = 0 +3 B ---- X = 1 Y = 0 1 1 0 0 0 0 0 0 Are there any more equivalent states? Explicit Equivalence: Two states are equivalent if outputs, Next states are identical for all input combinations.

14 0 A ---- X = 0 Y = 0 0 B ---- X = 0 Y = 0 0 C ----- X = 0 Y = 1 1 1 0 1 A ---- X = 0 Y = 0 1 B ---- X = 0 Y = 0 1 C ----- X = 1 Y = 1 1 1 ― 2 A ---- X = 0 Y = 0 2 B ---- X = 1 Y = 0 1 1 0 0 1 +3 A ---- X = 1 Y = 0 +3 B ---- X = 1 Y = 0 1 1 0 0 0 0 0 0 Combining equivalent states 2b, 3b Reason : Next states, outputs are identical for all input combinations.

15 Common Mistake in Midterm2 Many got B = C = F, but didn’t get E = G Their state table looked like this. Present State Next State I=0 I=1 Output I = 0 I = 1 AAB00 BBE11 DBA00 EBD10 GBD10 Explicit Equivalence E = G.

16 0 A ---- X = 0 Y = 0 0 B ---- X = 0 Y = 0 0 C ----- X = 0 Y = 1 1 1 0 1 A ---- X = 0 Y = 0 1 B ---- X = 0 Y = 0 1 C ----- X = 1 Y = 1 1 1 ― 2 A ---- X = 0 Y = 0 2 B ---- X = 1 Y = 0 1 1 0 0 1 +3 A ---- X = 1 Y = 0 1 0 0 0 0 0

17 Another approach is to design an FSM for X (FSM-X) and a separate FSM for Y (FSM-Y) Then “simulate” the execution from the “initial states”

18 V A ---- X = 0 V B ---- X = 0 1 1 V C ----- X = 0 V D ----- X = 1 1 1 S A ---- Y = 0 S B ---- Y = 0 S C ----- Y = 1 0 1 0 1 FSM-X FSM-Y 0 0 0 ― ―

19 V B S A ---- X = 0 Y = 0 0 V A S A ---- X = 0 Y = 0 V B S B ---- X = 0 Y = 0 V C S C ----- X = 0 Y = 1 1 1 V D S C ----- X = 1 Y = 1 ― 1 0 0 V C S B ---- X = 0 Y = 0 1 1 0 V C S A ---- X = 0 Y = 0 V D S B ---- X = 1 Y = 0 V D S C ----- X = 1 Y = 1 1 1 0 V D S A ---- X = 1 Y = 0 V D S B ---- X = 1 Y = 0 V D S C ----- X = 1 Y = 1 1 1 ― ― 0 0 0 0

20 V B S A ---- X = 0 Y = 0 0 V A S A ---- X = 0 Y = 0 V B S B ---- X = 0 Y = 0 V C S C ----- X = 0 Y = 1 1 1 V D S C ----- X = 1 Y = 1 ― 1 0 0 V C S B ---- X = 0 Y = 0 1 1 0 V C S A ---- X = 0 Y = 0 V D S B ---- X = 1 Y = 0 V D S C ----- X = 1 Y = 1 1 1 0 V D S A ---- X = 1 Y = 0 V D S B ---- X = 1 Y = 0 V D S C ----- X = 1 Y = 1 1 1 ― ― 0 0 0 0

21 V B S A ---- X = 0 Y = 0 0 V A S A ---- X = 0 Y = 0 V B S B ---- X = 0 Y = 0 V C S C ----- X = 0 Y = 1 1 1 V D S C ----- X = 1 Y = 1 ― 1 0 0 V C S B ---- X = 0 Y = 0 1 1 0 V C S A ---- X = 0 Y = 0 V D S B ---- X = 1 Y = 0 1 0 V D S A ---- X = 1 Y = 0 1 0 0 0 1

22 Can also synthesize an FSM for X (FSM-X) and an FSM for Y (FSM-Y) separately (although this is different than what’s asked in this question)

23 V A ---- X = 0 V B ---- X = 0 1 1 V C ----- X = 0 V D ----- X = 1 1 1 S A ---- Y = 0 S B ---- Y = 0 S C ----- Y = 1 0 1 0 1 FSM-X FSM-Y 0 0 0 ― ―

24 State transition and output table, K-Maps for X, V1+, V0+ (for FSM-X) 00 01 11 11 V1+ A V1 V0 01 00 01 11 10 V1+ = V1 + V0.A 01 10 11 01 V0+ A V1 V0 01 00 01 11 10 V0+ = V0.A’ + V1V0 + V0’.A 00 01 Y V0 V1 01 0 1 Y = V1.V0 Present State V1 V0 A = 0A = 1 X NS V1+ V0+ NS V1+ V0+ V A = 0 00 0 10 V B = 0 10 11 00 V C = 1 01 01 0 V D = 1 11 1

25 Schematic for X, V1, V0 DFF DFF V1 X V0 V0+ V1+ A

26 State transition and output table, K-Maps for Y, S1+, S0+ (for FSM-Y) 00 01 XX 11 S1+ A S1 S0 01 00 01 11 10 S1+ = S1 + S0.A 01 00 XX 00 S0+ A S1 S0 01 00 01 11 10 S0+ = A.S0’.S1’ 00 1X Y S0 S1 01 0 1 Y = S1 Present State S1 S0 A = 0A = 1 Y NS S1+ S0+ NS S1+ S0+ S A = 0 00 0 10 S B = 0 10 1 00 S C = 1 01 0 1

27 Schematic for Y, S1, S0 DFF DFF S1Y S0 S0+ S1+ A

28 State transition and output table, K-Maps for Y, S1+, S0+ (for FSM-Y) : Using a different State Assignment for Sc. (Using 11 instead of 10) This helps in reducing the number of literals required to compute S0+. (requires 2 literals instead of 3) Efficient State Assignment problem is sometimes taken care of by EDA tools. 00 01 11 XX S1+ A S1 S0 01 00 01 11 10 S1+ = S1 + S0.A 01 01 11 XX S0+ A S1 S0 01 00 01 11 10 S0+ = S1 + A 00 X1 Y S0 S1 01 0 1 Y = S1 Present State S1 S0 A = 0A = 1 Y NS S1+ S0+ NS S1+ S0+ S A = 0 00 0 10 S B = 0 10 1 0 S C = 1 11 1

29 Can also directly implement using datapath (e.g. counters and shift registers) – all FF’s initialize to “0”. One possible way is as given here. Other methods of implementations also exist. + 2 MUX 2 1 “01” 22 10 2 2-bit D-FFs 2-input AND X (counts to 3 and remains at 3) A (shifts to “11” and remains at “11”) FF MUX FF MUX Y 1010


Download ppt "Exercise Q3.17 Design an FSM to keep track of the mood of four students working in the digital design lab. Each Student is either: 1. Happy (the circuit."

Similar presentations


Ads by Google