Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENG241 Digital Design Week #7 Sequential Circuits (Part B)

Similar presentations


Presentation on theme: "ENG241 Digital Design Week #7 Sequential Circuits (Part B)"— Presentation transcript:

1 ENG241 Digital Design Week #7 Sequential Circuits (Part B)

2 2 Week #7 Topics  Sequential Circuit Analysis  Sequential Circuit Design Designing with D Flip-Flops Designing with JK Flip-Flops Designing with T Flip-Flops  VHDL Representations  Examples

3 3Resources  Chapter #6, Mano Sections 6.4 Sequential Circuit Analysis 6.5 Sequential Circuit Design 6.7 VHDL Representation of Sequential circuits

4 4 Analysis of Sequential Circuits  Earlier we learned how to analyze combinational circuits  We will extend analysis to synchronous sequential  We’ll use 1. State tables and 2. State diagrams

5 5 Review: Flip Flops

6 6 Analysis of Sequential Circuits  The behavior of a sequential circuit is determined from:  Inputs,  Outputs,  Present state of the circuit.  The analysis of a sequential circuit consists of:  Obtaining a suitable description that demonstrates the time sequence of inputs, outputs and states (STATE DIAGRAM).

7 7 Step #1: Derive Input Equations  Can describe inputs to FF with logic equations

8 8 Another Example

9 9 Input Equations  The input equations 1. Imply the type of flip-flop from the letter symbols, 2. Fully specify the combinational circuit that drives the flip-flops.

10 10 Time is Implied  Note that previous circuit used the next state Present state (A, B,..) to determine next state output State and inputs to determine output  Synchronous circuit  When are transitions?

11 Step #2: State Table  Similar to truth table with state added  A sequential circuit with `m’ FFs and `n’ inputs needs 2 m+n rows in state table. 11

12 12 Step#3: State Diagram “Mealy Model” An alternative representation to State Table Input/Output Input Output

13 13 Sequential Circuit Types  Moore model states only  Moore model – outputs depend on states only.  Mealy model inputs & states  Mealy model – outputs depend on inputs & states

14 14 State Diagram: Moore Alternative representation for state table State/Output Inputs

15 15 Moore vs. Mealy Machine  Moore Machine: Easy to understand and easy to code.  Might requires more states (thus more hardware).  Mealy Machine:  More complex since outputs are a function of both the state and input. Requires less states in most cases, therefore less components.  Choice of a model depends on the application and personal preference.  You can transform a Mealy Machine to a Moore Machine and vice versa.

16 16 State Table vs. Diagram  Provides same information  Table is perhaps easier to fill in from description  Diagram is easier for understanding and writing code  Analysis for sequential circuits that employs D flip flops is easy. Why?  Because the next state values are obtained directly from the input equations.

17 17 Analysis with JK Flip Flops  For circuits with other types of flip flops such as JK, the next state values are obtained by following the two step procedure: 1. Obtain the binary values of each flip-flop input equation in terms of the present state and input variables. flip-flop characteristic 2. Use the corresponding flip-flop characteristic to determine the next state.

18 18 Analysis with JK Flip Flops  J A = B  J B = x’  K A = Bx’  K B = A’x + Ax’ = A  x

19 19 JK Analysis: State Table  J A = B  K A = Bx’  J B = x’  K B = A’x + Ax’ = A  x Flip Flop Inputs JK Characteristic Table I. Use the Input equations to determine the FF inputs. next state. II. Use the FF inputs and Table to determine the next state.

20 20 JK Analysis State Table  J A = B  J B = x’  K A = Bx’  K B = A’x + Ax’ = A  x Flip Flop Inputs

21 21 JK Analysis: State Diagram 00 0110 11 1 0 0 1 1 0 1 0

22 22 Analysis vs. Design  The analysis of sequential circuits starts from a circuit diagram and culminates in a state table or state diagram.  The design of a sequential circuit starts from a set of specifications and we should obtain the state diagram and finally the logic diagram.

23 23 Design Procedure specification  Design starts from a specification and results in a logic diagram or a list of Boolean functions.  The steps to be followed are: 1. Derive a state diagram 2. Reduce the number of states 3. Assign binary values to the states 4. Obtain the binary coded state table 5. Choose the type of flip flops to be used 6. Derive the simplified flip flop input equations and output equations 7. Draw the logic diagram

24 24 Sequential Circuit Design  Remember that a synchronous sequential circuit is made up of flip flops and combinational gates.  Part of the design is to choose the flip-flop type and combinational circuit structure which, together with the flip-flops produce a circuit that fulfills the stated specification.  How many FLIP FLOPS? 1. The number of flip-flops is determined from the number of states in the circuit 2. n flip-flops can represent up to 2 n binary states. 3. Examples: 1. 2 states requires a single Flip Flop 2. 4 states requires two flip flops 3. 8 states requires three flip flops 4. 7 states requires again three flip flops …

25 25 Designing with D Flip-Flops Design a clocked sequential circuit that operates according to the state diagram.

26 26 Synthesizing Using D Flip Flops  The next step is to create a state table and then select two D flip flops to represent the four states, labeling their outputs as A and B.  There is one input, x, and one output, y, representing the input sequence and the output value respectively.  Remember that the characteristic equation of the D flip flop is  Q(t + 1) = D Q  This means that the next-state values in the state table specify the D input condition for the flip flop.

27 27 Designing with D Flip-Flops Input equations can be obtained directly from the table using minterms:  A(t + 1) = D A (A, B, x) = ∑m(2,4,5,6)  B(t + 1) = D B (A, B, x) = ∑m(1,3,5,6)

28 28 Designing with D Flip-Flops However, we have to minimize the expression in a similar way used for combinational logic design!

29 29 Designing with D Flip-Flops

30 30 Designing with D Flip-Flops D A = AB’ + BX’ D B = A’X + B’X+ ABX’ Y = B’X

31 31 A Sequence Detector  Design a circuit that detects a sequence of three ones. Circuit Detects `111’ at input InputOutput I. Create the state diagram Moore Machine

32 32 Synthesizing Using D Flip Flops II. The next step is to create a state table and then select two D flip flops to represent the four states, labeling their outputs as A and B. III. There is one input, x, and one output, y, representing the input sequence and the output value respectively. IV. The output y is `1’ only when we detect the input sequence of `111’

33 33 State Table for Sequence Detector  Input equations can be obtained directly from the table using minterms:  A(t + 1) = D A (A, B, x) = ∑m(3, 5, 7)  B(t + 1) = DB(A, B, x) = ∑m(1, 5, 7)  y(A, B, x) = ∑m(6, 7)

34 34 Boolean Minimization  K-Maps can be used to minimize the input equations, resulting in  D A = Ax + Bx  D B = Ax + B’x  Y = AB

35 35 Logic Diagram of Sequence Detector

36 36 Sequential Circuits with different Flip Flops (JK, T)  The design of sequential circuits other than D type flip flops is complicated by the fact that input equations must be derived indirectly from the state table.  It is necessary to derive a functional relationship between the state table and the input equations.

37 37 Excitation Table  During the design, we usually know the transition from present to next state but we need to find the flip flop input conditions that will cause the required transition.  We need a table that lists the required inputs for a given change of state, called an excitation table.

38 38 Excitation Tables Characteristic Table Excitation Table Characteristic Table Excitation Table

39 39 Synthesis Using JK Flip Flops  Synthesis of circuits with JK flip flops is the same as with D flip flops  Except that the input equations must be evaluated from the present-state to the next-state transition derived from the excitation table.

40 40 Example: JK Synthesis 00 11 10 01 0 0 0 1 1 1 10 Example: No output Step #1: Obtain State Table

41 41 JK Synthesis: State Table 00 Present State Next State 01 00 01

42 42 Cont.. Example JK Synthesis Step #2: Use K-Maps

43 43 Cont.. Example JK Synthesis A Bx 00011110 0 1 0001 XXXX JA = BX’

44 44 Cont.. Example JK Synthesis

45 45 Cont.. JK Synthesis Logic Diagram

46 46 Synthesis Using T Flip Flops Synthesis of circuits with T flip flops is the same as with JK flip flops … except that the input equations must be evaluated from the present-state to the next-state transition derived from the T excitation table.

47 47 Synthesis Using T Flip Flops  Design a counter that counts from “000” to “111” and then back to “000” again.  Constraint: Use T Flip-Flops

48 48 A Counter using T Flip Flops 000001010011 100101110111  Notice the only input is the clock!

49 49 Example: T Flip Flop Synthesis 0

50 50 Cont.. T Flip Flops  By using K-maps we can minimize the flip flop input equations. T T T 1 A0A0 A1A1 A2A2

51 51 One Dimensional Tables

52 52 Two Dimensional Tables Same thing, different layout

53 53 Example – Sequence Recognizer (VHDL)  Circuit has input: W and output: Z  Recognizes sequence of 11 on W Specifically, if W has been 1 and next bit is 1, make Z high  Design a Moore and Mealy Machines Sequence Recognizer W Z 1010110111

54 54 Sequence Recognizer (Mealy) Clk: t0t1t2t3t4t5t6t7t8t9t10 w:01011011101 z:00001001100 A B w=1/z=0 w=0/z=0 Reset w=0/z=0 w=1/z=1

55 55 Mealy: Implementation Clk:t0t1t2t3t4t5t6t7t8t9t10 w:01011011101 z:00001001100 A B w=1/z=0 w=0/z=0 Reset w=0/z=0 w=1/z=1

56 56 -- (Mealy Machine of Sequence Recognizer) library IEEE; use IEEE.std_logic_1164.all; entity SeqRec_Mealy is port (reset, clk, w: in std_logic; z: out std_logic); end entity SeqRec_Mealy; architecture behavioral of SeqRec_Mealy is type statetype is (A, B); -- define new type signal present_state, next_state: statetype; Begin clk_process: process(reset,clk) begin if reset = ‘1’ then -- Check for reset and initialize state present_state <= A; Elsif (rising_edge(clk)) then -- wait until the rising edge present_state <= next_state; end if; end process clk_process; end architecture behavioral; next_out_process: process(present_state,w) is begin case present_state is -- depending upon current state when A => -- set output signals and next state if w = '0' then next_state <= A; z <= ‘0'; else next_state <= B; z <= '0'; end if; when B => if w = '1' then next_state <= B; z <= ‘1'; else next_state <= A; z <= ‘0'; end if; end case; end process next_out_process; A B w=1/z=0 w=0/z=0 Reset w=0/z=0 w=1/z=1

57 57 Sequence Recognizer (Moore) A/z=0B/Z=0 C/z=1 w=1 w=0 w=1 w=0 w=1 w=0 Reset Clk: t0t1t2t3t4t5t6t7t8t9t10 w:01011011101 z:00000100110

58 58 Moore: Implementation A/z=0 B/Z=0 C/z=1 w=1 w=0 w=1 w=0 w=1 w=0 Reset Clk : t0t1t2t3t4t5t6t7t8t9t10 w:01011011101 z:00000100110

59 -- (Moore Machine of Sequence Recognizer) library IEEE; use IEEE.std_logic_1164.all; entity SeqRec_Moore is port (reset, clk, w: in std_logic; z: out std_logic); end entity SeqRec_Moore; architecture behavioral of SeqRec_Moore is type statetype is (A, B,C); -- define new type signal present_state, next_state: statetype; Begin clk_process: process( reset, clk) begin if reset = ‘1’ then -- Check for reset and initialize state present_state <= A; Elsif (rising_edge(clk)) then -- wait until the rising edge present_state <= next_state; end if; end process clk_process; next_state_process: process( present_state, w) is begin case present_state is -- depending upon current state when A => -- set next state if w = '0' then next_state <= A; else next_state <= B; end if; when B => if w = ‘0' then next_state <= A; else next_state <= C; end if; when C => if w = ‘0’ then next_state <= A; else next_state <= C; end case; end process next_state_process; output_process: process( present_state) is begin case present_state is -- depending upon current state when A => -- set output signals z<= ‘0’; when B => z<= ‘0’; when C => z<= ‘1’; end case; end process output_process; End architecture behavioral, A / z =0 B / Z =0 C/z=1 w=1 w=0 w=1 w=0 w=1 w=0 Reset 59

60

61 61 T Flip Flop Analysis  Analysis of a sequential circuit with T flip flops follows the same procedure outlined for JK flip flops.  The next state values in the state table can be obtained by using the characteristic table or the characteristic equation  Q(t + 1) = T  Q = T’Q + TQ’

62 62 T Flip Flop Analysis Example T T y A B R R x CLKReset  T A = Bx  T B = x  Y = AB

63 63 T Flip Flop Analysis State Table  T A = Bx  T B = x  Y = AB  A(t + 1) = T A  A = Bx  A  B(t + 1) = T B  B = x  B


Download ppt "ENG241 Digital Design Week #7 Sequential Circuits (Part B)"

Similar presentations


Ads by Google