lecture 5: sequential circuit designbharrington/cscb58/slides/lec05-1.pdf · shift registers §a...
TRANSCRIPT
![Page 1: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/1.jpg)
Lecture 5: Sequential Circuit Design
![Page 2: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/2.jpg)
Circuits using flip-flops
§ Now that we knowabout flip-flops andwhat they do, how dowe use them in circuitdesign?
§ What’s the benefit in usingflip-flops in a circuit at all?
Combinational Circuit
Inputs Outputs
Storage Units
![Page 3: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/3.jpg)
We are here
ProcessorsFinite State Machines
Arithmetic Logic Units
Devices Flip-flops
Circuits
Logic Gates
Transistors
Assembly Language
![Page 4: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/4.jpg)
Example #1: Registers
![Page 5: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/5.jpg)
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
![Page 6: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/6.jpg)
Shift registers
§ Illustration: shifting in 0101010101010101
D0 Q
Q
D15 Q
Q
D1 Q
Q
D2 Q
Q
Clk
SI
0101
![Page 7: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/7.jpg)
Shift registers
§ Illustration: shifting in 0101010101010101
§ After 16 clock cycles….
D0 Q
Q
D15 Q
Q
D1 Q
Q
D2 Q
Q
Clk
SI1 10 0
![Page 8: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/8.jpg)
Load registers
§ One can also load a register’s values all at once, 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
![Page 9: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/9.jpg)
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
![Page 10: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/10.jpg)
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
0
1
![Page 11: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/11.jpg)
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
![Page 12: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/12.jpg)
Example #2: Counters
![Page 13: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/13.jpg)
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 insequence?
§ More interesting:Connect the output of one flip-flop to the clockinput of the next!
T Q
Q
D
Clk
Q
Q
T
![Page 14: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/14.jpg)
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 Q31
![Page 15: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/15.jpg)
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 Q31
C
Q3
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
1
1
0
0
0
0
1
0
1
0
1
0
0
1
1
0
1
1
1
0
![Page 16: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/16.jpg)
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 Q1T Q
Q
T Q
Q
Q3T Q
Q
T Q
Q
Q2Write
Clk
![Page 17: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/17.jpg)
It’s time for…
§ The Count!
![Page 18: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/18.jpg)
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
R0R1
01
01
LoadWrite
Clear
![Page 19: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/19.jpg)
State Machines
![Page 20: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/20.jpg)
Designing with flip-flops
§ Counters and registers are examples of how flip-flops can implement useful circuits that storevalues.
§ How do you design these circuits?§ What would you design with these circuits?
![Page 21: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/21.jpg)
Designing with flip-flops§ Sequential circuits are the basis for memory,
instruction processing, and any other operation 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
![Page 22: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/22.jpg)
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 one state to the next, based on the inputs.
000
001 010 011
100
111 110 101
0
11 1
1
1
11
1
0 0 0
0
0 0 0
zero
one two three
four
seven six five
![Page 23: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/23.jpg)
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 0 zero
zero 1 one
one 0 one
one 1 two
two 0 two
two 1 three
three 0 three
three 1 four
four 0 four
four 1 five
five 0 five
five 1 six
six 0 six
six 1 seven
seven 0 seven
seven 1 zero
![Page 24: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/24.jpg)
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 outputs of the circuit here.
F1 F2 F3 Write F1 F2 F30 0 0 0 0 0 0
0 0 0 1 0 0 1
0 0 1 0 0 0 1
0 0 1 1 0 1 0
0 1 0 0 0 1 0
0 1 0 1 0 1 1
0 1 1 0 0 1 1
0 1 1 1 1 0 0
1 0 0 0 1 0 0
1 0 0 1 1 0 1
1 0 1 0 1 0 1
1 0 1 1 1 1 0
1 1 0 0 1 1 0
1 1 0 1 1 1 1
1 1 1 0 1 1 1
1 1 1 1 0 0 0
![Page 25: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/25.jpg)
Finite State Machinesand this brings us to…
![Page 26: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/26.jpg)
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.
![Page 27: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/27.jpg)
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
or each transition (depending on the machine),ú Start and end states for the state machine.
![Page 28: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/28.jpg)
Example #1: Tickle Me Elmo
§ Remember how the Tickle Me Elmo works!
![Page 29: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/29.jpg)
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!?
![Page 30: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/30.jpg)
Example #1: Tickle Me Elmo
Neutral
Tickles
OhBoy
GoCrazy
Squeeze
Squeeze
Squeeze
Squeeze
Time
Time
Time
![Page 31: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/31.jpg)
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).
![Page 32: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/32.jpg)
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.
![Page 33: Lecture 5: Sequential Circuit Designbharrington/cscb58/slides/LEC05-1.pdf · Shift registers §A series of D flip-flops can store a multi-bit value (such as a 16-bit integer, for](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f5857f902ea115d49771911/html5/thumbnails/33.jpg)
Example #3: Traffic Light
Red
Yellow Green
Change=1 Change=1
Change=1
Change=0 Change=0
Change=0