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

Similar documents
Last Lecture: Divide by 3 FSM

Quick Introduction to SystemVerilog: Sequental Logic

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

!== vs.!= and === vs. ==

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Sequential Logic Design

CSE 502: Computer Architecture

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

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

Lecture 32: SystemVerilog

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

HDLs and SystemVerilog. Digital Computer Design

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

ECE 551: Digital System *

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

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

Testbenches for Sequential Circuits... also, Components

Verilog Execution Semantics

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

Modeling Sequential Circuits in Verilog

EN164: Design of Computing Systems Lecture 07: Lab Foundations / Verilog 3

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

Digital Integrated Circuits

Verilog for Synthesis Ing. Pullini Antonio

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

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

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

Digital Design with SystemVerilog

Verilog Lecture Gandhi Puvvada, USC always statements, Coding a Flip-Flop. blocking and non-blocking assignments. Copyright 2008 Gandhi Puvvada 1

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

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

Synthesizable Verilog

CSE140L: Components and Design Techniques for Digital Systems Lab

CSE140L: Components and Design

Last Lecture: Adder Examples

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

Control in Digital Systems

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

Mealy and Moore examples

(System)Verilog Tutorial Aleksandar Milenković

Topics. Midterm Finish Chapter 7

Course Details: Webpage

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

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

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

Example Best and Median Results

EEL 4783: HDL in Digital System Design

University of Technology

EN2911X: Reconfigurable Computing Lecture 06: Verilog (3)

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Building Bigger Systems: Hardware Threads

SystemVerilog HDL - a programming language

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Verilog 1 - Fundamentals

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

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

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

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

FSM and Efficient Synthesizable FSM Design using Verilog

Parallel versus serial execution

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

Digital Design with FPGAs. By Neeraj Kulkarni

VERILOG: FLIP-FLOPS AND REGISTERS

Problem Set 2 Solutions

Verilog Behavioral Modeling

A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis

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

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

Registers and finite state machines

Introduction to Verilog/System Verilog

Building Bigger Systems: Interfacing

Readings: Storage unit. Can hold an n-bit value Composed of a group of n flip-flops. Each flip-flop stores 1 bit of information.

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

Homework deadline extended to next friday

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

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

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Spiral 1 / Unit 6. Flip-flops and Registers

Verilog for High Performance

Outcomes. Spiral 1 / Unit 6. Flip Flops FLIP FLOPS AND REGISTERS. Flip flops and Registers. Outputs only change once per clock period

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

ECEN 468 Advanced Logic Design

Course Topics - Outline

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

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

L5: Simple Sequential Circuits and Verilog

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

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

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

EECS150 - Digital Design Lecture 6 - Logic Simulation

Transcription:

Last Lecture Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal always_comb t = a & b; f = t c; should use = (called blocking assignment) in comb. logic always statements. RHS just takes output from the previous equation. The order of statements matters! module 1

This Lecture Talk about clocked always statements, which generate combinational logic gates and flip-flops Unfortunately, SystemVerilog does not have welldefined semantics for describing flip-flops and finite state machines (FSMs) Instead, SystemVerilog relies on idioms to describe flip-flops and FSMs (i.e., the use of coding templates that synthesis tools will interpret to mean flip-flops and FSMs) If you do not follow these templates, your code may still simulate correctly, but may produce incorrect hardware 2

D Flip-Flop module flop(input logic clk, input logic d, output logic q); always_ff @(posedge clk) q <= d; // pronounced q gets d module Verilog calls <= a non-blocking assignment. It means wait until next clk tick before updating q This is why synthesis will produce a positive edge-trigged D-FF always_ff indicates that this is a clocked always statement Slide derived from slides by Harris & Harris from their book 3

Resettable D Flip-Flop module flopr(input logic clk, input logic reset, input logic d, output logic q); // synchronous reset always_ff @(posedge clk) if (reset) q <= 4'b0; else q <= d; module Using this template, the if part specifies the reset condition, and the else part specifies what gets stored q after next clk tick Synthesis tools will recognize this template clk d reset D R Q q Slide derived from slides by Harris & Harris from their book q 4

Resettable D Flip-Flop module flopr(input logic clk, input logic reset, input logic d, output logic q); clk d reset // asynchronous reset always_ff @(posedge clk, posedge reset) if (reset) q <= 4'b0; else q <= d; module D Q R q q By specifying the reset signal here, synthesis tools will understand the if-thenelse template matches to an asynchronously resettable D-FF Again this works because synthesis tools recognize this template. Slide derived from slides by Harris & Harris from their book 5

Resettable D Flip-Flop clk d reset _n module flopr_n(input logic clk, input logic reset, input logic d, output logic q); // asynchronous reset always_ff @(posedge clk, negedge reset_n) if (!reset_n) q <= 4'b0; else q <= d; module D Q R q q By specifying the negedge reset_n signal here, synthesis tools will asynchronously resettable D-FFs that are reset on the falling edge of reset_n The template requires the ifthen-else to use if (!reset_n) else. Slide derived from slides by Harris & Harris from their book 6

Creating logic gates + FFs module ex4(input logic clk, input logic t, c, output logic f); always_ff @(posedge clk) f <= t & c; module Positive edge triggered register (D-FF) produced for f. <= means LHS stores new value after next clk tick. 7

Clocked always statements module ex5(input logic clk, input logic a, b, c, output logic f); logic t; always_ff @(posedge clk) D-FF t <= a & b; LHS stores output of AND-gate to t register produced for f <= t & c; t and f RHS reads from t register module LHS goes into FF RHS taken from FF output 8

Clocked always statements module ex6(input logic clk, reset_n, a, b, c, output logic f); logic t; always_ff @ (posedge clk, negedge reset_n) if (!reset_n) t <= 0; f <= 0; else t <= a & b; f <= t & c; module this if part specifies how registers should be initialized RHS taken from FF output Template specifies async reset edge-triggered D-FFs Positive edge-triggered on clk Async reset negative edge on reset_n LHS goes into FF resets on neg edge of reset_n 9

Clocked always statements module ex7 (input logic clk, reset_n, op, input logic x, output logic dataout); always_ff @ (posedge clk, negedge reset_n) if (!reset_n) dataout <= 4'b0000; else if (op) dataout <= dataout + x; else dataout <= dataout - x; module this if part specifies how registers should be initialized this else part specifies how registers should be updated at each cycle. all outputs (LHS) are stored in a register in a clocked always stmt. LHS specifies new value that will be stored after next clk tick. should use <= instead of =, which means on the RHS, the value is the current value of the register. If-then-else & case stmts translated as MUXes Arithmetic operators (e.g. + ) are replaced with library logic implementations. all outputs (LHS) are stored in a register in a clocked always stmt. 10

Clocked always statements module ex8 (input logic clk, reset_n, op, input logic x, output logic dataout); logic y, z; always_ff@(posedge clk,negedge reset_n) if (!reset_n) y <= 4'b0000; else if (op) y <= y + x; else y <= y - x; always_ff@(posedge clk,negedge reset_n) if (!reset_n) dataout <= 4'b0000; z <= 4'b0000; else z <= y + 1; dataout <= dataout + z; module 1 st always stmt 2 nd always stmt writes to z reg writes to z reg reads from z reg output from clocked always stmt is output of reg. reads from z reg 11

Mixing statements module ex9 (input logic clk, reset_n, op, input logic x, output logic dataout); logic y, z; assign z = y + 1; assign dataout = z + 1; always_ff@(posedge clk, negedge reset_n) if (!reset_n) y <= 4'b0000; else if (op) always_ff statement y <= y + x; else y <= y - x; module the 2 assign statements takes most recent value of z 12

Mixing statements module ex10 (input logic clk, reset_n, op, input logic x, output logic dataout); logic y, z; same behavior as ex9, but using always_comb instead of 2 assign statements always_comb z = y + 1; dataout = z + 1; should use = in comb. logic always stmts. no reg. RHS just takes output from the previous eqn. always_ff@(posedge clk, negedge reset_n) if (!reset_n) The 2 nd always_ff statement y <= 4'b0000; else if (op) y <= y + x; else y <= y - x; module The 1 st always_comb statement takes =st recent value of z 13

Last Lecture: Divide by 3 FSM Output should be 1 every 3 clock cycles S2 S0 S1 The double circle indicates the reset state Slide derived from slides by Harris & Harris from their book 14

Finite State Machines (FSMs) A simple Moore machine looks like the following CLK inputs M next state logic k next state k state output logic N outputs Slide derived from slides by Harris & Harris from their book 15

FSM Example in SystemVerilog module divideby3fsm (input logic clk, reset_n, output logic q); enum logic [1:0] {S0=2 b00, S1=2 b01, S2=2 b10} state; // declare states as enum // next state logic and state register always_ff @(posedge clk, negedge reset_n) if (!reset_n) state <= S0; else case (state) S0: state <= S1; S1: state <= S2; S2: state <= S0; case state transition graph is the same thing as a state transition table, which can be specify as a case statement // output logic assign q = (state == S0); module output is 1 every clock cycles when we are in state S0 16