henry hexmoor1 sequential circuits chapter 6 henry hexmoor-- siuc

88
Henry Hexmoor 1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Upload: gregory-poole

Post on 21-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 1

Sequential Circuits Chapter 6

Henry Hexmoor-- SIUC

Page 2: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 2

Introduction to Sequential Circuits

A Sequential circuit contains:• Storage elements:

Latches or Flip-Flops • Combinatorial Logic:

Implements a multiple-output switching function

Inputs are signals from the outside. Outputs are signals to the outside. Other inputs, State or Present State, are

signals from storage elements. The remaining outputs, Next State are

inputs to storage elements.

Combina-tionalLogic

Storage Elements

Inputs Outputs

StateNextState

Page 3: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 3

Combinatorial Logic• Next state function

Next State = f(Inputs, State)Mealy circuit:

Outputs = g(Inputs, State)Moore circuit:

Outputs = h(State) Output function type depends on specification and affects the

design significantly

Combina-tionalLogic

Storage Elements

Inputs Outputs

StateNextState

Sequential Circuits

Page 4: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 4

Types of Sequential Circuits

Depends on the times at which:• storage elements observe their inputs, and • storage elements change their state

Synchronous• Behavior defined from knowledge of its signals at discrete

instances of time• Storage elements observe inputs and can change state only in

relation to a timing signal (clock pulses from a clock) Asynchronous

• Behavior defined from knowledge of inputs an any instant of time and the order in continuous time in which inputs change

• If clock just regarded as another input, all circuits are asynchronous!

• Nevertheless, the synchronous abstraction makes complex designs tractable!

Page 5: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 5

Discrete Event Simulation

In order to understand the time behavior of a sequential circuit we use discrete event simulation.

Rules:• Gates modeled by an ideal (instantaneous) function

and a fixed gate delay• Any change in input values is evaluated to see if it

causes a change in output value• Changes in output values are scheduled for the fixed

gate delay after the input change• At the time for a scheduled output change, the

output value is changed along with any inputs it drives

Page 6: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 6

Gate Delay Models

Suppose gates with delay n ns are represented for n = 0.2 ns, n = 0.4 ns,n = 0.5 ns, respectively:

0.2 0.50.4

Page 7: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 7

Consider a simple 2-input multiplexer:

With function:• Y = A for S = 0• Y = B for S = 1

Glitch” is due to delay of inverter

A

0.4

0.5

0.4

SB

Y0.2

Circuit Delay Model

A

SB

YS

Page 8: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 8

What is memory

A memory should have at least three properties.

1. It should be able to hold a value.

2. You should be able to read the value that was saved.

3. You should be able to change the value that’s saved.

We’ll start with the simplest case, a one-bit memory.

1. It should be able to hold a single bit, 0 or 1.

2. You should be able to read the bit that was saved.

3. You should be able to change the value. Since there’s only a single bit, there are only two choices:– Set the bit to 1

– Reset, or clear, the bit to 0.

Page 9: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 9

Basic storage

How can a circuit “remember” anything, when it’s just a bunch of gates that produce outputs according to the inputs?

The basic idea is to make a loop, so the circuit outputs are also inputs. Here is one initial attempt, shown with two equivalent layouts:

Does this satisfy the properties of memory?• These circuits “remember” Q, because its value never changes. (Similarly, Q’

never changes either.)

• We can also “read” Q, by attaching a probe or another circuit.

• But we can’t change Q! There are no external inputs here, so we can’t control whether Q=1 or Q=0.

Page 10: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 10

A really confusing circuit Let’s use NOR gates instead of inverters. The

SR latch (right) has two inputs S and R, which will let us control the outputs Q and Q’.

Here Q and Q’ feed back into the circuit. They’re not only outputs, they’re also inputs!

To figure out how Q and Q’ change, we have to look at not only the inputs S and R, but also the current values of Q and Q’:

Qnext = (R + Q’current)’

Q’next = (S + Qcurrent)’

Let’s see how different input values for S and R affect this thing.

R S Nor

0 0 1

0 1 0

1 0 0

1 1 0

Page 11: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 11

Qnext = (R + Q’current)’Q’next = (S + Qcurrent)’

Latch delays Timing diagrams are useful in

understanding how sequential circuits work.

Here is a diagram which shows an example of how our latch outputs change with inputs RS=01.

0. Suppose that initially, Q = 0 and Q’ = 1.

1. Since S=1, Q’ will change from 1 to 0after one NOR-gate delay

(marked byvertical lines in the diagram for

clarity).

2. This change in Q’, along with R=0, causes Q to become 1 after another gate delay.

3. The latch then stabilizes until S or Rchange again.

S

R

Q

Q’

0 1 2 3 4

Page 12: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 12

SR latches are memories!

This little table shows that our latch provides everything we need in a memory: we can set it, reset it, and remember the current value.

The output Q represents the data stored in the latch. It is sometimes called the state of the latch.

We can expand the table above into a state table, which explicitly shows that the next values of Q and Q’ depend on their current values, as well as on the inputs S and R.

S R Q

0 0 No change0 1 0 (reset)1 0 1 (set)

I nputs Current NextS R Q Q’ Q Q’

0 0 0 1 0 10 0 1 0 1 0

0 1 0 1 0 10 1 1 0 0 11 0 0 1 1 01 0 1 0 1 0

Page 13: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 13

S’R’ latch

There are several varieties of latches. You can use NAND instead of NOR gates to get a S’R’ latch.

This is just like an SR latch, but with inverted inputs, as you can see from the table.

You can derive this table by writing equations for the outputs in terms of the inputs and the current state, just as we did for the SR latch.

S’ R’ Q

1 1 No change1 0 0 (reset)0 1 1 (set)0 0 Avoid!

Page 14: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 14

An SR latch with a control input

Here is an SR latch with a control input C.

Notice the hierarchical design!• The dotted blue box is the S’R’ latch from the previous slide.

• The additional NAND gates are simply used to generate the correct inputs for the S’R’ latch.

The control input acts just like an enable.

C S R S’ R’ Q

0 x x 1 1 No change1 0 0 1 1 No change1 0 1 1 0 0 (reset)1 1 0 0 1 1 (set)1 1 1 0 0 Avoid!

Page 15: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 15

D latch

Finally, a D latch is based on an S’R’ latch. The additional gates generate the S’ and R’ signals, based on inputs D (“data”) and C (“control”).

• When C = 0, S’ and R’ are both 1, so the state Q does not change.

• When C = 1, the latch output Q will equal the input D.

No more messing with one input for set and another input for reset!

Also, this latch has no “bad” input combinations to avoid. Any of the four possible assignments to C and D are valid.

C D Q

0 x No change1 0 01 1 1

DQ

C

Q

C

D Q

Q

Page 16: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 16

Sequential circuits and state diagrams To describe combinational circuits, we used Boolean

expressions and truth tables. With sequential circuits, we can still use expression and tables, but we can also use another form called a state diagram.

We draw one node for each state that the circuit can be in. Latches have only two states: Q=0 and Q=1.

Arrows between nodes are labeled with “input/output” and indicate how the circuit changes states and what its outputs are. In this case the state and the output are the same.

Basically the same as the finite state automata. Here’s a state diagram for a D latch with inputs D and C.

0x/0 0x/1

Q=0 Q=111/1

10/0

Page 17: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 17

Using latches in real life

We can connect some latches, acting as memory, to an ALU.

Let’s say these latches contain some value that we want to increment.• The ALU should read the current latch value.

• It applies the “G = X + 1” operation.

• The incremented value is stored back into the latches.

At this point, we have to stop the cycle, so the latch value doesn’t get incremented again by accident.

One convenient way to break the loop is to disable the latches.

+1ALU

S

XG

LatchesD

QC

Page 18: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 18

The problem with latches

The problem is exactly when to disable the latches. You have to wait long enough for the ALU to produce its output, but no longer.

• But different ALU operations have different delays. For instance, arithmetic operations might go through an adder, whereas logical operations don’t.

• Changing the ALU implementation, such as using a carry-lookahead adder instead of a ripple-carry adder, also affects the delay.

In general, it’s very difficult to know how long operations take, and how long latches should be enabled for.

+1ALU

S

XG

LatchesD

QC

Page 19: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 19

Memory Summary

A sequential circuit has memory. It may respond differently to the same inputs, depending on its current state.

Memories can be created by making circuits with feedback.• Latches are the simplest memory units, storing individual bits.

• It’s difficult to control the timing of latches in a larger circuit.

Next, we’ll improve upon latches with flip-flops, which change state only at well-defined times. We will then use flip-flops to build all sequential circuits.

Page 20: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 20

Flip-Flops

Latches introduce new problems:• We need to know when to enable a latch.

• We also need to quickly disable a latch.

• In other words, it’s difficult to control the timing of latches in a large circuit.

We solve these problems with two new elements: clocks and flip-flops

• Clocks tell us when to write to our memory.

• Flip-flops allow us to quickly write the memory at clearly defined times.

• Used together, we can create circuits without worrying about the memory timing.

Page 21: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 21

Making latches work right

Our example used latches as memory for an ALU.• Let’s say there are four latches initially storing 0000.

• We want to use an ALU to increment that value to 0001.

Normally the latches should be disabled, to prevent unwanted data from being accidentally stored.

• In our example, the ALU can read the current latch contents, 0000, and compute their increment, 0001.

• But the new value cannot be stored back while the latch is disabled.

+1ALU

S

XG

LatchesD

QC 0

00000001

Page 22: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 22

Writing to the latches After the ALU has finished its increment operation, the

latch can be enabled, and the updated value is stored.

The latch must be quickly disabled again, before the ALU has a chance to read the new value 0001 and produce a new result 0010.

+1ALU

S

XG

LatchesD

QC 1

00010001

+1ALU

S

XG

LatchesD

QC 0

00010010

Page 23: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 23

So to use latches correctly within a circuit, we have to:• Keep the latches disabled until new values are ready to be stored.

• Enable the latches just long enough for the update to occur.

There are two main issues we need to address:

How do we know exactly when the new values are ready?

We’ll add another signal to our circuit. When this newsignal becomes 1, the latches will know that the ALUcomputation has completed and data is ready to be stored.

How can we enable and then quickly disable the latches?

This can be done by combining latches together in aspecial way, to form what are called flip-flops.

Two main issues

Page 24: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 24

Clocks and synchronization

A clock is a special device that whose output continuously alternates between 0 and 1.

The time it takes the clock to change from 1 to 0 and back to 1 is called the clock period, or clock cycle time.

The clock frequency is the inverse of the clock period. The unit of measurement for frequency is the hertz.

Clocks are often used to synchronize circuits.• They generate a repeating, predictable pattern of 0s and 1s that can trigger certain

events in a circuit, such as writing to a latch.• If several circuits share a common clock signal, they can coordinate their actions with

respect to one another.

This is similar to how humans use real clocks for synchronization.

clock period

Page 25: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 25

More about clocks

Clocks are used extensively in computer architecture. All processors run with an internal clock.

• Modern chips run at frequencies above 3.2 GHz.

• This works out to a cycle time smaller than 0.31 ns!

Memory modules are often rated by their clock speedstoo—examples include “PC133” and “DDR400” memory.

Be careful...higher frequencies do not always mean faster machines!

• You also have to consider how much work is actually being done during each clock cycle.

• How much stuff can really get done in just 0.31 ns.

Page 26: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 26

Synchronizing our example We can use a clock to synchronize our latches with the ALU.

• The clock signal is connected to the latch control input C.• The clock controls the latches. When it becomes 1, the latches will be enabled for writing.

The clock period must be set appropriately for the ALU.• It should not be too short. Otherwise, the latches will start writing before the ALU

operation has finished.• It should not be too long either. Otherwise, the ALU might produce a new result that will

accidentally get stored, as we saw before.

The faster the ALU runs, the shorter the clock period can be.

+1ALU

S

XG

LatchesD

QC

Page 27: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 27

The second issue was how to enable a latch for just an instant. Here is the internal structure of a D flip-flop.

• The flip-flop inputs are C and D, and the outputs are Q and Q’.• The D latch on the left is the master, while the SR latch on the right is called

the slave.

Note the layout here.• The flip-flop input D is connected directly to the master latch.• The master latch output goes to the slave.• The flip-flop outputs come directly from the slave latch.

Flip-flops

Page 28: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 28

The D flip-flop’s control input C enables either the D latch or the SR latch, but not both.

When C = 0:• The master latch is enabled, and it monitors the flip-flop input D.

Whenever D changes, the master’s output changes too.

• The slave is disabled, so the D latch output has no effect on it. Thus, the slave just maintains the flip-flop’s current state.

D flip-flops when C=0

Page 29: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 29

D flip-flops when C=1

As soon as C becomes 1,• The master is disabled. Its output will be the last D input value seen

just before C became 1.

• Any subsequent changes to the D input while C = 1 have no effect on the master latch, which is now disabled.

• The slave latch is enabled. Its state changes to reflect the master’s output, which again is the D input value from right when C became 1.

Page 30: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 30

Positive edge triggering

This is called a positive edge-triggered flip-flop.• The flip-flop output Q changes only after the positive edge of C.

• The change is based on the flip-flop input values that were present right at the positive edge of the clock signal.

The D flip-flop’s behavior is similar to that of a D latch except for the positive edge-triggered nature, which is not explicit in this table.

C D Q

0 x No change1 0 0 (reset)1 1 1 (set)

Page 31: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 31

Direct inputs One last thing to worry about… what is the starting value of Q? We could set the initial value synchronously, at the next positive clock

edge, but this actually makes circuit design more difficult. Instead, most flip-flops provide direct, or asynchronous, inputs that let

you immediately set or clear the state.• You would “reset” the circuit once, to initialize the flip-flops.

• The circuit would then begin its regular, synchronous operation.

Here is a LogicWorks D flip-flop with active-low direct inputs.

S’ R’ C D Q

0 0 x x Avoid!0 1 x x 1 (set)1 0 x x 0 (reset)

1 1 0 x No change1 1 1 0 0 (reset)1 1 1 1 1 (set)

Direct inputs to set or reset the flip-flop

S’R’ = 11 for “normal” operation of the D flip-flop

Page 32: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 32

Direct Inputspage 256

At power up or at reset, all or partof a sequential circuit usually isinitialized to a known state beforeit begins operation

This initialization is often doneoutside of the clocked behaviorof the circuit, i.e., asynchronously.

Direct R and/or S inputs that control the state of the latches within the flip-flops are used for this initialization.

For the example flip-flop shown • 0 applied to R resets the flip-flop to the 0 state

• 0 applied to S sets the flip-flop to the 1 state

D

C

S

R

Q

Q

Page 33: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 33

We can use the flip-flops’ direct inputs to initialize them to 0000.

During the clock cycle, the ALU outputs 0001, but this does not affect the flip-flops yet.

Our example with flip-flops

+1ALU

S

XG

Flip-flopsD

QC

0000

+1ALU

S

XG

Flip-flopsD

QC

00000001

C

Q0

G0

C

Q0

G0

Page 34: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 34

Example continued The ALU output is copied into the flip-flops at the next positive edge of

the clock signal.

The flip-flops automatically “shut off,” and no new data can be written until the next positive clock edge... even though the ALU produces a new output.

+1ALU

S

XG

Flip-flopsD

QC

00010010

+1ALU

S

XG

Flip-flopsD

QC

00010001

C

Q0

G0

C

Q0

G0

Page 35: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 35

Flip-flop variations

We can make different versions of flip-flops based on the D flip-flop, just like we made different latches based on the S’R’ latch.

A JK flip-flop has inputs that act like S and R, but the inputs JK=11 are used to complement the flip-flop’s current state.

A T flip-flop can only maintain or complement its current state.

C T Qnext

0 x No change1 0 No change1 1 Q’current

C J K Qnext

0 x x No change1 0 0 No change1 0 1 0 (reset)1 1 0 1 (set)1 1 1 Q’current

Page 36: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 36

Characteristic tables

The tables that we’ve made so far are called characteristic tables.

• They show the next state Q(t+1) in terms of the current state Q(t) and the inputs.

• For simplicity, the control input C is not usually listed.

• Again, these tables don’t indicate the positive edge-triggered behavior of the flip-flops that we’ll be using.

D Q(t+1) Operation

0 0 Reset1 1 Set

T Q(t+1) Operation

0 Q(t) No change1 Q’(t) Complement

J K Q(t+1) Operation

0 0 Q(t) No change0 1 0 Reset1 0 1 Set1 1 Q’(t) Complement

Page 37: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 37

Characteristic equations We can also write characteristic equations, where the next state

Q(t+1) is defined in terms of the current state Q(t) and inputs.

D Q(t+1) Operation

0 0 Reset1 1 Set

T Q(t+1) Operation

0 Q(t) No change1 Q’(t) Complement

J K Q(t+1) Operation

0 0 Q(t) No change0 1 0 Reset1 0 1 Set1 1 Q’(t) Complement

Q(t+1) = D

Q(t+1)= K’Q(t) + JQ’(t)

Q(t+1)= T’Q(t) + TQ’(t)= T Q(t)

Page 38: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 38

Flip Flop Summary

To use memory in a larger circuit, we need to:• Keep the latches disabled until new values are ready to be stored.

• Enable the latches just long enough for the update to occur.

A clock signal is used to synchronize circuits. The cycle time reflects how long combinational operations take.

Flip-flops further restrict the memory writing interval, to just the positive edge of the clock signal.

• This ensures that memory is updated only once per clock cycle.

• There are several different kinds of flip-flops, but they all serve the same basic purpose of storing bits.

Page 39: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 39

Master-Slave:Postponed outputindicators

Edge-Triggered:Dynamicindicator

(a) Latches

S

R

SR SR

S

R

D with 0 Control

D

C

D with 1 Control

D

C

(b) Master-Slave Flip-Flops

D

C

Triggered DTriggered SR

S

R

C

D

C

Triggered DTriggered SR

S

R

C

(c) Edge-Triggered Flip-Flops

Triggered D

D

C

Triggered D

D

C

Standard Symbols for Storage Elements

Page 40: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 40

ts - setup time

th - hold time

tw - clock

pulse width

tpx - propa-

gation delay• tPHL - High-to-

Low

• tPLH - Low-to-High

• tpd - max (tPHL, tPLH)

ts th

tp-,mintp-,max

twH$ twH,min

twL$ twL,minC

D

Q

(b) Edge-triggered (negative edge)

thts

tp-,mintp-,max

twH$ twH,min

twL$ twL,minC

S/R

Q(a) Pulse-triggered (positive pulse)

Flip-Flop Timing Parameters- page 257

Page 41: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 41

Sequential Circuit Analysis6-4

General Model• Current State

at time (t) is stored in an array offlip-flops. 

• Next State at time (t+1) is a Boolean function of State and Inputs.

• Outputs at time (t) are a Boolean function of State (t) and (sometimes) Inputs (t).

Combina-tionalLogic

Inputs

StateNextState

Outputs

Storage Elements

CLK

Page 42: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 42

Example 1 (Figure 6-17)

Input: x(t) Output: y(t) State: (A(t), B(t)) What is the Output

Function?

What is the Next State Function?

AC

D Q

Q

C

D Q

Q

y

x A

B

CP

Page 43: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 43

Example 1 (from Figure 6-17) (page 260)

Boolean equations for the functions:• A(t+1) = A(t)x(t)

+ B(t)x(t)

• B(t+1) = A(t)x(t)

• y(t) = x(t)(B(t) + A(t))

C

D Q

Q

C

D Q

Q'

y

xA

A

B

CP

Next State

Output

Page 44: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 44

State Table Characteristics

State table – a multiple variable table with the following four sections:• Present State – the values of the state variables for

each allowed state.• Input – the input combinations allowed.• Next-state – the value of the state at time (t+1) based

on the present state and the input.• Output – the value of the output as a function of the

present state and (sometimes) the input. From the viewpoint of a truth table:

• the inputs are Input, Present State• and the outputs are Output, Next State

Page 45: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 45

Example 1: State Table (from Figure 6-17)

The state table can be filled in using the next state and output equations:

A(t+1) = A(t)x(t) + B(t)x(t) B(t+1) =A (t)x(t)

y(t) =x (t)(B(t) + A(t))Present State Input Next State Output

A(t) B(t) x(t) A(t+1) B(t+1) y(t) 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0

Page 46: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 46

Example 1: Alternate State Table

2-dimensional table that matches well to a K-map. Present state rows and input columns in Gray code order.

• A(t+1) = A(t)x(t) + B(t)x(t)

• B(t+1) =A (t)x(t)

• y(t) =x (t)(B(t) + A(t))

Present State

Next State x(t)=0 x(t)=1

Output x(t)=0 x(t)=1

A(t) B(t) A(t+1)B(t+1) A(t+1)B(t+1) y(t) y(t) 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 0 1 0

Page 47: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 47

State Diagrams

The sequential circuit function can be represented in graphical form as a state diagram with the following components:• A circle with the state name in it for each state• A directed arc from the Present State to the Next

State for each state transition• A label on each directed arc with the Input values

which causes the state transition, and• A label:

On each circle with the output value produced, or

On each directed arc with the output value produced.

Page 48: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 48

State Diagrams

Label form:

• On circle with output included: state/output Moore type output depends only on state

• On directed arc with the output included: input/output Mealy type output depends on state and

input

Page 49: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 49

Example 1: State Diagram

Which type? Diagram gets

confusing forlarge circuits

For small circuits,usually easier tounderstand thanthe state table

A B0 0

0 1 1 1

1 0

x=0/y=1 x=1/y=0

x=1/y=0x=1/y=0

x=0/y=1

x=0/y=1

x=1/y=0

x=0/y=0

Page 50: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 50

Moore and Mealy Models

Sequential Circuits or Sequential Machines are also called Finite State Machines (FSMs). Two formal models exist:

In contemporary design, models are sometimes mixed Moore and Mealy

Moore Model• Named after E.F. Moore.

• Outputs are a function ONLY of states

• Usually specified on the states.

Mealy Model• Named after G. Mealy• Outputs are a function of

inputs AND states• Usually specified on the

state transition arcs.

Page 51: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 51

Moore and Mealy Example Diagrams (page 263)

Mealy Model State Diagrammaps inputs and state to outputs

Moore Model State Diagram maps states to outputs

0 1

x=1/y=1

x=1/y=0

x=0/y=0

x=0/y=0

1/0 2/1

x=1x=1

x=0

x=0

x=1

x=0

0/0

Page 52: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 52

Moore and Mealy Example Tables

Mealy Model state table maps inputs and state to outputs

Moore Model state table maps state to outputs Present

State Next Statex=0 x=1

Output

0 0 1 0 1 0 2 0 2 0 2 1

Present State

Next State x=0 x=1

Output x=0 x=1

0 0 1 0 0 1 0 1 0 1

Page 53: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 53

Example 2: Sequential Circuit Analysis

Logic Diagram:

ClockReset

D

QC

Q

R

D

QC

Q

R

D

QC

Q

R

A

B

C

Z

Page 54: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 54

Example 2: Flip-Flop Input Equations

Variables• Inputs: None• Outputs: Z• State Variables: A, B, C

Initialization: Reset to (0,0,0) Equations

• A(t+1) = Z =• B(t+1) = • C(t+1) =

Page 55: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 55

Example 2: State Table

A B C A’B’C’ Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

X’ = X(t+1)

Page 56: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 56

Which states are used? What is the function of

the circuit?

000

011 010

001100

101

110

111

ResetABC

Example 2: State Diagram

Page 57: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 57

Consider a systemcomprised of ranksof flip-flopsconnected by logic:

If the clock period istoo short, somedata changes will notpropagate through thecircuit to flip-flop inputs before the setuptime interval begins

Circuit and System Level Timing

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

C

D Q

Q'

CLOCK CLOCK

Page 58: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 58

Timing components along a path from flip-flop to flip-flop

Circuit and System Level Timing (continued)

(a) Edge-triggered (positive edge)

tp

tpd,FF tpd,COMB tslacktsC

(b) Pulse-triggered (negative pulse)

tp

tpd,FF tpd,COMB tslack tsC

Page 59: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 59

New Timing Components• tp - clock period - The interval between

occurrences of a specific clock edge in a periodic clock

• tpd,COMB - total delay of combinational logic along the path from flip-flop output to flip-flop input

• tslack - extra time in the clock period in addition to the sum of the delays and setup time on a path Must be greater than or equal to zero on all

paths for correct operation

Circuit and System Level Timing (continued)

Page 60: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 60

Timing Equations tp = tslack + (tpd,FF + tpd,COMB + ts)

• For tslack greater than or equal to zero,

tp ≥ max (tpd,FF + tpd,COMB + ts)

for all paths from flip-flop output to flip-flop input

Can be calculated more precisely by using tPHL

and tPLH values instead of tpd values, but

requires consideration of inversions on paths

Circuit and System Level Timing (continued)

Page 61: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 61

Calculation of Allowable tpd,COMB

Compare the allowable combinational delay for a specific circuit:

a) Using edge-triggered flip-flopsb) Using master-slave flip-flops

Parameters• tpd,FF(max) = 1.0 ns

• ts(max) = 0.3 ns for edge-triggered flip-flops

• ts = twH = 1.0 ns for master-slave flip-flops

• Clock frequency = 250 MHz

Page 62: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 62

Calculation of Allowable tpd,COMB (continued)

Calculations: tp = 1/clock frequency = 4.0 ns

• Edge-triggered: 4.0 ≥ 1.0 + tpd,COMB + 0.3, tpd,COMB ≤ 2.7 ns

• Master-slave: 4.0 ≥ 1.0 + tpd,COMB + 1.0, tpd,COMB ≤ 2.0 ns

Comparison: Suppose that for a gate, average tpd = 0.3 ns

• Edge-triggered: Approximately 9 gates allowed on a path

• Master-slave: Approximately 6 to 7 gates allowed on a path

Page 63: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 63

The Design Procedure6-5

Specification Formulation - Obtain a state diagram or state table

State Assignment - Assign binary codes to the states

Flip-Flop Input Equation Determination - Select flip-flop types and derive flip-flop equations from next state entries in the table

Output Equation Determination - Derive output equations from output entries in the table

Optimization - Optimize the equations

Technology Mapping - Find circuit from equations and map to flip-flops and gate technology

Verification - Verify correctness of final design

Page 64: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 64

Specification

Component Forms of Specification• Written description• Mathematical description• Hardware description language*• Tabular description*• Equation description*• Diagram describing operation (not just structure)*

Relation to Formulation• If a specification is rigorous at the binary level (marked

with * above), then all or part of formulation may be completed

Page 65: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 65

Formulation: Finding a State Diagram

A state is an abstraction of the history of the past applied inputs to the circuit (including power-up reset or system reset).

• The interpretation of “past inputs” is tied to the synchronous operation of the circuit. E. g., an input value (other than an asynchronous reset) is measured only during the setup-hold time interval for an edge-triggered flip-flop.

Examples:

• State A represents the fact that a 1 input has occurred among the past inputs.

• State B represents the fact that a 0 followed by a 1 have occurred as the most recent past two inputs.

Page 66: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 66

Formulation: Finding a State Diagram

In specifying a circuit, we use states to remember meaningful properties of past input sequences that are essential to predicting future output values.

A sequence recognizer is a sequential circuit that produces a distinct output value whenever a prescribed pattern of input symbols occur in sequence, i.e, recognizes an input sequence occurence.

We will develop a procedure specific to sequence recognizers to convert a problem statement into a state diagram.

Next, the state diagram, will be converted to a state table from which the circuit will be designed.

Page 67: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 67

Sequence Recognizer Procedure

To develop a sequence recognizer state diagram:

• Begin in an initial state in which NONE of the initial portion of the sequence has occurred (typically “reset” state).

• Add a state that recognizes that the first symbol has occurred.• Add states that recognize each successive symbol occurring.• The final state represents the input sequence (possibly less the

final input value) occurence.• Add state transition arcs which specify what happens when a

symbol not in the proper sequence has occurred.• Add other arcs on non-sequence inputs which transition to states

that represent the input subsequence that has occurred. The last step is required because the circuit must recognize the input

sequence regardless of where it occurs within the overall sequence applied since “reset.”.

Page 68: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 68

State Assignment

Each of the m states must be assigned a unique code

Minimum number of bits required is n such that

n ≥ log2 mwhere x is the smallest integer ≥ x

There are useful state assignments that use more than the minimum number of bits

There are 2n - m unused states

Page 69: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 69

Sequence Recognizer Example

Example: Recognize the sequence 1101

• Note that the sequence 1111101 contains 1101 and "11" is a proper sub-sequence of the sequence.

Thus, the sequential machine must remember that the first two one's have occurred as it receives another symbol.

Also, the sequence 1101101 contains 1101 as both an initial subsequence and a final subsequence with some overlap, i. e., 1101101 or 1101101.

And, the 1 in the middle, 1101101, is in both subsequences.

The sequence 1101 must be recognized each time it occurs in the input sequence.

Page 70: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 70

Example: Recognize 1101

Define states for the sequence to be recognized:• assuming it starts with first symbol,

• continues through each symbol in the sequence to be recognized, and

• uses output 1 to mean the full sequence has occurred,

• with output 0 otherwise.

Starting in the initial state (Arbitrarily named "A"):• Add a state that recognizes

the first "1."• State "A" is the initial state, and state "B" is the state which

represents the fact that the "first" one in the input subsequence has occurred. The output symbol "0" means that the full recognized sequence has not yet occurred.

A B1/0

Page 71: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 71

C is the next state obtained when the input sequence has two "1"s.

• To what state should the arc from state D go? Remember: 1101101 ?

• Note that D is the last state but the output 1 occurs for the input applied in D. This is the case when a Mealy model is assumed.

Example: Recognize 1101 (continued)

A B1/0

A B1/0C

1/0 0/0

C1/0

D1/1

Page 72: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 72

Example: Recognize 1101 (continued)

Clearly the final 1 in the recognized sequence 1101 is a sub-sequence of 1101. It follows a 0 which is not a sub-sequence of 1101. Thus it should represent the same state reached from the initial state after a first 1 is observed. We obtain:

A B1/0 C1/0 0/0

1/1

DA B1/0C

1/0 0/0

D1/1

Page 73: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 73

Example: Recognize 1101 (continued)

The state have the following abstract meanings:

• A: No proper sub-sequence of the sequence has occurred.

• B: The sub-sequence 1 has occurred.

• C: The sub-sequence 11 has occurred.

• D: The sub-sequence 110 has occurred.

• The 1/1 on the arc from D to B means that the last 1 has occurred and thus, the sequence is recognized.

1/1

A B1/0

C1/0

D0/0

Page 74: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 74

Example: Recognize 1101 (continued)

The other arcs are added to each state for inputs not yet listed. Which arcs are missing?

Answer:

"0" arc from A "0" arc from B "1" arc from C "0" arc from D.

1/1

A B1/0

C1/0

D0/0

Page 75: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 75

Example: Recognize 1101 (continued)

State transition arcs must represent the fact that an input subsequence has occurred. Thus we get:

Note that the 1 arc from state C to state C implies that State C means two or more 1's have occurred.

C

1/1

A B1/0 1/0D

0/0

0/0

0/0 1/0

0/0

Page 76: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 76

Formulation: Find State Table

From the State Diagram, we can fill in the State Table.

There are 4 states, one input, and one output. We will choose the form with four rows, one for each current state.

From State A, the 0 and 1 input transitions have been filled in along with the outputs.

1/0

0/0

0/0

1/1

A B1/0

C1/0

D0/0

0/0

Present State

Next State x=0 x=1

Output x=0 x=1

A B C D

1/0

B 0

0/0

A 0

Page 77: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 77

StatePresent

Formulation: Find State Table

From the state diagram, we complete the state table.

What would the state diagram and state table look like for the Moore model?

1/00/0

0/0

0/0

1/1

A B1/0

C1/0

D0/0

Next State x=0 x=1

Output x=0 x=1

A A B 0 0 B A C 0 0 C D C 0 0 D A B 0 1

Page 78: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 78

Example: Moore Model for Sequence 1101

For the Moore Model, outputs are associated with states.

We need to add a state "E" with output value 1 for the final 1 in the recognized input sequence.

• This new state E, though similar to B, would generate an output of 1 and thus be different from B.

The Moore model for a sequence recognizer usually has more states than the Mealy model.

Page 79: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 79

Example: Moore Model (continued)

We mark outputs on states for Moore model

Arcs now show only state transitions

Add a new state E to produce the output 1

Note that the new state, E produces the same behavior in the future as state B. But it gives a different output at the present time. Thus, these states do represent a

different abstraction of the input history.

A/0 B/0 C/0 D/0

0

E/1

0

0

0

11

1

110

Page 80: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 80

Example: Moore Model (continued)

The state table is shown below

Memory aid re more state in the Moore model: “Moore is More.”

A/0 B/0 C/0 D/0

0

E/1

0

0

0

11

1

110

Present State

Next State x=0 x=1

Output y

A A B 0 B A C 0 C D C 0 D A E 0 E A C 1

Page 81: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 81

How may assignments of codes with a minimum number of bits?• Two – A = 0, B = 1 or A = 1, B = 0

State Assignment – Example 1

Present State

Next State x=0 x=1

Output x=0 x=1

A A B 0 0 B A B 0 1

Page 82: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 82

State Assignment – Example 2

Present State

Next State x=0 x=1

Output x=0 x=1

A A B 0 0 B A C 0 0 C D C 0 0 D A B 0 1

Page 83: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 83

Assignment 1: A = 0 0, B = 0 1, C = 1 0, D = 1 1 The resulting coded state table:

State Assignment – Example 2 (continued)

Present State

Next State

x = 0 x = 1

Output

x = 0 x = 1

0 0 0 0 0 1 0 0

0 1 0 0 1 0 0 0

1 0 1 1 1 0 0 0

1 1 0 0 0 1 0 1

Page 84: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 84

Assignment 2: A = 0 0, B = 0 1, C = 1 1, D = 1 0 The resulting 2D coded state table:

State Assignment – Example 2 (continued)

Present State

Next State

x = 0 x = 1

Output

x = 0 x = 1

0 0 0 0 0 1 0 0

0 1 0 0 1 1 0 0

1 1 1 0 1 1 0 0

1 0 0 0 0 1 0 1

Page 85: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 85

Page 86: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 86

Page 87: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 87

Page 88: Henry Hexmoor1 Sequential Circuits Chapter 6 Henry Hexmoor-- SIUC

Henry Hexmoor 88

HW 61. A sequential circuit has three D flip flops A, B, and C, and one

input X. The circuit is described by the following input equations:

DA = (BC’ + B’C)X + (BC + B’C’)X’ DB = A DC = B (a) derive the state table for the circuit. (b) draw the state diagrams, one for X = 0 and the other for X =

1.(Q6-6)2. A sequential circuit has one flip flop Q, two inputs X and Y, and

one output S. The circuit consists of a D flip flop with S as its output and logic implementing the function D = X Y S

With D as the input to the D flip flop. Derive the state table and the state diagram of the sequential circuit.

(Q 6-7)