CS147

1 / 52

# CS147 - PowerPoint PPT Presentation

CS147 . Lecture 9. Sequential Circuits and Finite State Machines Prof. Sin-Min Lee Department of Computer Science. Example of combinational and sequential logic. Combinational: input A, B wait for clock edge observe C wait for another clock edge observe C again: will stay the same

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'CS147' - neviah

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### CS147

Lecture 9

Sequential Circuits and Finite State Machines

Prof. Sin-Min Lee

Department of Computer Science

Example of combinational and sequential logic
• Combinational:
• input A, B
• wait for clock edge
• observe C
• wait for another clock edge
• observe C again: will stay the same
• Sequential:
• input A, B
• wait for clock edge
• observe C
• wait for another clock edge
• observe C again: may be different

A

C

B

Clock

Basically
• Combinational:
• No internal state (or memory or history or whatever you want to call it)
• Output depends only on input
• Sequential:
• Output depends on internal state
• Probably not going to be on this midterm since formal lecture on it started last Thursday.
Design hierarchy

system

control

data-path

coderegisters

stateregisters

combinationallogic

multiplexer

comparator

register

logic

switchingnetworks

J

Q

CLK

To Be

Designed

D

Q’

K

Recap - Sequential Systems
• Example:
• Design a D FF with a JK FF and AND, OR, NOT gates:

D

- -

1 0

0 1

- -

Q

K = D’

J = D

D

D

J

Q

CLK

Q

Q’

K

Sequential Systems - Cont.

Analysis of Sequential Systems

• Goal:
• Decide the timing and functional behavior from the implementation of a sequential system composed of FFs and logic gates
• Types:
• Functional analysis
• Timing analysis

State Transition:

Output:

Example

Input

Output

State

Encoding Scheme

State Transition Table

Example (Cont’d)

High-Level Specification

State Diagram

Time-behavior Specification

JAKA, JBKB

10,01

01,01

10,10

01,10

00,00

01,00

10,10

11,10

Example

Design a single-input, single-output synchronous sequence detector with input labeled by x. Every time a pattern of sequence 0101 is detected, this sequence detector produces an output y = 1. Otherwise, y = 0. For example, when the input sequence is 01010100, the corresponding output sequence is 00010100.

Step 1: Derive the state digram. We can construct the state diagram of the detector with four states, A, B, C, and D.

Why four? What do they mean? A: ground zero; we don’t have any of the desired sequence. B: just got the leading 0 C: just got 01 D: just got 010 If we’re in state D and we see ‘1’ on x, we set the output y high.

Step 2: Derive the state table.

Step 3: It is impossible to reduce the number of states for this example.

If A and B are equivalent, A and C must be equivalent, which implies B and D are equivalent. The latter (B and D are equivalent) is not true, and hence A and B are NOT equivalent. We may apply the argument above to all pairs of states to find out that no two states are equivalent.

we need two state variables, S1 and S0, and the values assigned to the

four states are         ,          ,         , and          . Now the state table

looks like:

Step 5: From Step 4, we know that we need two flip flops because we have two state variables. We will discuss two cases: (1) use of D flip flops; (2) use of JK flip flops to implement the sequence detector.

Step 6: Derive the circuit excitation and output tables. If we use the D flip flops, then we have

During the design phase, we usually know the transition from present state to next state and need to find the FF input condition that will cause the required transition. That is, we need to know how to exercise the circuit so that given the present state, the circuit will go to some specific next state.

Take J-K flip flops as examples. Given the present state 0, to drive the circuit so that its next state is 0, we may either keep the circuit unchanged (i.e., applying J=K=0) or reset the circuit (i.e., applying J=0, K=1). That is, the inputs to the FF are J=0 and K= don't care. Similarly, given the present state 0, to drive the circuit so that its next state is 1, we may either set the circuit (i.e., applying J=1, K=0) or toggle the circuit (i.e., applying J=K=1). That is, the inputs to the FF are J=1 and K = don't care.

Step 7: Derive the circuit output functions and the flip-flop input functions.

If we use D flip flops, we should derive, using K-maps, D1 and D0 as functions of the present states S1, S0, and the input x, respectively. On the other hand, if we use JK flip flops, we should derive J1, K1, J0, and K0 as functions of the present states S1, S0, and the input x. For example, to derive the expression for J1, we construct the following K-map:

Hence, J1= S0x.

Registers and Counters
• A n-bit register is a set of n flip-flops that is capable of storing n bits of binary information. With added combinational gates, the register can perform data-processing tasks.
• A counter is a register that goes through a predetermined sequence of states upon the application of clock pulses.

Example

Counter design: Use J-K flip flops to design a counter that repeatedly counts the following binary sequence: 0, 1, 2, 4, 5, and 6.

Steps 2 through 6: Derive the state table and the circuit excitation table

Note that two states, 011 and 111, are not included in the count, and hence their corresponding J and K inputs are don't care.

Step 7: Derive the circuit output functions. By use of K-maps (with those don't cares figured in), the simplified functions are

It has one input x, one output Z and two state variables Q1Q2

(thus having four possible present states 00, 01, 10, 11).

The behaviour of the circuit is determined by the following

Boolean expressions:

Z = x*Q1

D1 = x' + Q1

D2 = x*Q2' + x'*Q1'

These equations can be used to form the state table.

Z = x*Q1

D1 = x' + Q1

D2 = x*Q2' + x'*Q1'

These equations can be used to form the state table.

in Figure 5.

Excitation tables
• The design process for an FSM involves determining the combinatorial logic to be used as input to each flip-flop input line. The SR and JK flip-flops have two lines, and it is possible that there may be more than one possible combination of inputs which will cause a flip-flop in state X to go to state Y. We therefore need to construct what are known as excitation tables. These define the input combinations to a flip-flop to implement defined changes of state.