CS Fall 2005 – Lec. #5 – Sequential Logic - 1

Slides:



Advertisements
Similar presentations
11/12/2004EE 42 fall 2004 lecture 311 Lecture #31 Flip-Flops, Clocks, Timing Last lecture: –Finite State Machines This lecture: –Digital circuits with.
Advertisements

1 Lecture 14 Memory storage elements  Latches  Flip-flops State Diagrams.
ECE C03 Lecture 81 Lecture 8 Memory Elements and Clocking Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
CHAPTER 3 Sequential Logic/ Circuits.  Concept of Sequential Logic  Latch and Flip-flops (FFs)  Shift Registers and Application  Counters (Types,
ECE 331 – Digital System Design Latches and Flip-Flops (Lecture #17) The slides included herein were taken from the materials accompanying Fundamentals.
Circuits require memory to store intermediate data
EKT 124 / 3 DIGITAL ELEKTRONIC 1
EECC341 - Shaaban #1 Lec # 13 Winter Sequential Logic Circuits Unlike combinational logic circuits, the output of sequential logic circuits.
ENGIN112 L20: Sequential Circuits: Flip flops October 20, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 20 Sequential Circuits: Flip.
11/16/2004EE 42 fall 2004 lecture 331 Lecture #33: Some example circuits Last lecture: –Edge triggers –Registers This lecture: –Example circuits –shift.
11/10/2004EE 42 fall 2004 lecture 301 Lecture #30 Finite State Machines Last lecture: –CMOS fabrication –Clocked and latched circuits This lecture: –Finite.
CS 151 Digital Systems Design Lecture 20 Sequential Circuits: Flip flops.
11/15/2004EE 42 fall 2004 lecture 321 Lecture #32 Registers, counters etc. Last lecture: –Digital circuits with feedback –Clocks –Flip-Flops This Lecture:
Sequential Circuits. 2 Sequential vs. Combinational Combinational Logic:  Output depends only on current input −TV channel selector (0-9) Sequential.
Contemporary Logic Design Sequential Logic © R.H. Katz Transparency No Chapter #6: Sequential Logic Design Sequential Switching Networks.
ENGIN112 L26: Shift Registers November 3, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 26 Shift Registers.
Sequential logic and systems
1 Digital Design: Sequential Logic Blocks Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals.
1 CSE370, Lecture 14 Lecture 14 u Logistics n Midterm 1: Average 90/100. Well done! n Midterm solutions online n HW5 due date delayed until this Friday.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 9 Sequential.
Registers & Counters M. Önder Efe
VI - Sequential Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Sequential logic Sequential circuits  simple circuits with feedback  latches.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Abdullah Said Alkalbani University of Buraimi
ECE C03 Lecture 81 Lecture 8 Memory Elements and Clocking Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Synchronous Sequential Circuits by Dr. Amin Danial Asham.
CS151 Introduction to Digital Design Chapter 5: Sequential Circuits 5-1 : Sequential Circuit Definition 5-2: Latches 1Created by: Ms.Amany AlSaleh.
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2002.
Sequential logic circuits First Class 1Dr. AMMAR ABDUL-HAMED KHADER.
Digital Design: Sequential Logic Principles
Overview Logistics Last lecture Today HW5 due today
Lecture 10 Flip-Flops/Latches
LATCHES AND FLIP-FLOPS
Digital Design: Sequential Logic Blocks
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Dr. Clincy Professor of CS
Lecture #16: D Latch ; Flip-Flops
FLIP FLOPS Binary unit capable of storing one bit – 0 or 1
Supplement on Verilog FF circuit examples
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN
David Culler Electrical Engineering and Computer Sciences
Homework Reading Machine Projects Labs Tokheim Chapter 9.1 – 9.6
Chapter #6: Sequential Logic Design
Sequential Logic Combinational logic:
6. Sequential circuits Rocky K. C. Chang 17 October 2017.
FIGURE 5.1 Block diagram of sequential circuit
Synchronous Sequential Circuits
Basic Delay in Gates Definitions
Typical Timing Specifications
6. Sequential circuits (v2)
Sequential Logic and Flip Flops
Assistant Prof. Fareena Saqib Florida Institute of Technology
Introduction to Sequential Logic Design
ECE Digital logic Lecture 16: Synchronous Sequential Logic
Digital Logic Design Sequential Circuits (Chapter 6)
LECTURE 15 – DIGITAL ELECTRONICS
Sequential Logic and Flip Flops
CSE 370 – Winter Sequential Logic-2 - 1
触发器 Flip-Flops 刘鹏 浙江大学信息与电子工程学院 March 27, 2018
Synchronous Sequential Circuits
Dr. Clincy Professor of CS
CSE 370 – Winter Sequential Logic - 1
Lecture 16 Logistics Last lecture Today HW5 out, due next wednesday
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 16 Logistics Last lecture Today HW5 out, due next wednesday
CSE 370 – Winter Sequential Logic-2 - 1
Flip-Flops.
SEQUENTIAL CIRCUITS __________________________________________________
Week 11 Flip flop & Latches.
FLIPFLOPS.
Presentation transcript:

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 1 Sequential Circuits Simple circuits with feedback Latches Edge-triggered flip-flops Timing Methodologies Cascading flip-flops for proper operation Clock skew Basic Registers Shift registers Counters CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 1

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 2 Sequential Circuits Circuits with Feedback Outputs = f(inputs, past inputs, past outputs) Basis for building "memory" into logic circuits Door combination lock is an example of a sequential circuit State is memory State is an "output" and an "input" to combinational logic Combination storage elements are also memory new equal reset value C1 C2 C3 mux control multiplexer comb. logic comparator state clock equal open/closed CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 2

Circuits with Feedback How to control feedback? What stops values from cycling around endlessly X1 X2 • • • Xn Z1 Z2 • • • Zn switching network CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 3

Simplest Circuits with Feedback Two inverters form a static memory cell Will hold value as long as it has power applied How to get a new value into the memory cell? Selectively break feedback path Load new value into cell "0" "1" "stored value" "remember" "load" "data" "stored value" CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 4

Memory with Cross-coupled Gates Cross-coupled NOR gates Similar to inverter pair, with capability to force output to 0 (reset=1) or 1 (set=1) Cross-coupled NAND gates Similar to inverter pair, with capability to force output to 0 (reset=0) or 1 (set=0) R S Q Q' R S Q Q Q' S' R' R' S' Q CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 5

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 6 Timing Behavior R S Q Q' Reset Hold Set Reset Set Race 100 R S Q \Q CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 6

State Behavior of R-S latch Truth table of R-S latch behavior Q Q' 0 1 Q Q' 1 0 Q Q' 0 0 Q Q' 1 1 S R Q 0 0 hold 0 1 0 1 0 1 1 1 unstable CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 7

Theoretical R-S Latch Behavior SR=10 SR=00 SR=01 SR=00 SR=10 Q Q' 0 1 Q Q' 1 0 Q Q' 0 0 Q Q' 1 1 SR=01 SR=10 SR=01 SR=01 SR=10 SR=11 SR=11 SR=11 State Diagram States: possible values Transitions: changes based on inputs possible oscillation between states 00 and 11 SR=00 SR=00 SR=11 CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 8

Observed R-S Latch Behavior Very difficult to observe R-S latch in the 1-1 state One of R or S usually changes first Ambiguously returns to state 0-1 or 1-0 A so-called "race condition" Or non-deterministic transition Q Q' 0 1 Q Q' 1 0 Q Q' 0 0 SR=10 SR=01 SR=00 SR=11 SR=00 CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 9

R-S Latch Analysis Break feedback path Q(t) R Q Q(t+) S Q' R S S R Q(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 X 1 1 1 X hold reset set not allowed 0 0 1 0 X 1 Q(t) R S characteristic equation Q(t+) = S + R’ Q(t) CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 10

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 11 Gated R-S Latch Control when R and S inputs matter Otherwise, the slightest glitch on R or S while enable is low could cause change in value stored enable' S' Q' Q R' R S Set Reset S' R' enable' Q Q' 100 CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 11

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 12 Clocks Used to keep time Wait long enough for inputs (R' and S') to settle Then allow to have effect on value stored Clocks are regular periodic signals Period (time between ticks) Duty-cycle (time clock is high between ticks - expressed as % of period) duty cycle (in this case, 50%) period CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 12

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 13 Clocks (cont’d) Controlling an R-S latch with a clock Can't let R and S change while clock is active (allowing R and S to pass) Only have half of clock period for signal changes to propagate Signals must be stable for the other half of clock period clock' S' Q' Q R' R S clock R' and S' changing stable CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 13

Edge-Triggered Flip-Flops More efficient solution: only 6 gates sensitive to inputs only near edge of clock signal (not while high) Q D Clk=1 R S D’ Q’ holds D' when clock goes low negative edge-triggered D flip-flop (D-FF) 4-5 gate delays must respect setup and hold time constraints to successfully capture input holds D when clock goes low characteristic equation Q(t+1) = D CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 18

Edge-Triggered Flip-Flops (cont’d) Step-by-step analysis Q D Clk=0 R S D’ Q new D Clk=0 R S D D’ new D  old D when clock goes high-to-low data is latched when clock is low data is held CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 19

Edge-Triggered Flip-Flops (cont’d) D = 0, Clk High 1 Act as inverters D’ D D’ Hold state R Q Clk=1 1 S D D’ D CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 20

Edge-Triggered Flip-Flops (cont’d) D = 1, Clk High 1 1 ® 0 0 ® 1 D’ D D’ R Q Clk=1 1 S D 0 ® 1 D’ D 1 CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 21

Edge-Triggered Flip-Flops (cont’d) D = 1, Clk LOW 1 Act as inverters D’ D D’ 0 ® 1 R Q Clk=0 1 ® 0 1 S 0 ® 1 D 1 D’ D CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 22

Edge-Triggered Flip-Flops (cont’d) Positive edge-triggered Inputs sampled on rising edge; outputs change after rising edge Negative edge-triggered flip-flops Inputs sampled on falling edge; outputs change after falling edge 100 D CLK Qpos Qpos' Qneg Qneg' positive edge-triggered FF negative edge-triggered FF CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 23

Negative Edge Trigger FF in Verilog module d_ff (q, q_bar, data, clk); input data, clk; output q, q_bar; reg q; assign q_bar = ~q; always @(negedge clk) begin q <= data; end endmodule CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 24

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 35 Registers Collections of flip-flops with similar controls and logic Stored values somehow related (e.g., form binary value) Share clock, reset, and set lines Similar logic at each stage Examples Shift registers Counters R S D Q OUT1 OUT2 OUT3 OUT4 CLK IN1 IN2 IN3 IN4 "0" CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 35

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 36 Shift Register Holds samples of input Store last 4 input values in sequence 4-bit shift register: D Q IN OUT1 OUT2 OUT3 OUT4 CLK CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 36

Shift Register Verilog module shift_reg (out4, out3, out2, out1, in, clk); output out4, out3, out2, out1; input in, clk; reg out4, out3, out2, out1; always @(posedge clk) begin out4 <= out3; out3 <= out2; out2 <= out1; out1 <= in; end endmodule CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 37

Shift Register Verilog module shift_reg (out, in, clk); output [4:1] out; input in, clk; reg [4:1] out; always @(posedge clk) begin out <= {out[3:1], in}; end endmodule CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 38

Universal Shift Register Holds 4 values Serial or parallel inputs Serial or parallel outputs Permits shift left or right Shift in new values from left or right left_in left_out right_out clear right_in output input s0 s1 clock clear sets the register contents and output to 0 s1 and s0 determine the shift function s0 s1 function 0 0 hold state 0 1 shift right 1 0 shift left 1 1 load new input CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 39

Design of Universal Shift Register Consider one of the four flip-flops New value at next clock cycle: Nth cell to N-1th cell to N+1th cell Q D CLK clear s0 s1 new value 1 – – 0 0 0 0 output 0 0 1 output value of FF to left (shift right) 0 1 0 output value of FF to right (shift left) 0 1 1 input CLEAR s0 and s1 control mux 1 2 3 Q[N-1] (left) Q[N+1] (right) Input[N] CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 40

Universal Shift Register Verilog module univ_shift (out, lo, ro, in, li, ri, s, clr, clk); output [3:0] out; output lo, ro; input [3:0] in; input [1:0] s; input li, ri, clr, clk; reg [3:0] out; assign lo = out[3]; assign ro = out[0]; always @(posedge clk or clr) begin if (clr) out <= 0; else case (s) 3: out <= in; 2: out <= {out[2:0], ri}; 1: out <= {li, out[3:1]}; 0: out <= out; endcase end endmodule CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 41

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 44 Counters Sequences through a fixed set of patterns In this case, 1000, 0100, 0010, 0001 If one of the patterns is its initial state (by loading or set/reset) Mobius (or Johnson) counter In this case, 1000, 1100, 1110, 1111, 0111, 0011, 0001, 0000 D Q IN OUT1 OUT2 OUT3 OUT4 CLK D Q IN OUT1 OUT2 OUT3 OUT4 CLK CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 44

CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 45 Binary Counter Logic between registers (not just multiplexer) XOR decides when bit should be toggled Always for low-order bit, only when first bit is true for second bit, and so on D Q OUT1 OUT2 OUT3 OUT4 CLK "1" CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 45

Binary Counter Verilog module shift_reg (out4, out3, out2, out1, clk); output out4, out3, out2, out1; input in, clk; reg out4, out3, out2, out1; always @(posedge clk) begin out4 <= (out1 & out2 & out3) ^ out4; out3 <= (out1 & out2) ^ out3; out2 <= out1 ^ out2; out1 <= out1 ^ 1b’1; end endmodule CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 46

Binary Counter Verilog module shift_reg (out4, out3, out2, out1, clk); output [4:1] out; input in, clk; reg [4:1] out; always @(posedge clk) out <= out + 1; endmodule CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 47

Sequential Logic Summary Fundamental building block of circuits with state Latch and flip-flop R-S latch, R-S master/slave, D master/slave, edge-triggered D FF Timing methodologies Use of clocks Cascaded FFs work because prop delays exceed hold times Beware of clock skew Basic registers Shift registers Pattern detectors Counters CS 150 - Fall 2005 – Lec. #5 – Sequential Logic - 50