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

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
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)
ECE 551 Digital System Design & Synthesis Lecture 06 Loops Non-synthesizable Constructs File I/O.
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.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
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.
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
D Flip-Flops in Verilog Discussion 10.3 Example 27.
Quad 2-to-1 Multiplexer Discussion D7.4 Example 7.
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.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
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 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
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.
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
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.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Overview Logistics Last lecture Today HW5 due today
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Adapted from Krste Asanovic
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.
‘if-else’ & ‘case’ Statements
Behavioral Modeling Structural modeling Behavioral modeling
Supplement on Verilog Sequential circuit examples: FSM
TODAY’S OUTLINE Procedural Assignments Verilog Coding Guidelines
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Why segregate blocking and non-blocking assignments to separate always blocks? always blocks start when triggered and scan their statements sequentially.
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
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
The Verilog Hardware Description Language
Lecture 4: Continuation of SystemVerilog
332:437 Lecture 9 Verilog Example
332:437 Lecture 9 Verilog Example
332:437 Lecture 8 Verilog and Finite State Machines
Introduction to Digital IC Design
Introduction to Verilog – Part-2 Procedural Statements
COE 202 Introduction to Verilog
332:437 Lecture 9 Verilog Example
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.