Why segregate blocking and non-blocking assignments to separate always blocks? always blocks start when triggered and scan their statements sequentially.

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Recap : Always block module and_gate (out, in1, in2); inputin1, in2; outputout; regout; or in2) begin out = in1 & in2; end endmodule zAlways.
//HDL Example 8-2 // //RTL description of design example (Fig.8-9) module Example_RTL (S,CLK,Clr,E,F,A);
CPSC 321 Computer Architecture Andreas Klappenecker
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Sequential Logic in Verilog
Synchronous Sequential Logic
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Combinational Logic.
Table 7.1 Verilog Operators.
Hardware Description Language (HDL)
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
ECE 551 Digital System Design & Synthesis Lecture 09 Synthesis of Common Verilog Constructs.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Overview Logistics Last lecture Today HW5 due today
Sequential Logic in Verilog
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
Why segregate blocking and non-blocking assignments to separate always blocks? always blocks start when triggered and scan their statements sequentially.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
M.Mohajjel. Objectives Learn How to write synthesizable Verilog code Common mistakes and how to avoid them What is synthesized for what we code Digital.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Adapted from Krste Asanovic
Figure 8.1. The general form of a sequential circuit.
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
Last Lecture Talked about combinational logic always statements. e.g.,
Reg and Wire:.
Verilog Introduction Fall
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
Part II A workshop by Dr. Junaid Ahmed Zubairi
‘if-else’ & ‘case’ Statements
HDL for Sequential Circuits
Supplement on Verilog Sequential circuit examples: FSM
Hardware Description Languages: Verilog
TODAY’S OUTLINE Procedural Assignments Verilog Coding Guidelines
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
UNIT 3: Behavioral Descriptions
SYNTHESIS OF SEQUENTIAL LOGIC
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
ESE 437: Sensors and Instrumentation
332:437 Lecture 8 Verilog and Finite State Machines
Chapter 4: Behavioral Modeling
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Lecture 4: Continuation of SystemVerilog
ECE 551: Digital System Design & Synthesis
332:437 Lecture 8 Verilog and Finite State Machines
Introduction to Digital IC Design
Introduction to Verilog – Part-2 Procedural Statements
Why segregate blocking and non-blocking assignments to separate always blocks? always blocks start when triggered and scan their statements sequentially.
Presentation transcript:

Why segregate blocking and non-blocking assignments to separate always blocks? always blocks start when triggered and scan their statements sequentially Blocking assignment: = (completes assignment before next statement executes) Non-blocking: <= (all such statements complete at once at end of the always block)

A mixed always block for a funny shifter module funnyshifter (input data, clk, output reg [3:0] yout); reg [3:0] asig; initial asig = 4'b0000; always @ (posedge clk) begin asig[1] = asig[0]; // Value of asig(0) on entry written to asig(1) at // end of loop - D-ff asig[2] = asig[1]; // Value of asig(1) as step written is already // updated so asig(2) = asig(0) at end of loop asig[3] = asig[2]; // Value of asig(2) as step written is already // updated so asig(3) = asig(0) at end of loop asig[0] = data; // asig(0) = data at end of loop - D-ff yout[3:1] <= asig[3:1]; // non-blocking unambiguous D-ff's yout[0] <= data; end endmodule

Designer’s Probable Intention – Block Diagram

Simulation results for different order of statements Result with first statement order: asig[3:1] are redundant Swap first and third lines and there is a double shift register

What You Actually Get – Block Diagram

Same mixed always block but different statement order - designer’s probable intention module funnyshifter (input data, clk, output reg [3:0] yout); reg [3:0] asig; initial asig = 4'b0000; always @ (posedge clk) begin asig[3] = asig[2]; // Value of asig(2) on entry written to asig(3) at // end of loop - D-ff asig[2] = asig[1]; // Value of asig(1) on entry written to asig(2) at // end of loop - D-ff asig[1] = asig[0]; // Value of asig(0) on entry written to asig(1) at // end of loop - D-ff asig[0] = data; // asig(0) = data at end of loop - D-ff yout[3:1] <= asig[3:1]; // non-blocking unambiguous D-ff's yout[0] <= data; end endmodule

The right way to do it: module funnyshifter (input data, clk, output reg [3:0] yout); reg [3:0] asig; initial asig = 4'b0000; // Note: this line initializes only the simulator // and has no effect on hardware. I needed it to generate the // simulator output by starting in a known state. always @ (posedge clk) begin asig <= {asig[2:0], data}; // non-blocking unambiguous D-ff's yout[3:1] <= asig[3:1]; yout[0] <= data; end endmodule

Suggested Rules and Styles “Avoid writing modules that… mix the creation of state… in an always @ posedge block with the definition of the next-state function. .. (This) sidesteps a tremendous amount of confusion and frustration that result from incorrect use of blocking = versus non-blocking <= assignment.” Dally and Harting, Digital Design a Systems Approach, pp. 593-594 “Two rules are so important this is the only place that you’ll find bold font in this book. Always use blocking assignments (=) in always blocks intended to create combinational logic. Always use non-blocking assignments (<=) in always blocks intended to create registers. Do not mix blocking and non-blocking logic in the same always block.” John F. Wakerly, Digital Design Principles and Practices, pg. 316.

A Strong Style Preference: Rule: in any always block, you must not leave ambiguity – all possible input conditions should have fully specified output conditions Common logic expression formats include: always @ (*) begin if (adv = 1’b1) next = 0; // will get latch or permanent 0; end always @ (*) begin // PREFERRED STYLE case() // USE case() for multiple choices 1’b1: next = 0; 1’b0: next = 1; // Preferable to include all cases default: next = 1; // ALWAYS supply a default. endcase assign next = adv ? 0 : 1; // Satisfactory for single bit usage inside or outside always block