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

Similar documents
Verilog Module 1 Introduction and Combinational Logic

Sequential Logic - Module 5

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

Verilog for High Performance

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

CSE140L: Components and Design Techniques for Digital Systems Lab

EEL 4783: HDL in Digital System Design

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

CSE140L: Components and Design

Verilog for Synthesis Ing. Pullini Antonio

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

FPGA for Software Engineers

VHDL for Synthesis. Course Description. Course Duration. Goals

EE260: Digital Design, Spring 2018

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

Designing Safe Verilog State Machines with Synplify

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

VHDL for Modeling - Module 10

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

ECE 551: Digital System *

Lecture #1: Introduction

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Note: Closed book no notes or other material allowed, no calculators or other electronic devices.

Xilinx ASMBL Architecture

Writing Circuit Descriptions 8

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

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

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

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

Digital Design with FPGAs. By Neeraj Kulkarni

Finite State Machines

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

PINE TRAINING ACADEMY

CMPE 415 Verilog Case-Statement Based State Machines II

Topics. Midterm Finish Chapter 7

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Laboratory Exercise 7

VHDL: RTL Synthesis Basics. 1 of 59

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

Modeling of Finite State Machines. Debdeep Mukhopadhyay

Field Programmable Gate Array

2015 Paper E2.1: Digital Electronics II

Topics. Midterm Finish Chapter 7

קורס VHDL for High Performance. VHDL

Finite State Machines

Verilog. Verilog for Synthesis

XST User Guide

Asynchronous FIFO Design

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

Digital Design with SystemVerilog

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

General FSM design procedure

General FSM design procedure

State Machine Descriptions

Field Programmable Gate Array (FPGA)

Sequential Circuit Design: Principle

CMPE 415 Verilog Case-Statement Based State Machines II

Verilog introduction. Embedded and Ambient Systems Lab

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and

Sequential Logic Design

Digital Design Using Digilent FPGA Boards -- Verilog / Active-HDL Edition

Synthesis Options FPGA and ASIC Technology Comparison - 1

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

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

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

Chap 6 Introduction to HDL (d)

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

An easy to read reference is:

Chapter 9: Sequential Logic Modules

Synthesis of Combinational and Sequential Circuits with Verilog

Finite-State Machine (FSM) Design

Mealy and Moore examples

VHDL Modeling Behavior from Synthesis Perspective -Part B - EL 310 Erkay Savaş Sabancı University

Chapter 10. case studies in sequential logic design

ECEU530. Homework 4 due Wednesday Oct 25. ECE U530 Digital Hardware Synthesis. VHDL for Synthesis with Xilinx. Schedule

Quick Introduction to SystemVerilog: Sequental Logic

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences. Spring 2010 May 10, 2010

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

FSM-based Digital Design using Veriiog HDL

Debouncing a Switch. A Design Example. Page 1

Verilog Tutorial. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

A Brief Introduction to Verilog Hardware Definition Language (HDL)

Verilog Tutorial 9/28/2015. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

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

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

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

Sequential Circuit Design: Principle

RTL Design (Using ASM/SM Chart)

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

CS6710 Tool Suite. Verilog is the Key Tool

Homework deadline extended to next friday

R07. IV B.Tech. II Semester Supplementary Examinations, July, 2011

Lecture 12 VHDL Synthesis

Laboratory Finite State Machines and Serial Communication

N-input EX-NOR gate. N-output inverter. N-input NOR gate

Transcription:

Verilog Sequential Logic Verilog for Synthesis Rev C (module 3 and 4) Jim Duckworth, WPI 1 Sequential Logic Module 3

Latches and Flip-Flops Implemented by using signals in always statements with edge-triggered clk Necessary flip-flops are inferred by the synthesis tool. Edge-triggered flip-flop Reset Asynchronous Synchronous Counters Shift Registers Finite State Machines Jim Duckworth, WPI 2 Sequential Logic - Module 3

Verilog Concurrent statements always statement Continuous assignment - assign Jim Duckworth, WPI 3 Sequential Logic Module 3

Verilog Sequential Statements reside in an always statement if statements (no endif) case statements (endcase) for, repeat while loop statements Note: use begin and end to block sequential statements Sequential statements can be used in an always statement to describe both sequential and combinational logic use non-blocking (<=) assignment for sequential logic use blocking (=) assignment for combinational logic Jim Duckworth, WPI 4 Sequential Logic Module 3

Combinational Logic - review Using always statement All input signals specified in sensitivity list All conditions evaluated (LUTs used, no-flip-flops) a b y sel Jim Duckworth, WPI 5 Sequential Logic - Module 3

Incomplete IF statement causes Latches WARNING:Xst:647 - Input <b> is never used. This port will be preserved and left unconnected if it belongs to a top-level block or it belongs to a sub-block and the hierarchy of this sub-block is preserved. WARNING:Xst:737 - Found 1-bit latch for signal <y>. Latches may be generated from incomplete case or if statements. We do not recommend the use of latches in FPGA/CPLD designs, as they may lead to timing problems. Jim Duckworth, WPI 6 Sequential Logic Module 3

Flip-flops in Verilog Always inferred using edge-triggered always statement d clk q d clk q Jim Duckworth, WPI 7 Sequential Logic Module 3

Flip-flops in Verilog (with async) Add async signals to sensitivity list Jim Duckworth, WPI 8 Sequential Logic Module 3

Counters in Verilog Just extension of D type This example has async, active-high clear (reset) Jim Duckworth, WPI 9 Sequential Logic Module 3

Counter - synthesis Elaborating module <counter>. WARNING:HDLCompiler:413 - "C:\ece3829\counter\counter.v" Line 31: Result of 5-bit expression is truncated to fit in 4-bit target. ========================================================================= * HDL Synthesis * ========================================================================= Synthesizing Unit <counter>. Related source file is "C:\ece3829\counter\counter.v". Found 4-bit register for signal <q>. Found 4-bit adder for signal <q[3]_gnd_1_o_add_0_out> created at line 31. Summary: inferred 1 Adder/Subtractor(s). inferred 4 D-type flip-flop(s). Unit <counter> synthesized. Timing Summary: (Note - before PAR) --------------- Speed Grade: -3 Minimum period: 2.048ns (Maximum Frequency: 488.317MHz) Minimum input arrival time before clock: 2.335ns Maximum output required time after clock: 3.732ns Maximum combinational path delay: No path found ========================================================================= Jim Duckworth, WPI 10 Sequential Logic Module 3

With terminal count Counters in Verilog (cont d) Jim Duckworth, WPI 11 Sequential Logic Module 3

Blocking and non-blocking assignment To ensure correct synthesis and simulation results: Combinational logic Use blocking assignment = statements in always block Sequential logic Use non blocking assignment <= statements in always block Can only be used on reg types Can only be used in an initial or always procedural blocks Can not be used in continuous assignments Jim Duckworth, WPI 12 Sequential Logic Module 3

Counter with Clock Enable (and TC) Jim Duckworth, WPI 13

Synthesis (4 flip-flops) Jim Duckworth, WPI 14

Simulation and Implementation -------------------------------------------------------------------------------------------------- Constraint Check Worst Case Best Case Timing Timing Slack Achievable Errors Score -------------------------------------------------------------------------------------------------- NET "clk_bufgp/ibufg" PERIOD = 20 ns HIGH SETUP 18.626ns 1.374ns 0 0 50% HOLD 0.444ns 0 0 MINPERIOD 18.270ns 1.730ns 0 0 -------------------------------------------------------------------------------------------------- All constraints were met. Jim Duckworth, WPI 15

Creating slower clocks Jim Duckworth, WPI 16

4-bit with Parallel Load Shift left and shift right Shift Register Jim Duckworth, WPI 17

Shift Register - Simulation Note: X denotes unknown All operations synchronous change on positive edge of clock Jim Duckworth, WPI 18

LFSR Input bit driven by XOR of some bits (feedback taps) of shift reg value Initial value called seed Eventually enters repeating cycle n-bit LSR has 2 n -1 states (0000 missing state) Sequence can appear random generate PRN Jim Duckworth, WPI 19

Example 6-bit LFSR Jim Duckworth, WPI 20

LFSR - Simulation Jim Duckworth, WPI 21

Design Review Combinational Logic (Outputs only dependent on inputs) Implemented with LUTs Can be described using Assign statement or Always Statement (Use Assign for simpler logic) Always statement rules Sensitivity list must include all inputs Only use blocking assignment = Sequential Logic (Outputs depend on inputs and past events has clock) Implemented with LUTs and Flip-Flops Will always have a clock edge Can only be described using an Always Statement Sensitivity list must only include clock edge and any async signals Only use non-blocking assignment <= All signals used in always statement will result in flip-flops Note: LHS signals in always statements must be of type reg Jim Duckworth, WPI 22 Verilog Module Rev B

State Machines A common form of sequential logic circuit relatively easy to design and analyze Clocked Synchronous State Machine clocked - storage elements (flip-flops) have clock input synchronous - flip-flops have common clock signal only changes state on clock transition (edge) Use a standard coding convention enumerated type for states Always statement (state memory and next state logic) Need to understand state encoding (optimal design) one-hot binary other Jim Duckworth, WPI 23

State Machines Block Diagram - Moore Machine Outputs determined by current state Inputs Next State Logic State Memory Output Logic Outputs Clock Reset Current State Jim Duckworth, WPI 24

State Machine (cont d) Current state determined by state memory (flip-flops) Outputs are decoded from the value of the current state combinational logic Next state is determined by current state and inputs at time of next triggering clock edge. Jim Duckworth, WPI 25

Simple State Machine Example RESET=1 SW=0 SW=1 S0 C=0 SW=1 S3 C=1 S1 C=0 SW=0 SW=0 SW=1 S2 C=0 SW=1 SW=0 Jim Duckworth, WPI 26

Timing Diagram CLK STATE S0 S1 S2 S2 S3 RESET SW C Jim Duckworth, WPI 27 6

State Machine Coding Style Jim Duckworth, WPI 28

State Memory (flip-flops) Jim Duckworth, WPI 29

Next State (combinational logic) Jim Duckworth, WPI 30

SM1 Verilog Code Jim Duckworth, WPI 31

Synthesis Report Synthesizing Unit <sm1>. Related source file is "C:\ece3829\sm1\sm1.v". s0 = 2'b00 s1 = 2'b01 s2 = 2'b10 s3 = 2'b11 Found 2-bit register for signal <current_state>. Found finite state machine <FSM_0> for signal <current_state>. ----------------------------------------------------------------------- States 4 Transitions 8 Inputs 1 Outputs 1 Clock clk (rising_edge) Reset reset (positive) Reset type asynchronous Reset State 00 Encoding auto Implementation LUT ---------------------------------------- Summary: inferred 1 Finite State Machine(s). ========================================================================= * Advanced HDL Synthesis * ========================================================================= ========================================================================= Advanced HDL Synthesis Report Macro Statistics # FSMs : 1 ========================================================================= ========================================================================= * Low Level Synthesis * ========================================================================= Analyzing FSM <MFsm> for best encoding. Optimizing FSM <FSM_0> on signal <current_state[1:2]> with gray encoding. ------------------- State Encoding ------------------- 00 00 01 01 10 11 11 10 Jim Duckworth, WPI 32

SM1 Schematic (2 flip-flops) Jim Duckworth, WPI 33

Behavioral Simulation Jim Duckworth, WPI 34

One-hot Encoding Style use one flip-flop per state only one flip-flop active (hot) best for flip-flop rich technology use more flip-flops but simpler next state logic (faster) e.g. Xilinx FPGAs (Spartan 3, Virtex, etc) Sequential (binary) encoding generates sequential values for enumerated states 00, 01, 10, 11 less flip-flops but more complex next-state logic e.g. Altera CPLDs Jim Duckworth, WPI 35

HDL Options for FSM Encoding Jim Duckworth, WPI 36

Same Verilog with One-Hot Encoding ========================================================================= * Low Level Synthesis * ========================================================================= Optimizing FSM <FSM_0> on signal <current_state[1:4]> with One-Hot encoding. ------------------- State Encoding ------------------- 00 0001 01 0010 10 0100 11 1000 ------------------- Jim Duckworth, WPI 37