FSMs 1 Sequential logic implementation  Sequential circuits  primitive sequential elements  combinational logic  Models for representing sequential.

Slides:



Advertisements
Similar presentations
Introduction to Sequential Circuits
Advertisements

These slides incorporate figures from Digital Design
COUNTERS Counters with Inputs Kinds of Counters Asynchronous vs
State-machine structure (Mealy)
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
Give qualifications of instructors: DAP
Circuits require memory to store intermediate data
Sequential Circuit Analysis & Design Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals Dr. Aiman H. El-Maleh.
Verilog - 1 Writing Hardware Programs in Abstract Verilog  Abstract Verilog is a language with special semantics  Allows fine-grained parallelism to.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
CS 151 Digital Systems Design Lecture 25 State Reduction and Assignment.
ECE 331 – Digital System Design Introduction to and Analysis of Sequential Logic Circuits (Lecture #20) The slides included herein were taken from the.
Give qualifications of instructors: DAP
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design Finite State.
Logic and Computer Design Fundamentals Registers and Counters
Spring 2002EECS150 - Lec15-seq2 Page 1 EECS150 - Digital Design Lecture 15 - Sequential Circuits II (Finite State Machines revisited) March 14, 2002 John.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
ELEN 468 Advanced Logic Design
VII - Finite State Machines © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Finite State Machines Sequential circuits  primitive sequential elements.
ENGIN112 L25: State Reduction and Assignment October 31, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 25 State Reduction and Assignment.
Lecture 21 Overview Counters Sequential logic design.
1 Lecture 15 Registers Counters Finite State Machine (FSM) design.
Lecture 17 General finite state machine (FSM) design
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Registers CPE 49 RMUTI KOTAT.
VII - Finite State Machines © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Finite State Machines (FSM) Sequential circuits  primitive sequential.
Chapter 2Basic Digital Logic1 Chapter 2. Basic Digital Logic2 Outlines  Basic Digital Logic Gates  Two types of digital logic circuits Combinational.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
1 CSE370, Lecture 19 Lecture 19 u Logistics n Lab 8 this week to be done in pairs íFind a partner before your lab period íOtherwise you will have to wait.
Important Components, Blocks and Methodologies. To remember 1.EXORS 2.Counters and Generalized Counters 3.State Machines (Moore, Mealy, Rabin-Scott) 4.Controllers.
1 CSE370, Lecture 15 Lecture 15 u Logistics n HW5 due this Friday n HW6 out today, due Friday Feb 20 n I will be away Friday, so no office hour n Bruce.
ENG241 Digital Design Week #8 Registers and Counters.
Announcements Assignment 8 posted –Due Friday Dec 2 nd. A bit longer than others. Project progress? Dates –Thursday 12/1 review lecture –Tuesday 12/6 project.
Introduction to State Machine
Review of Digital Logic Design Concepts OR: What I Need to Know from Digital Logic Design (EEL3705)
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
1 CSE370, Lecture 18 Lecture 20 u Logistics n HW6 due Wednesday n Lab 7 this week (Tuesday exception) n Midterm 2 Friday (covers material up to simple.
DLD Lecture 26 Finite State Machine Design Procedure.
Digital Logic Design.
1 Finite State Machines (FSMs) Now that we understand sequential circuits, we can use them to build: Synchronous (Clocked) Finite State Machines Finite.
Introduction to ASIC flow and Verilog HDL
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 11, 2010.
Digital System Design using VHDL
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Chapter 8 Solving Larger Sequential Problems.
1 (c) W. J. Dally Digital Design: A Systems Approach Lecture 7: Data Path State Machines.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Lecture #17: Clocked Synchronous State-Machine Analysis
Figure 8.1. The general form of a sequential circuit.
Chapter #6: Sequential Logic Design
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Supplement on Verilog Sequential circuit examples: FSM
Typical Timing Specifications
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 15 Logistics Last lecture Today HW4 is due today
CSE 370 – Winter Sequential Logic-2 - 1
332:437 Lecture 8 Verilog and Finite State Machines
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Supplement on Verilog Sequential circuit examples: FSM
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 20 Logistics Last lecture Today HW6 due Wednesday
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
332:437 Lecture 8 Verilog and Finite State Machines
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Announcements Assignment 7 due now or tommorrow Assignment 8 posted
CSE 370 – Winter Sequential Logic-2 - 1
Presentation transcript:

FSMs 1 Sequential logic implementation  Sequential circuits  primitive sequential elements  combinational logic  Models for representing sequential circuits  finite-state machines (Moore and Mealy)  representation of memory (states)  changes in state (transitions)  Basic sequential circuits  shift registers  counters  Design procedure  state diagrams  state transition table  next state functions

FSMs 2 Any sequential system can be represented with a state diagram  Shift register  input value shown on transition arcs  output values shown within state node DQDQDQ IN OUT1OUT2OUT3 CLK

FSMs 3 State machine model  Values stored in registers are the state of the circuit  Combinational logic computes:  next state  outputs  function of current state and inputs (Mealy machine)  function of current state only (Moore machine) Inputs Outputs Next State Current State output logic next state logic

FSMs 4 State Machine Model  States: S1, S2,..., Sk  Inputs: I1, I2,..., Im  Outputs: O1, O2,..., On  Transition function: Fs(Si, Ij)  Output function: Fo(Si) or Fo(Si, Ij) Inputs Outputs Next State Current State output logic next state logic

FSMs 5 How do we turn a state diagram into logic?  e.g. counter  flip-flops to hold state  logic to compute next state  clock signal controls when flip-flop memory can change  wait just long enough for combinational logic to compute new value

FSMs 6 FSM design procedure  Describe FSM behavior, e.g. state diagram  Inputs and Outputs  States (symbolic)  State transitions  State diagram to state transition table, i.e. truth table  Inputs: inputs and current state  Outputs: outputs and next state  State encoding  decide on representation of states  lots of choices  Implementation  flip-flop for each state bit  synthesize combinational logic from encoded state table

FSMs 7 Present StateNext State CBAC+B+A+ 000xxx 001xxx xxx note the don't care conditions that arise from the unused state codes Synthesis Example  Implement simple count sequence: 000, 010, 011, 101, 110  Derive the state transition table from the state transition diagram

FSMs 8 C B A X110X1X0X110X1X0 C+C+ C B A X001X1X1X001X1X1 B+B+ C B A X100X0X1X100X0X1 A+A+ C + = B B + = A + B’ C A + = A’ C’ + AC Don’t cares in FSMs (cont’d)  Synthesize logic for next state functions derive input equations for flip- flops

FSMs 9 Self-starting FSMs  Deriving state transition table from don't care assignment C B A C+C+ C B A B+B+ C B A A+A+ Present StateNext State CBAC+B+A x

FSMs 10 implementation on previous slide Self-starting FSMs  Start-up states  at power-up, FSM may be in an used or invalid state  design must guarantee that it (eventually) enters a valid state  Self-starting solution  design FSM so that all the invalid states eventually  transition to a valid state may limit exploitation of don't cares

FSMs 11 Mealy vs. Moore Machines  Moore: outputs depend on current state only  Mealy: outputs may depend on current state and current inputs A L’ R’ / TR, F L / TL L’ R / TL, F

FSMs 12 D/1 E/1 B/0 A/0 C/ reset currentnext resetinputstatestateoutput 1––A 00AB0 01AC0 00BB0 01BD0 00CE0 01CC0 00DE1 01DC1 00EB1 01ED1 Specifying outputs for a Moore machine  Output is only function of state  specify in state bubble in state diagram  Example (what does it do?)

FSMs 13 currentnext resetinputstatestateoutput 1––A0 00AB0 01AC0 00BB0 01BC1 00CB1 01CC0 B A C 0/1 0/0 1/1 1/0 reset/0 Specifying outputs for a Mealy machine  Output is function of state and inputs  specify output on transition arc between states

FSMs 14 state feedback inputs outputsreg combinational logic for next state logic for outputs inputsoutputs state feedback reg combinational logic for next state logic for outputs Comparison of Mealy and Moore machines  Mealy machines tend to have fewer states  different outputs on arcs (i*n) rather than states (n)  Mealy machines react faster to inputs  react in same cycle – don't need to wait for clock  delay to output depends on arrival of input  Moore machines are generally safer to use  outputs change at clock edge (always one cycle later)  in Mealy machines, input change can cause output change as soon as logic is done – a big problem when two machines are interconnected – asynchronous feedback

FSMs 15 ABCinCoutS P.S.N.S. Isn’t Mealy Always Better?  Example: serial adder - add bits arriving serially on two input wires  Adding 5 serial numbers on 5 separate lines  What is the clock period of this circuit? A B CDE Sum ABAB S ABAB S ABAB S ABAB S A B S Cout Cin combinational logic

FSMs 16 Moore Implementation - Pipelined  Example: adding 5 serial numbers  What is the clock period of this circuit? A0 A1 A2 A3 A4 Sum ABAB S ABAB S ABAB S ABAB S A B Cin combinational logic Cout

FSMs 17 Example Abstract Verilog FSM – Breshenham’s Algorithm module breshenham (clk, reset, x1, y1, x2, y2, x, y); input clk, reset; input [7:0] x1, y1, x2, y2; output [7:0] x, y; REGISTER t = 0; REGISTER [7:0] x, y; REGSITER [7:0] dx, dy; parameter INIT=0, RUN=1, DONE=2; REGISTER [2:0] state = INIT; COMB [7:0] temp; ALWAYS begin case (state) INIT: begin x <-- x1; y <-- y1; dx <-- x2 – x1; dy = y2 – y1; t <-- 0; state <-- RUN; end RUN: begin temp = t + dy; if (temp = dx) begin y <-- y + 1; t <-- temp – dx; end else begin t <-- temp; end x <-- x + 1; if (x >= x2) state <-- DONE; end DONE: begin... end endmodule

FSMs 18 Design Problem – Run-Length Encoder  7-bit input stream  8-bit output stream  high-order bit == 0: Data value  high-order bit == 1: Repeat count of previous data value  Valid bit set when 8-bit output is data or count

FSMs 19 RLE Design  Split design into datapath and control  Datapath  Registers for data values, count  Multiplexors  Control  Keep track of what’s happening  clear count, increment count, send data value, send count  Control will be an FSM

FSMs 20 Start with Datapath  We need to know what to control  FSM inputs  eq  FSM outputs  clr, inc, valid, cnt,

FSMs 21 FSM Controller

FSMs 22 Verilog For State Machines  State machine has two parts  State register  Combinational Logic  Next state function  Output function  Each in a different always block inputs Moore outputs Mealy outputs next state current state combinational logic

FSMs 23 Implementing an FSM  1. Perform state assignment  different assignments may give very different results  no really good heuristics  using an extra bit or two for state works well  FPGAs often us a 1-hot encoding  2. Convert state diagram to state table  equivalent representation  mechanical  3. State table gives truth table for next state and output functions  synthesize into logic circuit  e.g. 2-level logic implementation

FSMs 24 RLE State Table  reset is implicit – resets state register eqstatenext stateclrincvalidcnttag -START1START2xx0x - SENDINGxx0x 0 xx10 1 COUNTING1x10 0 SENDINGxx11 1COUNTING 010x

FSMs 25 RLE State Table  minimal binary encoding  there are 6 output functions eqstatenext stateclrincvalidcnttag -0001xx0x - 10xx0x 0 xx x xx x

FSMs 26 Logic Synthesis Q1state eq Q0state eq clrstate eq0XXXX 1XX01 validstate eq incstate eq0XXXX 1XX1X cnttagstate eq0XXX0 1XX10 Q1 = Q1 + Q0 Q0 = Q1’ Q0’ + eq Q1 clr = Q0’ inc = 1 valid = eq’ Q1 + Q1 Q0’ = Q1 (eq’ + Q0’) cnttag = Q0 6 gates

FSMs 27 RLE State Table  1-hot encoding  there are 8 output functions eqstatenext stateclrincvalidcnttag xx0x xx0x 0 xx x xx x

FSMs 28 1-Hot Logic Functions  Synthesize directly from table Q0 = reset Q1 = Q0 Q2 = Q1 + eq’ (Q2 + Q3) Q3 = eq (Q2 + Q3) inc = 1 clr = Q2 valid = Q2 + eq’ Q3 cnttag = Q3  Same cost as minimal encoding (6 gates)