Lecture 5: Sequential Circuit Design Circuits using flip-flops - - PowerPoint PPT Presentation

lecture 5 sequential circuit design circuits using flip
SMART_READER_LITE
LIVE PREVIEW

Lecture 5: Sequential Circuit Design Circuits using flip-flops - - PowerPoint PPT Presentation

Lecture 5: Sequential Circuit Design Circuits using flip-flops Now that we know Inputs Outputs Combinational Circuit about flip-flops and what they do, how do we use them in circuit Storage Units design? Whats the benefit in


slide-1
SLIDE 1

Lecture 5: Sequential Circuit Design

slide-2
SLIDE 2

Circuits using flip-flops

§ Now that we know

about flip-flops and what they do, how do we use them in circuit design?

§ What’s the benefit in using

flip-flops in a circuit at all?

Combinational Circuit

Inputs Outputs

Storage Units

slide-3
SLIDE 3

We are here

Processors

Finite State Machines

Arithmetic Logic Units Devices

Flip-flops

Circuits Logic Gates Transistors Assembly Language

slide-4
SLIDE 4

Example #1: Registers

slide-5
SLIDE 5

Shift registers

§ A series of D flip-flops can store a multi-bit

value (such as a 16-bit integer, for example).

§ Data can be shifted into this register one bit

at a time, over 16 clock cycles.

ú Known as a shift register.

D0 Q Q D15 Q Q D1 Q Q D2 Q Q

Clk SI

slide-6
SLIDE 6

Shift registers

§ Illustration: shifting in 0101010101010101

D0 Q Q D15 Q Q D1 Q Q D2 Q Q

Clk SI

1 1

slide-7
SLIDE 7

Shift registers

§ Illustration: shifting in 0101010101010101 § After 16 clock cycles….

D0 Q Q D15 Q Q D1 Q Q D2 Q Q

Clk SI

1 1

slide-8
SLIDE 8

Load registers

§ One can also load a register’s values all at

  • nce, by feeding signals into each flip-flop:

ú In this example: a 4-bit load register.

D Q Q D Q Q D Q Q D Q Q

Clk D0 D1 D2 D3

slide-9
SLIDE 9

Load registers

§ To control when this register is allowed to

load its values, we introduce the D flip-flop with enable:

D Q Q EN D Q Q D EN Clk

slide-10
SLIDE 10

Load registers

§ To control when this register is allowed to

load its values, we introduce the D flip-flop with enable:

§ It’s a MUX!

D Q Q EN D Q Q D EN Clk

1

slide-11
SLIDE 11

Load registers

§ Implementing the register with these special

D flip-flops will now maintain values in the register until overwritten by setting EN high.

D Q Q D Q Q D Q Q D Q Q

Clk D0 D1 D2 D3 Write

EN EN EN EN

slide-12
SLIDE 12

Example #2: Counters

slide-13
SLIDE 13

Counters

§ Consider the T flip-flop:

ú Output is inverted when

input T is high.

§ What happens when a

series of T flip-flops are connected together in sequence?

§ More interesting:

Connect the output of

  • ne flip-flop to the clock

input of the next!

T Q Q D Clk Q Q

T

slide-14
SLIDE 14

Counters

§ This is a 4-bit ripple counter, which is an

example of an asynchronous circuit.

ú Timing isn’t quite synchronized with the rising

clock pulse à hard to know when output is ready.

ú Cheap to implement, but unreliable for timing.

T Q Q T Q Q T Q Q T Q Q Q0 Q1 Q2 Q3 1

slide-15
SLIDE 15

Counters

§ Timing diagram

ú Note how propagation delay increases for later Qs

Q0 C Q1 Q2

T Q Q T Q Q T Q Q T Q Q Q0 Q1 Q2 Q3

1 C

Q3

1 1 1 1 1 1 1 1 1 1 1 1 1

slide-16
SLIDE 16

Counters

§ This is a synchronous counter, with a slight delay. § Each AND gate combine outputs of all previous

flip-flops

§ Each flip-flop only changes when all previous flip

flops are set

Q0 Q1 T Q Q T Q Q Q3 T Q Q T Q Q Q2 Write Clk

slide-17
SLIDE 17

It’s time for…

§ The Count!

slide-18
SLIDE 18

Example #3: Counters

§ Counters are often implemented with a

parallel load and clear inputs.

ú Loading a counter value is used for countdowns.

D Q Q D Q Q

Clk R0 R1

1 1

Load Write Clear

slide-19
SLIDE 19

State Machines

slide-20
SLIDE 20

Designing with flip-flops

§ Counters and registers

are examples of how flip-flops can implement useful circuits that store values.

§ How do you design these circuits? § What would you design with these circuits?

slide-21
SLIDE 21

Designing with flip-flops

§ Sequential circuits are the basis for memory,

instruction processing, and any other

  • peration that requires the circuit to

remember past data values.

§ These past data values are also called the

states of the circuit.

§ Sequential circuits use combinational logic to

determine what the next state of the system should be, based on the past state and the current input values: input + prev state à next state

slide-22
SLIDE 22

State example: Counters

§ With counters, each state is the current

number that is stored in the counter.

§ On each clock tick, the circuit transitions from

  • ne state to the next, based on the inputs.

000 001 010 011 100 111 110 101 1 1 1 1 1 1 1 1

zero

  • ne

two

three

four

seven

six

five

slide-23
SLIDE 23

State Tables

§ State tables help to

illustrate how the states of the circuit change with various input values.

ú Transitions are

understood to take place on the clock ticks

ú (e.g., rising edge)

State Write State zero zero zero

1

  • ne
  • ne
  • ne
  • ne

1

two two two two

1

three three three three

1

four four four four

1

five five five five

1

six six six six

1

seven seven seven seven

1

zero

slide-24
SLIDE 24

State Tables

§ Same table as on

the previous slide, but with the actual flip-flop values instead of state labels.

§ Note: Flip-flop

values are both inputs and

  • utputs of the

circuit here.

F1 F2 F3 Write F1 F2 F3

1

1 1 1 1

1

1 1 1 1

1

1 1 1 1 1 1 1 1

1

1 1 1 1

1

1 1 1 1 1 1 1 1

1

1 1 1 1 1 1 1 1

1

1 1 1 1 1 1 1 1 1 1 1 1

1

slide-25
SLIDE 25

Finite State Machines

and this brings us to…

slide-26
SLIDE 26

As seen in other courses…

§ You may have seen finite state machines

before, but in a different context.

ú Used mainly to describe the grammars of a

language, or to model sequence data.

§ In CSCB58, finite state machines are models

for an actual circuit design.

ú The states represent internal states of the circuit,

which are stored in the flip-flop values.

slide-27
SLIDE 27

Finite State Machines (FSMs)

§ From theory courses…

ú A Finite State Machine is an abstract model that

captures the operation of a sequential circuit.

§ A FSM is defined (in general) as:

ú A finite set of states, ú A finite set of transitions between states,

triggered by inputs to the state machine,

ú Output values that are associated with each state

  • r each transition (depending on the machine),

ú Start and end states for the state machine.

slide-28
SLIDE 28

Example #1: Tickle Me Elmo

§ Remember how the

Tickle Me Elmo works!

slide-29
SLIDE 29

Example #1: Tickle Me Elmo

§ Toy reacts differently each time it is squeezed:

ú First squeeze à “Ha ha ha…that tickles.” ú Second squeeze à “Ha ha ha…oh boy.” ú Third squeeze à “HA HA HA HA…HA HA HA HA…etc”

§ Questions to ask:

ú What are the inputs? ú What are the states of this machine? ú How do you change from one state to the next? ú Who thought this is a good toy for children!?

slide-30
SLIDE 30

Example #1: Tickle Me Elmo

Neutral Tickles OhBoy GoCrazy

Squeeze Squeeze Squeeze Squeeze Time Time Time

slide-31
SLIDE 31

More elaborate FSMs

§ Usually our FSM has more than one input,

and will trigger a transition based on certain input values but not others.

§ Also might have input values that don’t cause

a transition, but keep the circuit in the same state (transitioning to itself).

slide-32
SLIDE 32

Example #2: Alarm Clock

§ Internal state description:

ú Starts in neutral state, until

timer signal goes off.

Clock moves to alarm state.

ú Alarm state continues until:

snooze button is pushed (move to snooze state) alarm is turned off (move to neutral state) timer goes off again (move to neutral state)

ú In snooze state, clock returns to alarm state when

the timer signal goes off again.

slide-33
SLIDE 33

Example #3: Traffic Light

Red Yellow Green Change=1 Change=1 Change=1 Change=0 Change=0 Change=0