Verilog Execution Semantics

Similar documents
Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

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

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

Verilog for High Performance

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

Digital Design with SystemVerilog

Programming with HDLs

Digital Integrated Circuits

Nonblocking Assignments in Verilog Synthesis, Coding Styles That Kill!

Quick Introduction to SystemVerilog: Sequental Logic

TOPIC : Verilog Synthesis examples. Module 4.3 : Verilog synthesis

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

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

L5: Simple Sequential Circuits and Verilog

L5: Simple Sequential Circuits and Verilog

L5: Simple Sequential Circuits and Verilog

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

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Spiral 1 / Unit 6. Flip-flops and Registers

L5: Simple Sequential Circuits and Verilog

Department of Computer Science and Electrical Engineering. CMPE 415 Synthesis. Prof. Ryan Robucci

Synthesizable Verilog

Lecture 11 Logic Synthesis, Part 2

Modeling Sequential Circuits in Verilog

Sequential Circuit Design: Principle

VHDL for Synthesis. Course Description. Course Duration. Goals

EEL 4783: HDL in Digital System Design

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

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>

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

Topics. Midterm Finish Chapter 7

Synthesis of Combinational and Sequential Circuits with Verilog

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

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

VHDL: RTL Synthesis Basics. 1 of 59

Overview. Implementing Gigabit Routers with NetFPGA. Basic Architectural Components of an IP Router. Per-packet processing in an IP Router

Modeling Synchronous Logic Circuits. Debdeep Mukhopadhyay IIT Madras

Lecture 32: SystemVerilog

Verilog for Synthesis Ing. Pullini Antonio

HDLs and SystemVerilog. Digital Computer Design

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

EEL 4783: HDL in Digital System Design

Sequential Circuit Design: Principle

Speaker: Kayting Adviser: Prof. An-Yeu Wu Date: 2009/11/23

Lecture 12 VHDL Synthesis

ECE 551: Digital System *

CS232 VHDL Lecture. Types

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

Digital System Design with SystemVerilog

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

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

A Tutorial Introduction 1

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

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

Course Details: Webpage

CSE140L: Components and Design Techniques for Digital Systems Lab

CSE140L: Components and Design

Writing Circuit Descriptions 8

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

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

The Verilog Hardware Description Language

HDL Design Cube. Synthesis and VHDL

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

[VARIABLE declaration] BEGIN. sequential statements

Last Lecture: Divide by 3 FSM

Homework deadline extended to next friday

A Brief Introduction to Verilog Hardware Definition Language (HDL)

University of Technology

Digital Design with FPGAs. By Neeraj Kulkarni

Digital Design Using Verilog EE Final Examination

ECEN 468 Advanced Logic Design

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

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

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Digital Circuits and Systems

Behavioral Modeling and Timing Constraints

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

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

HW1 Modeling Concepts

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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Schematic design. Gate level design. 0 EDA (Electronic Design Assistance) 0 Classical design. 0 Computer based language

Verilog introduction. Embedded and Ambient Systems Lab

VERILOG: FLIP-FLOPS AND REGISTERS

קורס VHDL for High Performance. VHDL

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

VERILOG HDL. (and C) 1 ENGN3213: Digital Systems and Microprocessors L#5-6

Behavioral Modeling and Timing Constraints

Topics. Midterm Finish Chapter 7

Verilog Hardware Description Language ROOM: B405

SystemC Synthesis Standard: Which Topics for Next Round? Frederic Doucet Qualcomm Atheros, Inc

Sunburst Design - Comprehensive SystemVerilog Design & Synthesis by Recognized Verilog & SystemVerilog Guru, Cliff Cummings of Sunburst Design, Inc.

Lecture 15: System Modeling and Verilog

EE 4755 Digital Design Using Hardware Description Languages

Transcription:

System Verilog (SV) is a parallel, hardware description language. SV differs from procedural languages such as C in that it models concurrency in digital logic. Logic gates operate in parallel, but software programs execute serially, one statement at a time. System Verilog looks/feels a lot like C...but behaves very differently! emember, when writing SV code, you are describing hardware structures, not creating a binary executable.

System Verilog allows us to do two things with the same piece of code: Infer the physical structure of the logic to be created. Simulate the behavior of the logic prior to building it. We must write code to simultaneously satisfy two tools. In order of importance... Logic synthesizer - Our code must clearly infer the structure (including errors!) we want from logic synthesis. Logic simulator - Our code, when simulated, must exhibit the exact behavior of the synthesized gates that are yet to be built. Much of the power of HLs comes from the ability to quickly simulate a design with the confidence that it represents the behavior of the gates that will be built. A simulation of an TL-level design will run several orders of magnitude faster than a synthesis-generated netlist of the structural gate-level design. (A min versus 2 hour simulation)

on t keep hacking code till the simulator is happy... Its working gates you want! Well structured TL code written with an eye towards logic synthesis almost always simulates correctly. The synthesizer is way pickier than the simulator. This is a big reason for our structure first approach. We write HL code that expresses structure while making sure the simulator understands what structure we are creating. Writing SV code that creates correct behavior in the simulator is easy but is often incomprehensible to the synthesizer as the synthesizible subset of SV is far smaller than that understood by the simulator.

System Verilog models concurrency with two basic constructs: Continuous assignment rocedural Blocks Continuous assignment statements execute when a variable on the HS changes. When the change occurs, the LHS is updated immediately. This behavior is just like a logic gate. An example of a continuous assignment and the gate it synthesizes to is shown below. assign d = a + b - c; // d gets updated whenever a, b or c change

A procedural block is made up of procedural statements which are executed sequentially just like any C program whenever the block is awakened for execution. rocedural blocks are awakened when a signal in the sensitivity list changes. Two procedural blocks describing some combinatorial logic are shown below. // combo logic - V95 style, explicit sensitivity list always @ (a, b, c, d) begin out_ = a + b; out_ = c + d; // combo logic - SV style, implied sensitivity list always_comb begin out_ = a + b; out_ = c + d;

To describe both clocked (sequential) and combinatorial logic, and to avoid problems with non-determinism, Verilog uses two different assignment operators within procedural blocks. Blocking assignments, = evaluate the HS and update the LHS immediately before any further instructions are executed. Non-Blocking assignments, <= evaluate the HS and postpone updating LHS until the of present simulation timestep.

Verilog Execution Semantics Blocking and Non-Blocking Assignment In always comb blocks we describe purely combinatorial logic. To describe combinatorial logic, use the blocking assignment: = always_comb Non blocking example begin x = a & b; y = x c; always_comb begin x <= a & b; y <= x c; Which piece of code correctly models the logic below? a b U U2 x c y TITLE FILE: EVISION: AGE OF AWN BY:

Verilog Execution y Semantics rst always_comb begin x = a & b; y = x c; "B" then "A" execution a b c U U2 x y TITLE FILE: AGE Blocking Behavior a b c x y initial condition a changes x = a & b; y = x c; Correct behavior of the combinatorial gates is observed.

Verilog Execution rst Semantics always_comb begin x <= a & b; y <= x c; "B" then "A" execution a b c U U2 x y TITLE FILE: AGE Non-Blocking Behavior a b c x y eferred assignments initial condition a changes x <= a & b; x <= y <= x c; x <=, y <= assignment completion x <=, y <= Non-blocking assignments do not embody the behavior of the gate structure desired. Incorrect behavior is the result. Synthesis results are identical! Use blocking assignments for combinatorial logic.

cution cution In always ff blocks we describe clocked logic such as flip-flops using the nonblocking assignment <=. Think about how the following circuit operates after reset has deasserted. Its a serial shift register. Blocking example in reset q The behavior we wish to describe is that at each clock edge, q, q2 and out simultaneously take on the values of in, q and q2 respectively. How would the operation differ using blocking and nonblocking assignments? q2 out

always_ff @ ( posedge, posedge reset ) if( reset ) begin q <= ; q2 <= ; out <= ; else begin q <= in; q2 <= q; out <= q2; always_ff @ ( posedge, posedge reset ) if( reset ) begin q = ; q2 = ; out = ; else begin q = in; q2 = q; out = q2; Non-blocking assignments defer all assignments to the of the simulation cycle. This is how real flip-flops would act in this circuit. Blocking assignments ripple the value of in all the way to out by completing each assignment in order. At the of the simulation cycle, out holds the value of in, essentially removing the 2nd and 3rd flip-flops. Use nonblocking assignments for clocked logic.

Since SV is a parallel language, and models concurrent execution, it is logical to ask what the order of execution is outside procedural statements. In Verilog, when multiple procedural blocks or continuous assignments are triggered to run, the order in which they are evaluated is not specified and is therefore non-deterministic. For example, these two procedural blocks may be executed in any order, with different results for the variable z. always @ (a) z = b ^ c; always @ (a) z = b ^ d; Hardware-wise, this is a nonsensical case. Two XO gates would be needed to compute the results and their outputs could never be connected together without creating a buffer-fight.

Since always blocks can execute in any order, blocking assignments can cause trouble. module fbosc ( output logic y, ; input, rst ); //" A" procedural block always_ff ( posedge, posedge rst ) if ( rst ) y = ; // reset else y = ; rst y "A" then "B" execution //" B" procedural block always_ff ( posedge, posedge rst ) if ( rst ) = ; // preset else = y; y module rst "B" then "A" execution y

Using nonblocking assignments, we can live with non-deterministic rst scheduling. "B" then "A" execution y module fbosc ( output logic y, ; input, rst ); //" A" procedural block always_ff ( posedge, posedge rst ) if ( rst ) y <= ; // reset else y <= ; rst y "A" then "B" execution //" B" procedural block always_ff ( posedge, posedge rst ) if ( rst ) <= ; // preset else <= y; y module rst "B" then "A" execution a b

Understanding all the nuances of the blocking and nonblocking assignment is beyond the scope of our class. However, adherence to the following guidelines will keep your simulator and synthesis tools in sync.. When modeling sequential logic, use always ff and <=. 2. When modeling latches, use always latch and <=. 3. When modeling combinatorial logic use always comb and =. 4. When modeling both sequential and combinatorial logic within the same always block (like a counter), use always ff and <=. 5. on t mix = and <= assignments in the same always block. 6. on t make assignments to the same variable from more than one always block or continuous assignment.