Control in Digital Systems

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

ECE 551: Digital System *

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

VERILOG: FLIP-FLOPS AND REGISTERS

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

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

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

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Finite State Machines

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

FSM and Efficient Synthesizable FSM Design using Verilog

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

Laboratory Exercise 7

EECS 270 Verilog Reference: Sequential Logic

Finite-State Machine (FSM) 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

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

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

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

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

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

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

CS/EE Homework 7 Solutions

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

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

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Quick Introduction to SystemVerilog: Sequental Logic

Finite State Machines (FSM) Description in VHDL. Review and Synthesis

EEL 4783: HDL in Digital System Design

VERILOG 2: LANGUAGE BASICS

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

CSE 140L Final Exam. Prof. Tajana Simunic Rosing. Spring 2008

CSE140L: Components and Design Techniques for Digital Systems Lab

Digital Integrated Circuits

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

RTL Design (Using ASM/SM Chart)

Nikhil Gupta. FPGA Challenge Takneek 2012

CSE140L: Components and Design

Register Transfer Level

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

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

Mealy and Moore examples

CMPE 415 Verilog Case-Statement Based State Machines II

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

Reset-able and Enable-able Registers

Course Topics - Outline

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

CSE 140L Final Exam. Prof. Tajana Simunic Rosing. Spring 2008

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

Laboratory Finite State Machines and Serial Communication

CMPE 415 Verilog Case-Statement Based State Machines II

Finite State Machines

Writing Circuit Descriptions 8

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

Sequential Logic Design

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

EECS 151/251A: SRPING 2017 MIDTERM 1

Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial

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

EECS150 - Digital Design Lecture 6 - Logic Simulation

Digital Integrated Circuits

Verilog Coding Guideline

ECE 353 Lab 3 (Verilog Design Approach)

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

Modeling of Finite State Machines. Debdeep Mukhopadhyay

Chapter 5 Registers & Counters

Verilog for Synthesis Ing. Pullini Antonio

EECS150 - Digital Design Lecture 10 Logic Synthesis

Exp#8: Designing a Programmable Sequence Detector

Last Lecture: Divide by 3 FSM

Verilog for High Performance

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

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

Modeling Sequential Circuits in Verilog

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Why Should I Learn This Language? VLSI HDL. Verilog-2

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

Course Topics - Outline

Digital Design with SystemVerilog

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

Registers and finite state machines

General FSM design procedure

3 Designing Digital Systems with Algorithmic State Machine Charts

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Introduction. Why Use HDL? Simulation output. Explanation

Debouncing a Switch. A Design Example. Page 1

Verilog 1 - Fundamentals

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

Parallel versus serial execution

Building Bigger Systems: Hardware Threads

R07. Code No: V0423. II B. Tech II Semester, Supplementary Examinations, April

University of Technology

EECS150 - Digital Design Lecture 10 Logic Synthesis

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

CSCB58 - Lab 3. Prelab /3 Part I (in-lab) /2 Part II (in-lab) /2 TOTAL /8

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

Topics. Midterm Finish Chapter 7

Testbenches for Sequential Circuits... also, Components

Transcription:

CONTROL CIRCUITS

Control in Digital Systems Three primary components of digital systems Datapath (does the work) Control (manager, controller) Memory (storage) B. Baas 256

Control in Digital Systems Control blocks in chips Typically small amount of HW Typically substantial verilog code Therefore: We typically do not care about small circuit area We typically do not care about fast circuits A possible exception is in cases of data-depent control. For example, if arithmetic is required to make control decisions e.g., "change states if sum < phase" Verilog code can be complex Many opportunities for bugs May be impossible to test all states and transitions Often the focus of testing by Verification Engineers B. Baas 257

Sequential Logic Combinational circuits outputs are a function of the circuit s inputs and a time delay Sequential circuits outputs are a function of the circuit s inputs, previous circuit state, and a time delay input logic output c_state state B. Baas 258

Control with Finite State Machines Of course we can design all standard finite state machines we learned in basic logic design classes Moore type FSM outputs dep only on the present state (state below) Mealy type FSM outputs dep on the present state and the inputs input logic output c_state state B. Baas 259

Design process Writing Verilog for State Machines Think Draw state diagrams if helpful Draw block diagrams if helpful Draw timing diagrams Pick descriptive signal names Think Then Write verilog Test it B. Baas 260

#1 Design Goal for Controllers: Clarity Clear code bugs will be less likely It is even more important to use good signal naming conventions in control logic than with other digital circuits Ex: state_c state Reduce the amount of state if possible (clarity) Ex: It may be better to have one global state machine instead of two separate ones Increase the amount of state if helpful (clarity) Ex: It may be better to have two separate global state machines instead of a single global one Ex: Instantiate separate counters to count indepent events B. Baas 261

I. Counters Typically the output is equal to the state of the counter Frequently the next state is the present state plus a fixed number Ring Counter Count Up Counter Count Down Counter B. Baas 262

II. General FSMs Typically the output is derived from the state but it is not a copy of it The state can be encoded with a compact binary representation Ex: 5 states 3 bits has 8 possible states The state can be encoded one hot with the number of flip-flops equal to the number of states Ex: 5 states 5 state bits B. Baas 263

Good Sequential Circuit Coding Style Example combinational circuit with output freq_c Always declare default values at beginning of always blocks Use all of the best combinational logic design practices gets the final word higher priority or precedence //--- this "always" block instantiates the combinational logic always @(freq or xyz or abc or reset) begin // defaults freq_c = freq; // hold previous value in this case // logic case (freq) begin 3 b000: freq_c = abc; 3 b001: freq_c = abc+3 b001; default: freq_c = 3 bxxx; // error case case // logic if (xyz==4 b0010) begin freq_c = abc; reset abc xyz // reset logic is usually last in always block for highest priority if (reset == 1 b1) begin freq_c = 3 b000; logic freq_c clock freq //--- this "always" block instantiates the register always @(posedge clock) begin freq <= #1 freq_c; B. Baas 264

Characteristics of Virtually Every Well-Designed Verilog State Machine 1) Default: state_c = state; 2) case (state) 3) STATE: begin... for each state. Partition design by state. In traditional 180A-style design, we partition the overall design by bits of the state. 4) if (reset == 1 b1) at the of the combinational always block 5) Instantiate FF register(s) in a separate always block // this "always" block instantiates the combinational logic always @(state or reset or...) begin // defaults state_c = state; // hold previous value in this case case (state) begin INIT: begin... // Add a block for each state default: c_freq = 3 bxxx; // error case case reset logic state_c clock state // reset logic often last in always block for highest priority if (reset == 1 b1) begin state_c = 3 b000; // this "always" block instantiates the register always @(posedge clock) begin state <= #1 state_c; B. Baas 265

Characteristics of a Well-Designed Verilog State Machine with Integrated Counters 1) In the default section, it is probably a good idea to have an autoincrement or auto-decrement statement count_c = count + 8 h01; // Example increment count_c = count - 8 h01; // Example decrement 2) In the idle or wait state, it is probably a good idea to hold the counter value to eliminate unnecessary toggling to reduce power dissipation count_c = count; // Example hold counter value count_c = 8 h00; // Example hold counter at zero B. Baas 266

Example Controller Specification Four states IDLE Go to PREP when go is asserted PREP Do something for 10 cycles Go to JOB1 if x <= 5 Go to JOB2 if x > 5 JOB1 Do something for 5 cycles, then go to IDLE JOB2 Do something for 20 cycles, then go to IDLE reset at any time returns control to IDLE B. Baas 267

Control Block Example Solution (There are many solutions!) State registers Choose two bits (obviously the minimum) since there are four states Counter(s) Choose one five bit counter since states are indepent and counter can be shared between different states Counting down may be slightly better (simpler comparator for all uses compares with zero) Safest to keep registers (flip-flops) separate from state machine logic Always do this for this class It is normally clearer to define states with names (such as IDLE) rather than constants (such as 2'b01) B. Baas 268

Example State Machine State diagram reset IDLE go PREP 10 cycles x <= 5 x > 5 JOB1 5 cycles JOB2 20 cycles B. Baas 269

Example State Machine (untested, could have bugs especially syntax or off-by-one-cycle bugs) parameter IDLE = 2 h0; // constants in hex notation parameter PREP = 2 h1; parameter JOB1 = 2 h2; parameter JOB2 = 2 h3; reg [1:0] state, c_state; // declare both FF regs reg [4:0] count, c_count; // and comb. logic regs // Combinational logic for state machine always @(state or count or go or x or reset) begin // defaults (place first) c_state = state; // default same state c_count = count 5 b00001; // default count down // main state machine logic case (state) IDLE: begin if (go) begin c_state = PREP; c_count = 5 d10; // constant in decimal else begin c_count = 0; // only for lower power PREP: begin if (count == 5 b00000) begin if (x <= 5) begin // goto JOB1 c_state = JOB1; c_count = 5 d05; else begin // goto JOB2 c_state = JOB2; c_count = 5 d20; // PREP JOB1: begin if (count == 5 b00000) begin c_state = IDLE; // count will underflow to 1 but it is ok JOB2: begin if (count == 5 b00000) begin c_state = IDLE; // count will underflow to 1 but it is ok default: begin // good practice, but not used here c_state = 2 bxx; // better for testing c_state = IDLE; // another option case // reset logic (place last to override other logic) if (reset == 1 b1) begin c_state = IDLE; c_count = 5 b00000; // of always block // Instantiates registers (flip-flops) always @(posedge clk) begin state <= #1 c_state; count <= #1 c_count; I think it is better to put reset logic inside the control logic rather than with the FF declaration B. Baas 270