Registers, Finite State Machines CSE 140: Components and Design - - PowerPoint PPT Presentation

registers finite state machines
SMART_READER_LITE
LIVE PREVIEW

Registers, Finite State Machines CSE 140: Components and Design - - PowerPoint PPT Presentation

Lecture 7: Sequential Networks: Registers, Finite State Machines CSE 140: Components and Design Techniques for Digital Systems Diba Mirza Dept. of Computer Science and Engineering 1 University of California, San Diego D Flip-Flop (Delay)


slide-1
SLIDE 1

Lecture 7: Sequential Networks: Registers, Finite State Machines

CSE 140: Components and Design Techniques for Digital Systems

Diba Mirza

  • Dept. of Computer Science and Engineering

University of California, San Diego

1

slide-2
SLIDE 2

D Flip-Flop (Delay)

D CLK Q Q’

Id D Q(t) Q(t+1) 0 0 0 0 1 0 1 0 2 1 0 1 3 1 1 1

Characteristic Expression Q(t+1) = D(t)

0 0 1 1 0 1 PS D 0 1 State table NS= Q(t+1)

2

What does the equation mean?

slide-3
SLIDE 3

iClicker

3

How long does a D-flip flop store a bit before its

  • utput can potentially change?
  • A. Half a clock cycle
  • B. One clock cycle
  • C. Two clock cycles
  • D. There is no minimum time
slide-4
SLIDE 4

Rising vs. Falling Edge D Flip-Flop

4

D Q ’ Q Q ’ D Q Symbol for rising-edge triggered D flip-flop Symbol for falling-edge triggered D flip-flop

Clk

rising edges

Clk

falling edges Internal design: Just invert servant clock rather than master The triangle means clock input, edge triggered

slide-5
SLIDE 5

Internal Circuit D Q CLK EN D Q 1 D Q EN Symbol

  • Inputs: CLK, D, EN

– The enable input (EN) controls when new data (D) is stored

  • Function

– EN = 1: D passes through to Q on the clock edge – EN = 0: the flip-flop retains its previous state

Enabled D-FFs

slide-6
SLIDE 6

6

slide-7
SLIDE 7

Bit Storage Overview

7

D flip-flop D latch master D latch servant DmQm C m Ds D Clk Qs’ Cs Qs Q’ Q S R D Q C D latch

Only loads D value present at rising clock edge, so values can’t propagate to other flip- flops during same clock cycle. Tradeoff: uses more gates internally than D latch, and requires more external gates than SR – but gate count is less of an issue today. SR can’t be 11 if D is stable before and while C=1, and will be 11 for only a brief glitch even if D changes while C=1. Problem: C=1 too long propagates new values through too many latches: too short may not enable a store.

S1 R1 S Q C R Level-sensitive SR latch

S and R only have effect when C=1. We can design outside circuit so SR=11 never happens when C=1. Problem: avoiding SR=11 can be a burden.

R (reset) S (set) Q SR latch

S=1 sets Q to 1, R=1 resets Q to 0. Problem: SR=11 yield undefined Q.

slide-8
SLIDE 8

8

slide-9
SLIDE 9

Shift register

  • Holds & shifts samples of input

9

D Q D Q D Q D Q IN OUT1 OUT2 OUT3 OUT4 CLK

slide-10
SLIDE 10

Pattern Recognizer

  • Combinational function of input samples

10

D Q D Q D Q D Q IN OUT1 OUT2 OUT3 OUT4 CLK OUT

slide-11
SLIDE 11

Counters

11

D Q D Q D Q D Q IN OUT1 OUT2 OUT3 OUT4 CLK

  • Sequences through a fixed set of patterns
slide-12
SLIDE 12

What we will learn:

12

  • 1. Describe the desired behavior of a sequential circuit over time

(FSMs)

  • 2. Given the behavior of a sequential circuit, implement the circuit

Wall-E is a Finite State Machine

Active Inactive

Describing Wall-E Implementing Wall-E

slide-13
SLIDE 13

Finite State Machines: Describing circuit behavior over time

13

2 bit Counter Symbol/ Circuit

slide-14
SLIDE 14

Finite State Machines: Describing circuit behavior over time

14

Free running 2 bit Counter Symbol/ Circuit Output over time time

CLK Q1 Q0

What is the expected output of the counter over time?

slide-15
SLIDE 15

Finite State Machines: Describing circuit behavior over time

15

2 bit Counter 00 Symbol/ Circuit Diagram that depicts behavior over time 01 10 11

slide-16
SLIDE 16

State: What is it ? Why do we need it?

16

Symbol/ Circuit Behavior over time time

CLK

2 bit Counter PI Q: At time t1, what information is needed to produce the output of the counter at the next rising edge of the clock (i.e t2)?

  • A. All the outputs of the counter until t1
  • B. The initial output of the counter at time t=0
  • C. The output of the counter at current time t1
  • D. We cannot determine the output of the counter at t2 prior to t2

t1 t2

slide-17
SLIDE 17

Implementing the 2 bit counter

17

S0 S1 S2 S3

State Diagram State Table

Q1(t) Q0(t) Q1(t+1) Q0(t+1) Current state Next State S0 S1 S1 S2 S2 S3 S3 S0

slide-18
SLIDE 18

18

State Table

Q1(t) Q0(t) Q1(t+1) Q0(t+1) 1 1 1 1 1 1 1 1

PI Q: Which of the following is the likely structure of the circuit realization of the counter Q0(t) Q1(t)

D Q Q’ D Q Q’

CLK Circuit with 2 flip flops B.

Combinational circuit Combinational circuit

Circuit with no flip flops A.

Q0(t) Q1(t)

Q D Q Q’

CLK Circuit with one flip flop C.

Combinational circuit

slide-19
SLIDE 19

19

State Table

Q1(t) Q0(t) Q1(t+1) Q0(t+1) 1 1 1 1 1 1 1 1

Q0(t) Q1(t)

D Q Q’ D Q Q’

CLK Circuit with 2 flip flops B.

Combinational circuit D0(t) = Q0(t)’ D1(t) = Q0(t) Q1(t)’ + Q0(t)’ Q1(t)

To design the combinational circuit we need a truth table

slide-20
SLIDE 20

20

State Table

Q1(t) Q0(t) Q1(t+1) Q0(t+1) 1 1 1 1 1 1 1 1

We store the current state using D-flip flops so that:

  • Inputs to the combinational circuit

don’t change while the next output is being computed

  • The transition to the next state only
  • ccurs at the rising edge of the clock

Q0(t) Q1(t)

D Q Q’ D Q Q’

CLK Implementation of 2-bit counter

Q0(t+1) = Q0(t)’ Q1(t+1) = Q0(t) Q1(t)’ + Q0(t)’ Q1(t)

slide-21
SLIDE 21

21

Generalized Model of Sequential Circuits

S(t) X Y CLK

slide-22
SLIDE 22

22

Mealy Machine: yi(t) = fi(X(t), S(t)) Moore Machine: yi(t) = fi(S(t)) si(t+1) = gi(X(t), S(t)) C1 C2

CLK x(t) y(t)

Mealy Machine

S(t)

C1 C2

CLK x(t) y(t)

Moore Machine

S(t)

Canonical Form: Mealy and Moore Machines