eng241 digital design week #6 sequential circuits (part a)

57
ENG241 ENG241 Digital Design Digital Design Week #6 Sequential Circuits (Part A)

Upload: amie-collins

Post on 01-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

ENG241 ENG241 Digital DesignDigital Design

Week #6 Sequential Circuits (Part A)

Page 2: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

2

Week #6 TopicsWeek #6 Topics

Sequential Circuit Definitions Latches Flip-Flops Delays in Sequential Circuits Clock Gating

Page 3: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

3

ResourcesResources

Chapter #6, Mano Sections 6.1 Sequential Circuit Definition 6.2 Latches 6.3 Flip-Flops

Page 4: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

4

Combinational/Sequential CircuitsCombinational/Sequential Circuits

Combinational logic are very interesting and useful for designing arithmetic circuits (adders, multipliers) or in other words the Data Path of a computer.

Combinational circuits cannot remember what happened in the past (i.e. outputs are a function of current inputs).

In certain cases we might need to store some info before we proceed with our computation or take action based on a certain state that happened in the past.

Sequential circuits are capable of storing information between operations. They are useful in designing registers, counters, and CONTROL Circuits.

Page 5: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

5

Remembering StatesRemembering States

Page 6: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

6

Sequential CircuitsSequential Circuits

Information that is stored in the storage elements represent the state of the system.

The outputs will depend on the inputs and present state of the storage elements.

Storage

Elements

Page 7: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

7

Types of Sequential CircuitsTypes of Sequential Circuits

Two main types and their classification depends on the times at which their inputs are observed and their internal state changes. Synchronous

State changes synchronized by one or more clocks

Asynchronous Changes occur independently

Page 8: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

8

Signal Examples Over TimeSignal Examples Over Time

Analog

Asynchronous

Synchronous

Time

Continuous in value &

time

Discrete in value & continuous

in time

Discrete in value &

time

Digital

Page 9: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

9

Clocking of Synchronous CircuitsClocking of Synchronous Circuits

Changes enabled by clock

Page 10: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

10

ComparisonComparison

Synchronous Easier to analyze because can factor out gate

delays Speed of the system is determined by the

clock (maybe slowed!) Asynchronous

Potentially faster Harder to analyze

We will look mostly at synchronous

Page 11: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

11

Basic Storage (How?)Basic Storage (How?)

1. Apply low or high for longer than tpd But we are interested in storing information indefinitely!

2. Feedback will hold value However we want inputs to our circuitry!

Page 12: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

12

LatchesLatches

Are storage elements that can maintain a binary state indefinitely (as long as power is delivered to the circuit) until directed by an input signal to switch states. Latches are asynchronous circuits Latches are used to build more

complex synchronous circuits such as Flip Flops.

Page 13: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

13

SR (set-reset) Latches: SR (set-reset) Latches:

Replace the inverters with NAND, NOR Gates Basic storage made from gates The information can be changed

S & R both 0 in “resting” state Have to keep both from 1 at same time

Page 14: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

14

OperationOperation

Reset, Q=0

Keep State

Set, Q=1 Undefined!

Page 15: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

15

Latch

Similar – made from NANDs

RS

• S & R both 1 in “resting” state• Have to keep both from 0 at same time

Page 16: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

16

Add Control Input: SR LatchAdd Control Input: SR Latch

An additional input determines when the state of the latch can be changed!

Can we avoid the undefined state?

Page 17: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

17

D-type LatchD-type Latch

No illegal state

Page 18: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

18

Transparency of LatchesTransparency of Latches

The state of a latch is allowed to switch by a momentary change in value on the control input. As long as C (the trigger ) is high, state can

change! This is called transparencytransparency

What is wrong with transparency?

Page 19: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

19

Effects of TransparencyEffects of Transparency

Output of one latch may feedback As soon as the input changes, shortly thereafter

the corresponding output changes to match it. The final state will depend on how long the

clock pulse stays at level logic 1! (unreliable) We need to predict the outputs at a certain

moment in time!o Want to change latch state once

Depending on inputs at time of clock

Storage Element

Clock

Page 20: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

20

Flip-FlopsFlip-Flops

Ensure only one transition Two major types

1. Master-Slave (level triggered) Two stage Output not changed until clock

disabled

2. Edge triggered Change happens when clock level

changes

Page 21: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

21

Master-Slave SR Flip-FlopMaster-Slave SR Flip-Flop

When Master is enabled, Slave is disabled! Output Q will not change when inputs change

S

C

R

S

C

R

S

C

R

SR LatchMaster

Slave

Page 22: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

22

Timing DiagramTiming Diagram

Trace the behavior Note the illegal state Is it transparent?

1

00

1

Page 23: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

23

Have We Fixed the Problem?Have We Fixed the Problem?

Output no longer transparent Combinational circuit can use last values New inputs appear at latches Not sent to output until clock low In one clock cycle we can predict what will happen

Note: Master-Slave = pulse triggered

Page 24: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

24

JK Flip FlopJK Flip Flop

The JK Flip Flop is a modified version of the SR Flip Flop which eliminates the undesirable condition that leads to undefined outputs.

The JK flip flop performs three operations:1. Set Q to 12. reset Q to 03. complement the output

Page 25: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

25

Master-Slave JK Flip Flop Master-Slave JK Flip Flop

The J input sets the flip flop to 1.The K input resets the flip flop to 0.When both J and K are enabled, the

output is complemented.

Page 26: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

26

Edge-Triggered Flip-FlopsEdge-Triggered Flip-Flops

An Edge Triggered Flip-Flop ignores the pulse while it is at a constant level and triggers only during a transition of the clock signal. New state latched on clock transition Low-to-high or high-to-low

Changes when clock high are ignored

Page 27: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

27

Clock ResponsesClock Responses

We can classify Flip/Flops according to the response to the clock.

Page 28: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

28

Edge Triggered D-Flip-FlopEdge Triggered D-Flip-Flop

D

C

S

C

R

Page 29: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

29

Characteristic TablesCharacteristic Tables

Define the logical properties of a flip flop by describing its operations in tabular form. They define the next state as a function of the inputs

and the present state. Q(t) refers to the present state prior to the application

of a clock edge. Q(t + 1) refers to the next state one clock period later. Clock edges are not listed as inputs but are implied by

the transition from t to t + 1.

Page 30: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

30

D FF Characteristic TableD FF Characteristic Table

The Characteristic Equation:Q(t + 1) = D(t)

Page 31: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

31

Edge-Triggered D Flip Flop: Edge-Triggered D Flip Flop: Graphic Symbols Graphic Symbols

The triangle is called: dynamic indicator

Page 32: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

32

Other Flip FlopsOther Flip Flops

Other types of flip flops can be constructed by using the D flip flop and external logic. The two most commonly used are:

1. Edge triggered JK flip flops2. T flip flops

Page 33: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

33

JK Characteristic TableJK Characteristic Table

Characteristic Equation:Q(t+1) = J(t) Q’(t) + K’(t)Q(t)

Utilize the equation to create a JK flipflop from an existing D flipflop

Page 34: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

34

Edge-Triggered JK Flip Flop Edge-Triggered JK Flip Flop

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

Page 35: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

35

Analysis of the JK CircuitAnalysis of the JK Circuit

The circuit applied to the D input is D = JQ’ + K’Q

I. If J = 1 and K = 0, D = Q + Q’ = 1 (Set)II. If J = 0 and K = 1, D = 0 (Reset)III. If J = K = 0, D = Q, (No Change)IV. If J = K = 1, D = Q’ (Complement)

Page 36: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

36

T Flip Flop T Flip Flop

T

The T Flip Flop is a complementing flip flop.

How can we obtain a T Flip Flop from a JK Flip Flop or D Flip Flop?

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

Page 37: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

37

T Flip FlopT Flip Flop

The T flip flop can be obtained from a JK flip flop when inputs J and K are tied together.

Page 38: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

38

Characteristic EquationsCharacteristic Equations

The D flip flop can be expressed as: Q(t + 1) = D

The JK flip flop can be expressed as: Q(t + 1) = JQ’ + K’Q

The T flip flop can be expressed as: Q(t + 1) = TQ’ + T’Q

Characteristic Tables are used to1. Derive the characteristic equations,2. Analyze Sequential Circuits.

Page 39: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

39

JK- Characteristic Equation JK- Characteristic Equation

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

0 0 0 ^ 0

0 0 1 ^ 1

0 1 0 ^ 0

0 1 1 ^ 0

1 0 0 ^ 1

1 0 1 ^ 1

1 1 0 ^ 1

1 1 1 ^ 0

J K Q CLK Q+

0 0 1 1

1 0 0 1

QJK

0

1

00 01 11 10

Page 40: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

40

Standard Symbols – LatchesStandard Symbols – Latches

Circle at input indicates negation

Page 41: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

41

Symbols – Master-SlaveSymbols – Master-Slave

Inverted L indicates postponed output Circle indicates whether enable is

positive or negative

Page 42: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

42

Symbols – Edge-TriggeredSymbols – Edge-Triggered

Arrow indicates edge trigger

Page 43: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

43

Direct InputsDirect Inputs

Set/Reset independent of clock Direct set or preset Direct reset or clear

Often used for power-up reset

Page 44: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

44

VHDL Design StylesVHDL Design Styles

Components andinterconnects

structural

VHDL Design Styles

dataflow

Concurrent statements

behavioral(algorithmic)

• Registers• State machines• Test benches

Sequential statements

Page 45: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

45

VHDL For Sequential CircuitsVHDL For Sequential Circuits

Several techniques have been discussed in class to describe the architecture of combinational logic circuits:

1. Data Flow2. Structural

Statements used in “Data Flow” and “Structural” descriptions can be executed in parallel i.e. concurrently.

Another technique to describe the architecture of any circuit is to use Behavioral description.

The process statement is usually used to describe sequential designs.

The process statement consists of only sequential statements

Page 46: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

46

VHDL For Sequential CircuitsVHDL For Sequential Circuits

To describe sequential circuits we usually use the “process” statement.

A process statement consists of 1. Sensitivity list Process (CLK, RESET)

This list enumerates exactly which signals causes the process statement to be executed. (Only events on these signals cause the process statement to be executed!)

2. Declarative region Process (CLK, RESET) …… (declare local vars) Begin ….. END

Page 47: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

47

VHDL for Positive Edge Triggered D-FFVHDL for Positive Edge Triggered D-FF

-- positive Edge-Triggered D flip-flop with reset-- VHDL Process Descriptionlibrary ieee;use ieee.std_logic_1164.all;entity dff is port (CLK, RESET, D : in std_logic; Q : out std_logic);end dff;

architecture pet_pr of dff isbegin process (CLK, RESET) begin if (RESET = `1’) then Q <= `0’; elsif (CLK’event and CLK = `1’) then - - you can use rising_edge(CLK) instead! Q <= D; end if; end process;end;

Page 48: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

48

Flip-Flop TimingFlip-Flop Timing

• Setup time (ts)– time that D must be available before clock edge

• Hold time (th)– time that D must be stable after clock edge

Page 49: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

49

SummarySummary

Combinational logic are very interesting and useful for designing arithmetic circuits (adders, multipliers) or in other words the Data Path of a computer.

Sequential circuits are capable of storing information between operations. They are useful in designing registers, counters, and CONTROL Circuits.

Latches are storage elements that are asynchronous, transparent and are used to build more complex synchronous circuits such as Flip-Flops.

Flip-flops avoid the transparency problem faced by latches and are either Master-Slave pulse active or edge triggered.

Characteristic tables will be used to analyze the behavior of sequential circuits.

Page 50: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

50

Page 51: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

51

Propagation Delay

Propagation delay – time after edge when output is available

Page 52: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

52

Positive D-Type Edge Triggered

D

C

S

C

R

Page 53: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

53

Have We Fixed the Problem?

Output no longer transparent Combinational circuit can use last values New inputs appear at latches Not sent to output until clock low In one clock cycle we can predict what will happen

But changes at input of FF when clock high trigger next state Transient state where S goes high caused by gate

delays As clock faster, more problems Have to guarantee circuit settles while clock low

Note: Master-Slave = pulse triggered

Page 54: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

54

Clock Pulse Requirements

Basically a max clock frequency

Page 55: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

55

Clock Gating

Can gate clocks (to keep any FF from changing states, for example) Clock gating used to reduce power drain

However, can cause clock skew Clock edges at different times on different

FFs Clock skew also caused by wire lengths

over chip

Page 56: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

56

T Flip Flop

The T flip flop can also be obtained from a D flip flop by using an XOR as the input for D.

Page 57: ENG241 Digital Design Week #6 Sequential Circuits (Part A)

57

Master-Slave JK Flip Flop

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