Sequential Logic Implementation. Mealy vs. Moore Machines. Specifying Outputs for a Mealy Machine. Specifying Outputs for a Moore Machine

Similar documents
Mealy and Moore examples

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Instructor: Mohsen Imani. Slides from Tajana Simunic Rosing

General FSM design procedure

General FSM design procedure

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines

EE 231 Fall EE 231 Homework 8 Due October 20, 2010

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2

Chapter 10. case studies in sequential logic design

Finite-State Machine (FSM) Design

Abstraction of State Elements. Sequential Logic Implementation. Forms of Sequential Logic. Finite State Machine Representations

RealDigital. Problem Set #7 S1 S2 S3 Y Z X Y + Y Z X Z

Finite State Machines

Blocking(=) vs Nonblocking (<=) Assignment. Lecture 3: Modeling Sequential Logic in Verilog HDL. Procedural assignments

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date:

Finite State Machines

Outline. EECS Components and Design Techniques for Digital Systems. Lec 11 Putting it all together Where are we now?

Sequential Logic Design

Parallel versus serial execution

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Controller Implementation--Part I. Cascading Edge-triggered Flip-Flops. Clock Skew. Cascading Edge-triggered Flip-Flops. Why Gating of Clocks is Bad!

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

General FSM design procedure

Programming in Esterel

CS 151 Final. Q1 Q2 Q3 Q4 Q5 Total Credit Score. Instructions: Student ID. (Last Name) (First Name) Signature

ECE 551: Digital System *

ECE 551 Digital System Design and Synthesis. Instructor: Kewal K. Saluja. Midterm Exam

Finite State Machines

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines

Quick Introduction to SystemVerilog: Sequental Logic

EECS 270 Verilog Reference: Sequential Logic

Sequential Circuits. inputs Comb FFs. Outputs. Comb CLK. Sequential logic examples. ! Another way to understand setup/hold/propagation time

Alternative Ways to Implement Processor FSMs. Outline. Moore Machine State Diagram. Random Logic. Moore Machine Diagram

EECS 151/251A: SRPING 2017 MIDTERM 1

Homework deadline extended to next friday

problem maximum score 1 10pts 2 8pts 3 10pts 4 12pts 5 7pts 6 7pts 7 7pts 8 17pts 9 22pts total 100pts

The VHDL Hardware Description Language

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Introduction to Verilog and ModelSim. (Part 6 State Machines)

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

EECS Components and Design Techniques for Digital Systems. Lec 07 PLAs and FSMs 9/ Big Idea: boolean functions <> gates.

B.10 Finite State Machines B.10

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design

EECS150 - Digital Design Lecture 7 - Computer Aided Design (CAD) - Part II (Logic Simulation) Finite State Machine Review

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Federal Urdu University of Arts, Science and Technology, Islamabad VLSI SYSTEM DESIGN. Prepared By: Engr. Yousaf Hameed.

CSE140L: Components and Design

VHDL: RTL Synthesis Basics. 1 of 59

CS 151 Midterm. Instructions: Student ID. (Last Name) (First Name) Signature

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

CSE140L: Components and Design Techniques for Digital Systems Lab

Chapter 5 Registers & Counters

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Digital Integrated Circuits

Verilog for High Performance

Writing Circuit Descriptions 8

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

EEL 4783: HDL in Digital System Design

PDHonline Course G349. State Machines. Mark A. Strain, P.E. PDH Online PDH Center

Debouncing a Switch. A Design Example. Page 1

EECS150 - Digital Design Lecture 10 Logic Synthesis

RTL Design (Using ASM/SM Chart)

DIGITAL SYSTEM DESIGN

History: Combinational Logic! single FSM! Hierarchy. Facilities for managing networks of FSMs MISII. Facilities for handling latches

Lecture #1: Introduction

Techniques for Digital Systems Lab. Verilog HDL. Tajana Simunic Rosing. Source: Eric Crabill, Xilinx

Verilog for Synthesis Ing. Pullini Antonio

Introduction. Overview. Top-level module. EE108a Lab 3: Bike light

Lecture 32: SystemVerilog

EECS150 - Digital Design Lecture 6 - Logic Simulation

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

Computer Organization. Structure of a Computer. Registers. Register Transfer. Register Files. Memories

EE 231 Fall EE 231 Homework 13 Due December 3, 2010

Today. Implementation of FSMs. Designing Digital System (1) Designing Digital System (2)

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Control in Digital Systems

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 6 Combinational and sequential circuits

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

I 3 I 2. ! Language of logic design " Logic optimization, state, timing, CAD tools

Modeling Sequential Circuits in Verilog

Alternative controller FSM implementation approaches based on:

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

One and a half hours. Section A is COMPULSORY UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1 Solutions

Verilog introduction. Embedded and Ambient Systems Lab

Modeling of Finite State Machines. Debdeep Mukhopadhyay

Digital Design with SystemVerilog

EECS150 - Digital Design Lecture 10 Logic Synthesis

ARM 64-bit Register File

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

VHDL for Synthesis. Course Description. Course Duration. Goals

Transcription:

uential Logic Implementation! Models for representing sequential circuits " bstraction of sequential elements " Finite state machines and their state diagrams " Inputs/ " Mealy, Moore, and synchronous Mealy machines! Finite state machine design procedure " Verilog specification " eriving state diagram " eriving state transition table " etermining next state and put functions " Implementing combinational logic Mealy vs. Moore Machines! Moore: dep on current state only! Mealy: dep on current state and inputs! nt brain is a Moore Machine " Output does not react immediately to input change! We could have specified a Mealy FSM " Outputs have immediate reaction to inputs " s inputs change, so does next state, doesn t commit until ing event L / TL L R / TL, F react right away to leaving the wall L R / TR, F CS 5 - Spring 27 Lec #7: uential Implementation CS 5 - Spring 27 Lec #7: uential Implementation 2 Specifying Outputs for a Moore Machine! Output is only function of state " Specify in state bubble in state diagram " Example: sequence detector for or reset / / C/ / E/ current next reset input state state put C C E C C E C E E Specifying Outputs for a Mealy Machine! Output is function of state and inputs " Specify put on transition arc between states " Example: sequence detector for or reset/ / / / / C / / current next reset input state state put C C C C C CS 5 - Spring 27 Lec #7: uential Implementation 3 CS 5 - Spring 27 Lec #7: uential Implementation 4 Comparison of Mealy and Moore Machines Mealy and Moore Examples! Mealy Machines t to have less states " ifferent on arcs (n^2) rather than states (n)! Moore Machines are safer to use " Outputs change at edge (always one cycle later) " In Mealy machines, input change can cause put change as soon as logic is done a big problem when two machines are interconnected asynchronous feedback! Mealy Machines react faster to inputs " React in same cycle don't need to wait for " In Moore machines, more logic may be necessary to decode state into more gate delays after! Recognize, =, " Mealy or Moore? inputs Combinational logic for ext State reg Logic for inputs Logic for Combinational logic for ext State reg state feedback CS 5 - Spring 27 Lec #7: uential Implementation 5 state feedback CS 5 - Spring 27 Lec #7: uential Implementation 6

Mealy and Moore Examples Registered Mealy Machine (Really Moore)! Recognize, =, then, " Mealy or Moore?! Synchronous (or registered) Mealy Machine " Registered state " voids glitchy " Easy to implement in programmable logic! Moore Machine with no put decoding " Outputs computed on transition to next state rather than after entering " View as expanded state vector Inputs put logic next state logic Outputs CS 5 - Spring 27 Lec #7: uential Implementation 7 Current State CS 5 - Spring 27 Lec #7: uential Implementation 8 Verilog FSM - Reduce s Example Moore Verilog FSM! Change the first to in each string of s " Example Moore machine implementation // State assignment parameter =, one =, twos = 2; module reduce (, clk, reset, in); put ; input clk, reset, in; reg ; reg [:] state; // state register reg [:] next_state; [] one [] twos [] always @(in or state) : begin // last input was a = ; if (in) next_state = one; one: begin // we've seen one = ; if (in) next_state = twos; twos: begin // we've seen at least 2 ones = ; if (in) next_state = twos; default: begin // in case we reach a bad state = ; next_state = ; case [] include all signals that are input to state and put equations one [] twos [] CS 5 - Spring 27 Lec #7: uential Implementation 9 CS 5 - Spring 27 Lec #7: uential Implementation Moore Verilog FSM Mealy Verilog FSM for Reduce-s Example // Implement the state register if (reset) state <= ; else state <= next_state; module [] one [] twos [] module reduce (clk, reset, in, ); input clk, reset, in; put ; reg ; reg state; // state register reg next_state; parameter =, one = ; always @(in or state) : begin // last input was a if (in) next_state = one; = ; one: // we've seen one if (in) begin next_state = one; = ; next_state = ; = ; case / / one / / if (reset) state <= ; else state <= next_state; CS 5 - Spring 27 Lec #7: uential Implementation module CS 5 - Spring 27 Lec #7: uential Implementation 2

Synchronous Mealy Verilog FSM for Reduce-s Example module reduce (clk, reset, in, ); input clk, reset, in; put ; reg ; reg state; // state register reg next_state; reg next_; parameter =, one = ; always @(in or state) : begin // last input was a if (in) next_state = one; next_ = ; one: // we've seen one if (in) begin next_state = one; next_ = ; next_state = ; next_ = ; case if (reset) begin state <= ; <= ; state <= next_state; <= next_; module / CS 5 - Spring 27 Lec #7: uential Implementation 3 one / / / nnouncements! Review Session nnouncement! First Midterm, Thursday, 5 February, 2-3:3 PM, 25 Cory Hall "??? uiz-like uestions -- Please Read Them Carefully! They are not inted to be tricky; they should contain all the information you need to answer the question correctly " o calculators or other gadgets are necessary! on t bring them! o blue books! ll work on the sheets handed! " o bring pencil and eraser please! If you like to unstaple the exam pages, then bring a stapler with you! Write your name and student I on EVERY page in case they get separated -- it has happened! " on t forget your two-sided 8.5 x crib sheet! CS 5 - Spring 27 Lec #7: uential Implementation 4 nnouncements Example: Ving Machine! Examination, Th, 2-3:3 PM, 25 Cory Hall " Topics likely to be covered # Combinational logic: design and optimization (K-maps up to and including 6 variables) # Implementation: Simple gates (minimum wires and gates), PL structures (minimum unique terms), Muxes, ecoders, ROMs, (Simplified) Xilinx CL # uential logic: R-S latches, flip-flops, transparent vs. edge-triggered behavior, master/slave concept # asic Finite State Machines: Representations (state diagrams, transition tables), Moore vs. Mealy Machines, Shifters, Registers, Counters # Structural and ehavioral Verilog for combinational and sequential logic # Labs, 2, 3 # K&: Chapters, 2 (2.-2.5), 3 (3., 3.6), 4 (4., 4.2, 4.3), 6 (6., 6.2., 6.3), 7 (7., 7.2, 7.3)! Release item after 5 cents are deposited! Single coin slot for dimes, nickels! o change Coin Sensor Ving Machine FSM Release Mechanism Clock CS 5 - Spring 27 Lec #7: uential Implementation 5 CS 5 - Spring 27 Lec #7: uential Implementation 6 Example: Ving Machine Example: Ving Machine! Suitable bstract Representation " Tabulate typical input sequences: # 3 nickels # nickel, dime # dime, nickel # two dimes " raw state diagram: # Inputs:,, reset # Output: open chute " ssumptions: # ssume and asserted for one cycle # Each state has a self loop for = = (no coin) S3 S7 S S4 S S2 S5 S6! Minimize number of states - reuse states whenever possible + present inputs next put state state open symbolic state table CS 5 - Spring 27 Lec #7: uential Implementation 7 CS 5 - Spring 27 Lec #7: uential Implementation 8

Example: Ving Machine Example: Ving Machine! Uniquely Encode States present state inputs next state put open! Mapping to Logic X X X X X X X X X X X X = + + = + + + OPE = CS 5 - Spring 27 Lec #7: uential Implementation 9 CS 5 - Spring 27 Lec #7: uential Implementation 2 Example: Ving Machine! One-hot Encoding Equivalent Mealy and Moore State iagrams! Moore machine " associated with state Mealy machine associated with transitions present state inputs next state put 3 2 3 2 open - - - - - - - - - - - - - - - - - = = + 2 = + + 2 3 = + 2 + 2 + 3 OPE = 3 [] + [] [] + / ( + )/ / / / / / / / +/ [] / CS 5 - Spring 27 Lec #7: uential Implementation 2 CS 5 - Spring 27 Lec #7: uential Implementation 22 Moore Verilog FSM for Ving Machine Mealy Verilog FSM for Ving Machine module ving (open, Clk,,, ); input Clk,,, ; put open; reg open; reg state; // state register reg next_state; parameter =, five =, ten = 2, fifteen = 3; always @( or or state) : begin if () next_state = five; else if () next_state = ten; case else open = ; fifteen: begin next_state = ; if (!) next_state = fifteen; open = ; [] + [] [] [] + module ving (open, Clk,,, ); input Clk,,, ; put open; reg open; reg state; // state register reg next_state; reg next_open; parameter =, five =, ten = 2, fifteen = 3; always @( or or state) : begin if () begin next_state = ten; next_open = ; else if () begin next_state = five; next_open = ; next_state = ; next_open = ; case / / / / / +/ ( + )/ / / / / if ( (! &&!)) state <= ; else state <= next_state; module if ( (! &&!)) begin state <= ; open <= ; state <= next_state; open <= next_open; module CS 5 - Spring 27 Lec #7: uential Implementation 23 CS 5 - Spring 27 Lec #7: uential Implementation 24

! busy highway is intersected by a little used farmroad! etectors C sense the presence of cars waiting on the farmroad " with no car on farmroad, light remain green in highway direction " if vehicle on farmroad, highway lights go from Green to Yellow to Red, allowing the farmroad lights to become green " these stay green only as long as a farmroad car is detected but never longer than a set interval " when these are met, farm lights transition from Green to Yellow to Red, allowing highway to return to green " even if farmroad vehicles are waiting, highway gets at least a set interval as green! ssume you have an interval timer that generates: " a short time pulse (TS) and " a long time pulse (TL), " in response to a set (ST) signal. " TS is to be used for timing yellow lights and TL for green lights! Highway/farm road intersection farm road car sensors highway CS 5 - Spring 27 Lec #7: uential Implementation 25 CS 5 - Spring 27 Lec #7: uential Implementation 26! Tabulation of Inputs and Outputs inputs description description reset place FSM in initial state HG, HY, HR assert green/yellow/red highway lights C detect vehicle on the farm road FG, FY, FR assert green/yellow/red highway lights TS short time interval expired ST start timing a short or long interval TL long time interval expired! Tabulation of unique states some light configurations imply others state description S highway green (farm road red) S highway yellow (farm road red) S2 farm road green (highway red) S3 farm road yellow (highway red)! State iagram (TL C)' S S: HG TL C / ST S: HY S2: FG S3: FY TS' S S3 TL+C' / ST S2 (TL+C')' TS' CS 5 - Spring 27 Lec #7: uential Implementation 27 CS 5 - Spring 27 Lec #7: uential Implementation 28! Generate state table with symbolic states! Consider state assignments Inputs Present State ext State Outputs C TL TS ST H F HG HG Green Red HG HG Green Red HG HY Green Red HY HY Yellow Red HY FG Yellow Red FG FG Red Green FG FY Red Green FG FY Red Green FY FY Red Yellow FY HG Red Yellow S: HG = HY = FG = FY = S2: HG = HY = FG = FY = S3: HG = HY = FG = FY = (one-hot) CS 5 - Spring 27 Lec #7: uential Implementation 29 put encoding similar problem to state assignment (Green =, Yellow =, Red = ) Traffic Light Controller Verilog module traffic (ST, Clk,, C, TL, TS); input Clk,, C, TL, TS; put ST; reg ST; reg state; reg next_state; reg next_st; parameter S =, S =, S2 = 2, S3 = 3; always @(C or TL or TS or state) S: if (!(TL && C)) begin next_state = S; next_st = ; else if (TL C) begin next_state = S; next_st = ; case always @(posedge Clk) if () begin state <= S; ST <= ; state <= next_state; ST <= next_st; module TS' TL C S (TL C)' CS 5 - Spring 27 Lec #7: uential Implementation 3 S TL+C / ST S2 (TL+C')' S3 TL+C' / ST TS'

Logic for ifferent State ssignments Ving Machine Example Revisted (PL mapping)! S S = C TL' PS PS + TS PS' PS + TS PS PS' + C' PS PS + TL PS PS S = C TL PS' PS' + C TL' PS PS + PS' PS OPE = reset'(' + ' + + ) = reset'( + + ) = CLK ST = C TL PS' PS' + TS PS' PS + TS PS PS' + C' PS PS + TL PS PS H = PS H = PS' PS F = PS' F = PS PS'! S2 S = C TL PS' + TS' PS + C' PS' PS S = TS PS PS' + PS' PS + TS' PS PS ST = C TL PS' + C' PS' PS + TS PS H = PS H = PS PS' F = PS' F = PS PS! S3 S3 = C' PS2 + TL PS2 + TS' PS3 S2 = TS PS + C TL' PS2 S = C TL PS + TS' PS S = C' PS + TL' PS + TS PS3 ST = C TL PS + TS PS + C' PS2 + TL PS2 + TS PS3 H = PS3 + PS2 H = PS F = PS + PS F = PS3 Com CS 5 - Spring 27 Lec #7: uential Implementation 3 CS 5 - Spring 27 Lec #7: uential Implementation 32 Ving Machine Ving Machine (Retimed PL Mapping)! OPE = creates a combinational delay after and change! This can be corrected by retiming, i.e., move flip-flops and logic through each other to improve delay! OPE = reset'( + + )(' + ' + + ) = reset'(' + + + ' + ')! Implementation now looks like a synchronous Mealy machine " Common for programmable devices to have FF at of logic OPE = reset'(' + + + ' + ') CLK OPE CS 5 - Spring 27 Lec #7: uential Implementation 33 CS 5 - Spring 27 Lec #7: uential Implementation 34 uential Logic Implementation Summary! Models for representing sequential circuits " bstraction of sequential elements " Finite state machines and their state diagrams " Inputs/ " Mealy, Moore, and synchronous Mealy machines! Finite state machine design procedure " Verilog specification " eriving state diagram " eriving state transition table " etermining next state and put functions " Implementing combinational logic CS 5 - Spring 27 Lec #7: uential Implementation 35