1 COMP541 Sequential Circuits Montek Singh Feb 24, 2016.

Slides:



Advertisements
Similar presentations
Synchronous Sequential Logic
Advertisements

Sequential Logic ENEL 111. Sequential Logic Circuits So far we have only considered circuits where the output is purely a function of the inputs With.
EE 5900 Advanced Algorithms for Robust VLSI CAD, Spring 2009 Sequential Circuits.
COE 202: Digital Logic Design Sequential Circuits Part 1 Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office: Ahmad Almulhem, KFUPM.
1 Fundamentals of Computer Science Sequential Circuits.
CHAPTER 3 Sequential Logic/ Circuits.  Concept of Sequential Logic  Latch and Flip-flops (FFs)  Shift Registers and Application  Counters (Types,
Flip-Flops, Registers, Counters, and a Simple Processor
Classification of Digital Circuits  Combinational. Output depends only on current input values.  Sequential. Output depends on current input values and.
Digital Logic Chapter 5 Presented by Prof Tim Johnson
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 12 Basic (NAND) S – R Latch “Cross-Coupling” two NAND gates gives the S -R Latch:
Sequential Circuits1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
Fall 2004EE 3563 Digital Systems Design EE 3563 Sequential Logic Design Principles  A sequential logic circuit is one whose outputs depend not only on.
Module 12.  In Module 9, 10, 11, you have been introduced to examples of combinational logic circuits whereby the outputs are entirely dependent on the.
1 Lecture 20 Sequential Circuits: Latches. 2 Overview °Circuits require memory to store intermediate data °Sequential circuits use a periodic signal to.
Sequential Circuits : Part I Read Sections 5-1, 5-2, 5-3.
Dr. ClincyLecture1 Appendix A – Part 2: Logic Circuits Current State or output of the device is affected by the previous states Circuit Flip Flops New.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 5 – Sequential Circuits Part 1 – Storage.
1 COMP541 Sequential Circuits Montek Singh Sep 17, 2014.
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits – I Flip-Flops A sequential circuit is a logic components whose outputs.
Lecture 12 Latches Section Schedule 3/10MondayLatches (1) /12WednesdayFlip-flops5.4 3/13ThursdayFlip-flops, D-latch 3/17MondaySpring.
EKT 124 / 3 DIGITAL ELEKTRONIC 1
Lecture 12 Latches Section , Block Diagram of Sequential Circuit gates New output is dependent on the inputs and the preceding values.
Sequential circuit Digital electronics is classified into combinational logic and sequential logic. In combinational circuit outpus depends only on present.
Sequential Circuits. 2 Sequential vs. Combinational Combinational Logic:  Output depends only on current input −TV channel selector (0-9) Sequential.
EE 4271 VLSI Design, Fall 2010 Sequential Circuits.
Fall 2007 L16: Memory Elements LECTURE 16: Clocks Sequential circuit design The basic memory element: a latch Flip Flops.
Sequential Circuit  It is a type of logic circuit whose output depends not only on the present value of its input signals but on the past history of its.
A State Element “Zoo”.
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
Overview Logistics Last lecture Today HW5 due today
Digital Computer Design Fundamental
COE 202: Digital Logic Design Sequential Circuits Part 1
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 9 Sequential.
Chap 4. Sequential Circuits
ENG241 Digital Design Week #6 Sequential Circuits (Part A)
Flip-Flops and Registers
Synchronous Sequential Circuits by Dr. Amin Danial Asham.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1 Lecture #11 EGR 277 – Digital Logic Ch. 5 - Synchronous Sequential Logic There are two primary classifications of logic circuits: 1.Combinational logic.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2007.
COMP541 Sequential Circuits
Synchronous Sequential Logic A digital system has combinational logic as well as sequential logic. The latter includes storage elements. feedback path.
Lecture 5. Sequential Logic 1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education & Research.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Chapter5: Synchronous Sequential Logic – Part 1
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.
Synchronous Sequential Circuits by Dr. Amin Danial Asham.
TOPIC : Introduction to Sequential Circuits UNIT 1: Modeling and Simulation Module 4 : Modeling Sequential Circuits.
1 Modeling Synchronous Logic Circuits Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
Sequential logic circuits First Class 1Dr. AMMAR ABDUL-HAMED KHADER.
Overview Logistics Last lecture Today HW5 due today
Lecture 10 Flip-Flops/Latches
2018/5/2 EE 4271 VLSI Design, Fall 2016 Sequential Circuits.
Supplement on Verilog FF circuit examples
Last Lecture Talked about combinational logic always statements. e.g.,
COMP541 Sequential Circuits
2018/8/29 EE 4271 VLSI Design, Fall 2013 Sequential Circuits.
ECE Digital logic Lecture 16: Synchronous Sequential Logic
CS Fall 2005 – Lec. #5 – Sequential Logic - 1
Buttons and Debouncing Finite State Machine
COMP541 Sequential Circuits
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
FLIP-FLOPS.
Sequential Circuits UNIT- IV
Lecture 3: Timing & Sequential Circuits
Presentation transcript:

1 COMP541 Sequential Circuits Montek Singh Feb 24, 2016

2Topics  Sequential Circuits Latches Latches Flip Flops Flip Flops  Verilog for sequential design Example: A simple counter Example: A simple counter

3 Sequential Circuits  State of system is information stored/memorized State and inputs determine outputs State and inputs determine outputs

4 Types of Sequential Circuits  Synchronous State changes synchronized by one or more clocks State changes synchronized by one or more clocks  Asynchronous There are no clocks, but changes are triggered by events (e.g., inputs changing) There are no clocks, but changes are triggered by events (e.g., inputs changing)

5 Clocking of Synchronous  Changes enabled by clock

6Comparison  Synchronous Easier to analyze because can factor out gate delays Easier to analyze because can factor out gate delays Set clock so changes occur before next clock pulse Set clock so changes occur before next clock pulse  Asynchronous Potentially faster Potentially faster Harder to analyze (more subtle, but more powerful!) Harder to analyze (more subtle, but more powerful!)  Most of my research!  This course will look mostly at synchronous

Storage Elements  Several types: Latch Latch Flip-Flop Flip-Flop Registers Registers Addressable memories or banks of registers Addressable memories or banks of registers 7

8 Basic Storage  Need feedback to hold a value Apply low or high once, and it will persist Apply low or high once, and it will persist Figure 3.1 Cross-coupled inverter pair

Bistable circuits  Consider 2 possible cases: Q = 0: then Q’ = 1 and Q = 0 (consistent) Q = 0: then Q’ = 1 and Q = 0 (consistent) Q = 1: then Q’ = 0 and Q = 1 (consistent) Q = 1: then Q’ = 0 and Q = 1 (consistent)  Bistable circuit stores 1 bit of state in the state variable, Q (or Q’)  But there are no inputs to control the state

SR (set-reset) Latch  Basic storage made from gates A “1” on the input sets/resets the output A “1” on the input sets/resets the output  ‘1’ on S sets the output Q to ‘1’  ‘1’ on R resets the output Q to ‘0’  S & R both 0 in “resting” state  If both S & R are 1, Q and Q’ are both 0 not a very useful case not a very useful case Figure 3.3 SR latch schematic 10

SR (set-reset) Latch  Bistable: Has two stable states 11

SR Latch  Symbol 12

13 SR Latch: Operation

14 Latch Latch  Similar, but dual made from NANDs made from NANDs A “0” on the input sets/resets the output A “0” on the input sets/resets the output  ‘0’ on S’ sets the output Q to ‘1’  ‘0’ on R’ resets the output Q to ‘0’

SR Latch Summary  SR stands for Set/Reset Latch Stores one bit of state (Q) Stores one bit of state (Q)  Control what value is being stored with S, R inputs Set: Make the output 1 (S = 1, R = 0, Q = 1) Set: Make the output 1 (S = 1, R = 0, Q = 1) Reset: Make the output 0 (S = 0, R = 1, Q = 0) Reset: Make the output 0 (S = 0, R = 1, Q = 0)  Behavior undesirable when: S = R = 1 S = R = 1  Q and Q’ are no longer complementary

16 D Latch  Two modifications to SR latch Eliminate illegal state Eliminate illegal state  ensure that “set” and “reset” cannot be simultaneously asserted  simply have one input called D (data) –S is derived from D; R from D’ Add a control input (CLK) Add a control input (CLK)  to decide when the state should change Figure 3.7 D latch: (a) schematic, (b) truth table, (c) symbol

17 D Latch: Operation  When CLK = 0 both S and R are 0 both S and R are 0  previous value of output is held  When CLK = 1 S=D, R=D’ S=D, R=D’  output is set to 1 if input D =1  output is reset to 0 if input D =0  output is updated to the value of input D NOTE: output will be continuously updated to D while CLK=1 NOTE: output will be continuously updated to D while CLK=1 Figure 3.7 D latch: (a) schematic, (b) truth table, (c) symbol

18 D Latch: Transparency  Summary: When CLK = 0 When CLK = 0  output is held  we say: “D latch is opaque” When CLK = 1 When CLK = 1  output follows the input  we say: “D latch is transparent” Figure 3.7 D latch: (a) schematic, (b) truth table, (c) symbol

19 Effects of Transparency  Output of latch may feed back May cause/allow further state changes May cause/allow further state changes Behavior depends on actual gate delays Behavior depends on actual gate delays  Want to change latch state only once Behavior should depend only on logical values Behavior should depend only on logical values

Toll Booth Analogy 20

Flakey Control Systems Here’s a strategy for saving 2 bucks the next time you find yourself at a toll booth!

Flakey Control Systems Here’s a strategy for saving 2 bucks the next time you find yourself at a toll booth!

Flakey Control Systems WARNING: DON’T try this At home! Here’s a strategy for saving 2 bucks the next time you find yourself at a toll booth!

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy The Solution: Add two gates and only open one at a time.

Escapement Strategy Key Idea: At no time is there an open path through both gates… The Solution: Add two gates and only open one at a time.

Solution to Transparency: Flip-Flops Flip-Flops: Ensure output changes only once per clock cycle Ensure output changes only once per clock cycle Master-Slave construction Master-Slave construction  Use a sequence of two latches 40

41 D Flip-Flop (Master-Slave Flip-Flop)  Either Master or Slave is enabled, not both Master typically controlled by CLK’ and slave by CLK Master typically controlled by CLK’ and slave by CLK  positive edge-triggered  example on right Another common form has master controlled by CLK and slave by CLK’ Another common form has master controlled by CLK and slave by CLK’  negative edge-triggered Figure 3.8 D flip-flop: (a) schematic, (b) symbol, (c) condensed symbol

D Flip-Flop: Operation  Edge-triggered when CLK goes from 0 to 1 when CLK goes from 0 to 1  output Q is updated once to the input D value all other times, output is held all other times, output is held  Why? master latch is transparent when CLK=0 master latch is transparent when CLK=0  the last value of D that goes through to N1 is when CLK goes to 1 slave latch is transparent when CLK=1 slave latch is transparent when CLK=1  the value that goes through is N1  i.e., last value of D just before CLK goes to 1 Figure 3.8 D flip-flop: (a) schematic, (b) symbol, (c) condensed symbol 42

Register  Simply multi-bit flip-flops N flip-flops stacked on top of each other = N-bit Register N flip-flops stacked on top of each other = N-bit Register 43 Figure 3.9 A 4-bit register: (a) schematic and (b) symbol

44 Adding More Control Inputs: Enable  Enable determines whether new data from input is captured on next clock edge, or ignored determines whether new data from input is captured on next clock edge, or ignored 2 implementations (first one better) 2 implementations (first one better)  when EN=0, old value cycles back  when EN=0, clock tick doesn’t reach the flip-flop –messing with clock is messy! Figure 3.10 Enabled flip-flop: (a, b) schematics, (c) symbol

Adding More Control Inputs: Reset  Reset (synchronous) if RESET=1 if RESET=1  on next clock tick, stored value is changed to 0 alternatively, if “Preset” or “Set” is used alternatively, if “Preset” or “Set” is used  on next clock tick, stored value changed to 1 45 Figure 3.11 Synchronously resettable flip-flop: (a) schematic, (b, c) symbols

Adding More Control Inputs: Reset  Asynchronous Reset stored value is reset immediately stored value is reset immediately if RESET=1 if RESET=1  stored value is changed to 0  does not wait for a clock tick requires modification to internal structure of latches of the flip-flop requires modification to internal structure of latches of the flip-flop  design not discussed in class, but may be a fun exercise for you! 46

Latch and Flip-Flop comparison  Latch is transparent throughout the interval CLK=1 is transparent throughout the interval CLK=1  all input changes during this time go through!  Flip-Flop only copies input to output at discrete instants only copies input to output at discrete instants  last input D just before clock tick go through 47

Counters  Increments on each clock edge  Used to cycle through numbers For example, 000, 001, 010, 011, 100, 101, 110, 111, 000, 001… 000, 001, 010, 011, 100, 101, 110, 111, 000, 001… Not necessarily binary Not necessarily binary  Example uses: Digital clock displays Digital clock displays Program counter Program counter

Verilog design patterns for sequential logic 49

Verilog for Sequential  One option is to use structural Verilog Can use latches and flip-flops from library Can use latches and flip-flops from library And connect them using wires And connect them using wires  Alternative: Use behavioral Verilog more productive to write behavioral description more productive to write behavioral description if you follow the templates provided, the synthesis tool can infer sequential logic if you follow the templates provided, the synthesis tool can infer sequential logic 50

Logic ( logic ) Data Type  Like wire but value is retained over time  IF NEEDED: causes latch/flipflop to be synthesized if SystemVerilog clearly describes a combinational block if SystemVerilog clearly describes a combinational block  combinational circuit is synthesized, and output type becomes wires if SystemVerilog describes a value that needs to be “held” if SystemVerilog describes a value that needs to be “held”  a latch or flipflop is synthesized  Difference between wire and logic : wire must be continuously assigned (using assign ) wire must be continuously assigned (using assign )  only creates combinational logic for the wire logic can be intermittently updated logic can be intermittently updated  value is held or memorized between updates  but… “intermittent” includes “continuous” as a special case: no hold periods between updates 51

wire vs. logic  a signal of type wire must be continuously assign ed since it cannot have memory since it cannot have memory wire z; assign z = a&b | c&d; // combinational func wire zz = a&b | c&d; // shorter form  logic can be intermittently updated holds its value between updates holds its value between updates must specify the discrete events when updates occur must specify the discrete events when updates occur logic [3:0] z = 0; clock) z <= z + 1; // sequential func 52

wire vs. logic  logic can be intermittently updated holds its value between updates holds its value between updates must specify the discrete events when updates occur must specify the discrete events when updates occur Example: counter Example: counter logic [3:0] z = 0; clock) z <= z + 1; // sequential func Example: stimulus in tester Example: stimulus in tester logic [31:0] A = 0; initial begin #10 A = 1; // discrete time instants #10 A = 2; …end 53

wire vs. logic  As a special case: “intermittent” includes “continuous” “intermittent” includes “continuous”  logic can also be assign ed logic zz = a&b | c&d; update instants are implicitly defined update instants are implicitly defined  whenever a or b or c or d changes value  update zz since updates occur whenever inputs change, SystemVerilog infers a combinational circuit since updates occur whenever inputs change, SystemVerilog infers a combinational circuit  with no need for latches/flipflops 54

Always Block  Example ( sensitivity list ) statement; statement;  Sensitivity list determines when statements are evaluated Could think of it as “statement is evaluated whenever one of values in sensitivity list changes” Could think of it as “statement is evaluated whenever one of values in sensitivity list changes”  Example next slide 55

Synthesize a Flip-Flop module flop ( input wire C, D, input wire C, D, output logic Q // Q needs 1 bit of storage output logic Q // Q needs 1 bit of storage ); ); C) // here’s how Q is updated C) // here’s how Q is updated Q <= D; Q <= D;endmodule  Behavioral description: C)  whenever C transitions from 0 to 1a C)  whenever C transitions from 0 to 1a Q <= D;  output Q is updated to input D Q <= D;  output Q is updated to input D 56 negedge also possible

Blocking vs. Non-blocking Assignment  Blocking assignments: Equal sign indicates blocking statements Equal sign indicates blocking statements B = A; C = B; Result: new contents of B are in C, so all have contents of A Result: new contents of B are in C, so all have contents of A  Non-blocking assignments: RHS of all <= lines within a begin-end block are evaluated in parallel, then assigned to LHS signals in parallel RHS of all <= lines within a begin-end block are evaluated in parallel, then assigned to LHS signals in parallel B <= A; C <= B; Result: new B is the value of A, but new C is the old B! Result: new B is the value of A, but new C is the old B! 57

This is Not Software!  Don’t assign to same signal in more than one always_ff block The always_ff blocks are concurrent The always_ff blocks are concurrent Doesn’t make sense to set a flipflop from two different inputs Doesn’t make sense to set a flipflop from two different inputs  For sequential logic: Use only non-blocking assignments you usually don’t mean one-by-one execution anyway you usually don’t mean one-by-one execution anyway yields the design pattern that is recognized by the compiler yields the design pattern that is recognized by the compiler  each logic on the LHS becomes a flip-flop/register  each RHS becomes the input D to the flipflop  sensitivity list ( posedge clock ) determines the clock signal  enables/resets are also inferred if described 58

Verilog template: Synchronous Reset CLK) begin begin if (RESET) if (RESET) state <= 0; else else state <= D; state <= D; end endOR CLK) state <= RESET? 0 : D;  Remember: This is just a template that the SystemVerilog compiler recognizes 59

Verilog template: Asynchronous Reset CLK, posedge RESET) begin begin if (RESET) if (RESET) state <= 0; else else state <= D; state <= D; end endOR CLK, posedge RESET) state <= RESET? 0 : D;  Remember: This is just a template that the SystemVerilog compiler recognizes 60

Verilog template: Counter module counter( input wire clk, input wire clk, output logic [23:0] cnt output logic [23:0] cnt ); ); (posedge clk) cnt <= cnt + 1’b 1; endmodule 61

Simulation vs. Synthesis  If you don’t initialize flipflops/registers in your circuits, simulator will complain many values will be X many values will be X  Electronics will work OK each flipflop in actual circuit will “wake up” to a 0 or 1 value each flipflop in actual circuit will “wake up” to a 0 or 1 value 62

SystemVerilog Syntax: Initialization  Can initialize flipflops/registers at declaration logic onebit = 1’b 0; logic [3:0] fourbits = 4’b 1011; logic [23:0] cnt = 0; // widths default to 32 bits // and are padded // and are padded // or truncated (keep LSBs) // or truncated (keep LSBs)  DO NOT initialize combinational logic! initial values of a combinational circuit are determined solely by the initial values of its inputs initial values of a combinational circuit are determined solely by the initial values of its inputs logic z onebit = 1’b 0; // should not initialize! assign z = x & y; // a combinational func 63

Summary  Today Looked at basic latches Looked at basic latches Flip-flops Flip-flops Verilog for sequential circuits Verilog for sequential circuits Simple counter Simple counter 64

Read  Textbook Ch and Ch for today Ch for next class Ch for next class  Next Class: State Machines 65