Download presentation
Presentation is loading. Please wait.
1
ECE 352 Digital System Fundamentals
Intro to Sequential Circuits In this presentation, we will introduce sequential circuits.
2
Definitions Combinational Circuit Sequential Circuits
Outputs are a function of only current circuit inputs Sequential Circuits Outputs are a function of not only the current circuit inputs but also what has happened in the past Example: An automated sign that shows how many parking spots are free in a parking deck by keeping track of when cars enter or leave We don’t need to remember anything about specific cars, only how many are still in the garage! Can also think of sequential circuits as blocks of combinational logic separated by flip-flops The circuits we’ve worked with so far have been combinational, where the output depends only on the present values of the inputs. In a sequential circuit, the output also depends on some information about the past. For example, think about an automatic sign that displays how full a parking garage is. It really doesn’t need to know anything about specific cars, or even how many entered and how many left. All it needs to do is increment a count every time a car enters, and decrement the count every time a car leaves. It does have to remember the current count. When working with sequential circuits, you still need to know how to work with combinational circuits. That’s because sequential circuits are in fact constructed from flip-flops and blocks of combinational logic.
3
State The “state” of matter: solid, liquid, gas, plasma
The “state” of a circuit: the set of values stored in its flip-flops (which represent its status) A code of 1s and 0s that representing everything “important” that happened since the circuit was reset A circuit’s state affects how that circuit reacts to different sets of input values Examples: The state of a washing machine includes its current cycle (wash, rinse, spin) and the time left in the cycle The state of a vending machine includes the amount of money entered (not necessarily the exact coins!) The word state has a very specific meaning in sequential circuits. You are used to talking about the state of matter – it describes the way in which the matter exists at a specific time, which affects the way it behaves at that time. A liquid will flow, but a solid will not. The state of a sequential circuit also affects the way in which the circuit will behave at a given time. It is the set of values that are stored in its flip-flops. Those 1s and 0s are a code that represents everything about the past that is relevant to the circuit. How the circuit reacts to some set of inputs will depend in part on what state it is in – this is how we make a digital machine behave differently under different conditions. For example, a washing machine needs to know that it is in the wash cycle and how much time is left in that cycle to know whether or not it should stay in the wash cycle or transition to the rinse cycle. A vending machine needs to know how much money has already been inserted so it knows when it should dispense the product.
4
Finite State Machine (FSM)
A sequential circuit that has a finite number of possible states Limited by the number of flip-flops in the circuit All practical sequential circuits are FSMs We commonly use this term to refer to machines that perform tasks rather than just store data for later retrieval (such as memory in a computer) A finite state machine, or FSM, is a sequential circuit that has a finite number of flip-flops. Since each flip-flop has only two states (1 and 0), the FSM also has a finite number of possible states. All practical sequential circuits are FSMs. In practice, we usually use the term FSM to describe a machine that performs some task, as opposed to a memory device that just stores data.
5
Synchronous Sequential Circuits
Storage elements hold current state: a code that provides information from the past that the circuit uses in determining how to react to new input values A special signal called a clock marks the passage of time Synchronous: ruled by the clock (synchronized to the clock) The clock goes DIRECTLY to the flip-flops—don’t gate the clock! The clock alternates between 0 and 1 at a constant rate Cycle: from one rising/falling edge to the next rising/falling edge Period: the length of time of a clock cycle The storage elements in a sequential circuit hold the current state of the circuit. The current state is a code that determines how the machine will react to the inputs. In this course, we will focus on synchronous sequential circuits, which means that the circuit’s activity is governed by a clock. The storage elements are flip-flops and the clock signal controls when they update. The clock is simply a signal that alternates between 1 and 0 at a constant frequency. Once during each cycle of the clock, the flip-flops update to the next state value, so the clock is like a digital “heartbeat”. The clock goes directly to ALL of the flip-flops in the circuit, so that every flip-flop updates at the same instant. You should NEVER add any logic in the clock path – at that point you are trying to become an ASYNCHRONOUS circuit designer, and it is probably going to go poorly.
6
Synchronous Sequential Circuits
Once per clock cycle, the values in the storage elements are updated with the new state information The “next state” becomes the “current state” The next state values are produced by a combinational function of the current state values and the circuit inputs The circuit outputs are produced by a combinational function of the current state and possibly the circuit inputs Basically, a synchronous sequential circuit consists of a group of flip-flops that hold the state. The state is updated once per clock cycle, and what was the “next state” becomes the “current state”. The circuit also includes combinational logic, which determines the next state based on the current state and the circuit input values. The circuit output values are determined by some combinational logic function of the current state and possibly the circuit inputs.
7
Anatomy of a Simple Seq. Circuit
What the state will become at the next cycle What the state is now in this cycle Next State Current State Circuit Inputs Circuit Output Clock Here we have very simple example of a sequential circuit. The circuit has one flip-flop, so it has only two states. The clock signal goes directly to the flip-flop. A direct clear input allows us to start the machine with a 0 stored in the flip-flop, which we would say is state 0. There are two circuit inputs, A and B. The current state is simply the value stored in the flip-flop. Again, this is the state during the current clock cycle. The next state is the value at the input to the flip-flop, since at the clock edge that value will be stored in the flip-flop and become the current state. The circuit has a single output, which is a function of the current state and input B. Reset
8
Current vs. Next State Current state is the set of values that are stored in the FFs at a given time Remember: FFs output their current values Next state is the set of values that will be stored into the FFs when they change state The inputs to the FFs that have not yet been stored into the FFs Understanding the difference between these two is very important! It is important to know the difference between where the current state and the next state exist in the circuit. The current state is the set of values stored in the flop-flops, which is visible on the Q output of the flip-flops. The next state is the set of values that will be stored into the flip-flops at the next clock edge. Remember that values on the flip-flop D input ONLY affect the flip-flop’s state at the active clock edge. Understanding the difference between these two is essential to effectively working with sequential circuits.
9
State Table Lists the next state and circuit output values for all possible current state and circuit input values Essentially a truth table that shows all possible combinations of current state and circuit inputs and the resulting next state and circuit outputs The equations for the next state represent combinational logic that feeds the FF inputs aka input forming logic (IFL) The output equations may be: Based exclusively on the FF outputs (Moore) Based on FF outputs and circuit inputs (Mealy) A state table is simply an ordered list of all possible combinations of current state and input values, with the next state and output values shown for each combination. It is essentially a compact truth table for each flip-flop input (the next state) and each circuit output, as function of current state and the circuit inputs. We use the state table to derive the equations for the combinational logic feeding each flip-flop D input, also known as the input forming logic. We also derive the equations for each circuit output from the state table. If all of the circuit’s outputs depend only on the current state, then we call it a Moore machine. If any of the circuit’s outputs depend on the current state and circuit inputs, we call it a Mealy machine. We’ll talk more about the ramifications of this distinction later. As a memory aid, the machine that depends ONLY on the current state has a letter “o” in the name. If it isn’t a Moore machine, then it must be Mealy.
10
State Tables in Circuit Analysis
Examine the diagram and write equations for the circuit’s flip-flop inputs and circuit outputs Use those equations to fill in the state table Examine the state table (and/or equations) to see what the circuit does D = A ⨁ Q We can use a state table to analyze what a sequential circuit does. We start with a state table listing all combinations of current state and input values. We then write a logic equation for the flip-flop input, and use it to fill in the next state column. We also write the output equation, and fill in the output column. By examining the current state and output columns, we see that this is a Moore machine. We could have reached the same conclusion by simply observing that the output logic equation only depended on Q; it did not include input A. Y = Q Moore: Output depends only on the current state
11
Waveform Example D = A ⨁ Q Y = Q “Toggle” the output if input A is 1
Now, let’s look at a waveform showing the circuit’s operation over time. Note that we apply the RST signal at the start of the waveform, forcing the machine into state 0. We’ll use the logic equations for D and Y to help us complete the waveform. In the first phase of the clock signal, Q is forced to 0 by the reset, and so will remain 0 until the next active clock edge. At the first positive edge of the clock, the flip-flop D value is stored. Since D was 0, the machine remains in state 0. At the next positive edge, D is 1 so the flip-flop updates to 1 and the machine is now in state 1. At the next positive edge, D is 0, so the machine goes to state 0. Note that the value of D changed to 1 immediately after the clock edge, but that was because Q had changed in response to the clock edge. That change on D thus doesn’t affect what is stored in the flip-flop. At the next edge, D is 0, so the machine stays in state 0. At the next clock edge, D is 1 so the machine goes to state 1. So what does the machine do? Note that whenever A is 1, the state (and output) changes at the clock edge, and when A is 0, the state (and output) do not change. We would say this machine “toggles” its output when A is 1. D = A ⨁ Q Y = Q
12
State Tables in Circuit Design
Fill in the desired circuit behavior in the state table for each current state / input combination Use state table to create minimized logic equations for flip-flop inputs and circuit outputs Equation inputs: flip-flop outputs and circuit inputs Equation outputs: flip-flop inputs and circuit outputs The logic that determines the next state (FF inputs) and the circuit outputs is some combinational function of the current state (FF outputs) and the circuit inputs We can also use state tables to design sequential circuits. We fill in the desired behavior by choosing next state and output values for each possibility of current state and circuit input values. Then, we use the information in the state table to determine the next state and output logic. Remember that the state stable is in fact a truth table for each flip-flop input and each circuit output, as functions of the flip-flop outputs (the current state) and the circuit inputs.
13
State Tables in Circuit Design
D = A Y = A ⨁ Q D Y Let’s look at an example. We’ve decided that the circuit should have the behavior shown in the state table. We start with a flip-flop with an asynchronous clear input. The clock signal is, of course, directly connected to the flip-flop clock input. We can see that the next state logic is simply D = A, so we make that connection. The current state is in fact “remembering” the previous value of A. But what if we couldn’t tell what the logic was for D? Then we’d create a K-map for D with input values Q and A, and solve it. The logic for Y isn’t quite as obvious, so let’s do a K-map for Y as a function of Q and A. The K-map shows that Y is A XOR Q, so we need to add that logic to our circuit. D = Y = Q A + Q A A = A ⊕ Q
14
State Tables in Circuit Design
D = A Y = A ⨁ Q Detect if input’s current value is different than it was at the end of the previous cycle Let’s look at the behavior of this circuit on a waveform. Again, we show the functions for D and Y for easy reference. In the first phase of the clock, the flip-flop is forced to state 0 by the asynchronous reset. D is also 0, so it remains in state 0 after the first active clock edge. During the next cycle, A becomes 1. Note that the output changed as well, since it is a function of both the state and the circuit input. At the second positive edge, D is 1, so the machine goes to state 1. In the next cycle, D changes to 0, so the machine goes to state 0 at the clock edge. The behavior continues in the next two cycles. So what does this machine do? Looking at output Y, you can see it is always a 1 if the current value of A is different from the previous value, so this circuit will detect a change in A. D = A Y = A ⨁ Q
15
Another FSM Example D1 = Q1 ⊕ Q0 ⊕ A D0 = Q0 Y = Q1 + Q0
Here’s a final example that you can use to test your understanding of how state tables and sequential circuits relate. Note that the state table has two bits of state, so this machine has four possible states. Given the state table, you should be able to derive the equations shown here. The next state and output logic is always a function of the current state and the circuit inputs. In this case, the circuit input is optimized out of the equation for Y, making it a function of only the current state. It is a Moore machine. With those equations, you should be able to create an FSM that implements the required behavior. Note that each flip-flop stores a single bit of the state, and is updated by the corresponding bit of the next state logic. You should also be able to do this in reverse order – given the circuit, determine the next state and output equations, and use those to complete a state table. D1 = Q1 ⊕ Q0 ⊕ A D0 = Q0 Y = Q1 + Q0
16
ECE 352 Digital System Fundamentals
Intro to Sequential Circuits This concludes our introduction to sequential circuits.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.