ECE 551 Digital System Design & Synthesis Lecture 09 Synthesis of Common Verilog Constructs.

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.
ECE 551 Digital Design And Synthesis
Synchronous Sequential Logic
Combinational Logic.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Table 7.1 Verilog Operators.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
ECE 551 Digital System Design & Synthesis Lecture 08 The Synthesis Process Constraints and Design Rules High-Level Synthesis Options.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 8: Sequential Design Spring 2009 W. Rhett.
Slide 1 7. Verilog: Combinational always statements. VHDL: Combinational Processes: To avoid (I.E. DO NOT What in your HDL code?) Cases that generate Synthesis.
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2006 Class Web Site:
Useful Things to Know Norm. Administrative Midterm Grading Finished –Stats on course homepage –Pickup after this lab lec. –Regrade requests within 1wk.
Digital System Design by Verilog University of Maryland ENEE408C.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
ELEN 468 Advanced Logic Design
Digital System Design Verilog ® HDL Behavioral Modeling (1) Maziar Goudarzi.
Overview Logistics Last lecture Today HW5 due today
ECE 551 Digital System Design & Synthesis Lecture 11 Verilog Design for Synthesis.
Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example,
Sequential Logic in Verilog
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
ECE 551 Digital Design And Synthesis
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example, Modeling Flip-Flops Spring.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Verilog for Synthesis Ing. Pullini Antonio
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.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
ELEN 468 Lecture 131 ELEN 468 Advanced Logic Design Lecture 13 Synthesis of Combinational Logic II.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
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.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
03/31/031 ECE 551: Digital System Design & Synthesis Lecture Set 8 8.1: Miscellaneous Synthesis (In separate file) 8.2: Sequential Synthesis.
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 9: State Machines & Reset Behavior Spring.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Overview Logistics Last lecture Today HW5 due today
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
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.,
ELEN 468 Advanced Logic Design
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
‘if-else’ & ‘case’ Statements
SYNTHESIS OF SEQUENTIAL LOGIC
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
332:437 Lecture 8 Verilog and Finite State Machines
Chapter 4: Behavioral Modeling
The Verilog Hardware Description Language
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
ECE 551: Digital System Design & Synthesis
332:437 Lecture 8 Verilog and Finite State Machines
Introduction to Verilog – Part-2 Procedural Statements
Lecture 7: Verilog Part II
Presentation transcript:

ECE 551 Digital System Design & Synthesis Lecture 09 Synthesis of Common Verilog Constructs

Overview  Don’t Cares and z’s in synthesis  Unintentional latch synthesis  Synthesis & Flip-Flops  Gating the clock… and alternatives  Loops in synthesis 2

Synthesis Of x And z  Only allowable uses of x is as “don’t care”, since x cannot actually exist in hardware  in casex  in casez  in defaults of conditionals such as if, case, ?  Only allowable uses of z:  As a “don’t care”  Constructs implying a 3-state output 3

Don’t Cares  x assigned as a default in a conditional, case, or casex.  x, ?, or z within case item expression in casex  Does not actually output “don’t cares”!  Values for which input comparison to be ignored  Lets synthesizer choose between 0 or 1  Choose whichever helps meet design goals  z, ? within case item expression in casez  Same conditions as listed above except does not apply to x 4

Don’t Cares Example [1]  Give synthesizer flexibility in optimization 5 case (state) 3’b000: out = 1’b0; 3’b001:out = 1’b1; 3’b010:out = 1’b1; 3’b011: out = 1’b0; 3’b100: out = 1’b1; // below states not used 3’b101:out = 1’b0; 3’b110:out = 1’b0; 3’b111: out = 1’b0; endcase case (state) 3’b000: out = 1’b0; 3’b001:out = 1’b1; 3’b010:out = 1’b1; 3’b011: out = 1’b0; 3’b100: out = 1’b1; default: out = 1’bx; endcase VS

Don’t Cares Example [2] 6  Synthesis results for JUST output calculation: VS Area = Area = 15.24

Don’t Cares Example [3]  casex can reduce number of conditions specified and may aid synthesis 7 casex (state) 3’b000: out = 1’b1; 3’b001:out = 1’b1; 3’b010:out = 1’b1; 3’b011: out = 1’b1; 3’b100: out = 1’b0; 3’b101:out = 1’b0; 3’b110:out = 1’b1; 3’b111: out = 1’b1; endcase casex (state) 3’b0??: out = 1’b1; 3’b10?:out = 1’b0; 3’b11?:out = 1’b1; endcase VS

Synthesis Of z  Example 1: (Simple Tri-State Bus) assign bus_line = (en) ? data_out : 32’bz;  Example 2 (Bidirectional Bus) // bus_line receives from data when en is 0 assign bus_line = (!en) data : 32’bz; // bus_line sends to data when enable is 1 assign data = (en) ? bus_line : 32’bz; 8

Combinational Logic Hazards  Avoid structural feedback in continuous assignments, combinational always assign z = a | y; assign y = b | z;// feedback on y and z signals!  Avoid incomplete sensitivity lists in combinational always always (*) // helps to avoid latches  For conditional assignments, either:  Set default values before statement  Make sure LHS has value in every branch/condition  For warning, set hdlin_check_no_latch true before compiling 9

Synthesis Example [1] 10 module latch2(input a, b, c, d, output reg out); b, c, d) begin if (a) out = c | d; else if (b) out = c & d; end endmodule Area = 44.02

Synthesis Example [2] 11 module no_latch2(input a, b, c, d, output reg out); b, c, d) begin if (a) out = c | d; else if (b) out = c & d; else out = 1’b0; end endmodule Area = 16.08

Synthesis Example [3] 12 module no_latch2_dontcare(input a, b, c, d, output reg out); b, c, d) begin if (a) out = c | d; else if (b) out = c & d; else out = 1’bx; end endmodule When can this be done? Area = 12.99

Registered Combinational Logic  Combinational logic followed by a register clk) y <= (a & b) | (c & d); clk) case (select) 3’d0: y <= a; 3’d1: y <= b; 3’d2: y <= c; 3’d3: y <= d; default y <= 8’bx; endcase  The above behaviors synthesize to combinational logic followed by D flip-flops.  Combinational inputs (e.g., a, b, c, and d) should not be included in the sensitivity list 13

Flip-Flop Synthesis 14  Each variable assigned in an edge-controlled always block implies a flip-flop.

Gated Clocks  Use only if necessary (e.g., for low-power)  Clock gating is for experts! module gated_dff(clk, en, data, q); inputclk, en, data; outputreg q; wiremy_clk = clock & en; my_clk) q <= data; endmodule  When clock_en is zero flip-flop won’t update.  What problems might this cause? 15

Alternative to Gated Clocks module enable_dff(clk, en, data, q); input clk, en, data; output reg q; clock) if (en) q <= data; endmodule  Flip-flop output can only change when en is asserted  How might this be implemented? 16

Clock Generators  Useful when you need to gate large chunks of your circuit.  Adding individual enable signals adds up module clock_gen(pre_clk, clk_en, post_clk); inputpre_clk, clk_en; outputpost_clk; assign post_clk = clk_en & pre_clk; endmodule  Key: If you do this, you cannot use pre_clk on any flip-flops! Exclusively use post_clk.  This is still mostly recommended only for experts. 17

Loops  A loop is static (data-independent) if the number of iterations is fixed at compile-time  Loop Types  Static without internal timing control  Combinational logic  Static with internal timing control  Sequential logic  Non-static without internal timing control  Not synthesizable  Non-static with internal timing control  Sometimes synthesizable, Sequential logic 18

Static Loops w/o Internal Timing  Combinational logic results from “loop unrolling”  Example begin andval[0] = 1; for (i = 0; i < 4; i = i + 1) andval[i + 1] = andval[i] & a[i]; end  What would this look like?  How can we register the outputs? 19

Static Loops with Internal Timing  If a static loop contains an internal edge-sensitive event control expression, then activity distributed over multiple cycles of the clock always begin for (i = 0; i < 4; i = i + clk) sum <= sum + i; end  What does this loop do?  This might synthesize, but why take your chances? 20

Non-Static Loops w/o Internal Timing  Number of iterations is variable  Not known at compile time  Can be simulated, but not synthesized!  Essentially an iterative combinational circuit of data dependent size! n) begin andval[0] = 1; for (i = 0; i < n; i = i +1) andval[i + 1] = andval[i] & a[i]; end  What if n is a parameter? 21

Non-Static Loops with Internal Timing  Number of iterations determined by  Variable modified within the loop  Variable that can’t be determined at compile time  Due to internal timing control—  Distributed over multiple cycles  Number of cycles determined by variable above  Variable must still be bounded always begin continue = 1’b1; for (; continue; ) clk) sum = sum + in; if (sum > 8’d42) continue = 1’b0; end 22 Timing controls inside the always block make design guidelines fuzzy… Confusing, and best to avoid.

Unnecessary Calculations  Expressions that are fixed in a for loop are replicated due to “loop unrolling.”  Solution: Move fixed (unchanging) expressions outside of all loops. for (x = 0; x < 5; x = x + 1) begin for (y = 0; y < 9; y = y + 1) begin index = x*9 + y; value = (a + b)*c; mem[index] = value; end  Which expressions should be moved? 23

Unnecessary Calculations  Expressions that are fixed in a for loop are replicated due to “loop unrolling.”  Solution: Move fixed (unchanging) expressions outside of all loops. value = (a + b)*c; for (x = 0; x < 5; x = x + 1) begin index = x*9; for (y = 0; y < 9; y = y + 1) begin mem[index+y] = value; end Not so different from Loop optimization in software. 24

FSM Replacement for Non-Static Loops  Not all loop structures supported by vendors  Can always implement a loop with internal timing using an FSM  Can make a “while” loop easily by rewriting as FSM  Often use counters along with the FSM  All (good) synthesizers support FSMs!  Synopsys supports for-loops with a static number of iterations  Don’t bother with “fancy” loops outside of testbenches 25

Review Questions  Draw the Karnaugh-map for each statement, assuming each variable is one bit. if (c) z = a | b; else z = 0; if (c) z = a | b; else z = 1`x; Give a simplified Boolean expression for each statement  What would you expect to get from the following expressions? if (c) z = a & b; 26

Review Questions  Rewrite the following code, so that it takes two clock cycles and can use only a single multiplier and adder to compute z. Draw potential hardware for each piece of code. reg [15:0] z; reg [7:0] a, b, c, d clock) z = a*b + c*d; 27

Review Questions  What hardware would you expect from the following code? module what(input clk, input [7:0] b, output [7:0] c); reg [7:0] a[0:3]; integer i; clk) begin a[0] <= b; for (i = 1; i < 4; i=i+1) a[i] <= a[i-1] + b; end assign c = a[3]; endmodule 28