102-1 Under-Graduate Project: RTL Coding Style

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Combinational Logic.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
ECE 551 Digital System Design & Synthesis Lecture 08 The Synthesis Process Constraints and Design Rules High-Level Synthesis Options.
Logic Synthesis – 3 Optimization Ahmed Hemani Sources: Synopsys Documentation.
Kazi Spring 2008CSCI 6601 CSCI-660 Introduction to VLSI Design Khurram Kazi.
NLint 操作教學
Digital System Design by Verilog University of Maryland ENEE408C.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
Overview Logistics Last lecture Today HW5 due today
ECE 2372 Modern Digital System Design
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Logic Synthesis assign z=a&b a b z What is Synthesis synthesis /sinth siss/ noun ( pl. syntheses /sinth seez/) 1 the combination of components to form.
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 9 - Coding Guidelines.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project: RTL Coding Style Speaker: 蔡朝陽 Date: 2010/10/26.
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Under-Graduate Project: RTL Coding Style Speaker: MingChun-Hsiao Date: 2012/11/27.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
Logic Synthesis assign z=a&b a b z What is Synthesis synthesis /sinth siss/ noun ( pl. syntheses /sinth seez/) 1 the combination of components to form.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Slide 1 2. Verilog Elements. Slide 2 Why (V)HDL? (VHDL, Verilog etc.), Karen Parnell, Nick Mehta, “Programmable Logic Design Quick Start Handbook”, Xilinx.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Finite State Machine (FSM) Nattha Jindapetch December 2008.
Introduction to ASIC flow and Verilog HDL
03/31/031 ECE 551: Digital System Design & Synthesis Lecture Set 8 8.1: Miscellaneous Synthesis (In separate file) 8.2: Sequential Synthesis.
Logic Synthesis assign z=a&b a b z What is Synthesis synthesis /sinth siss/ noun ( pl. syntheses /sinth seez/) 1 the combination of components to form.
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
03/30/031 ECE Digital System Design & Synthesis Lecture Design Partitioning for Synthesis Strategies  Partition for design reuse  Keep related.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Verilog Tutorial Fall
Adapted from Krste Asanovic
Figure 8.1. The general form of a sequential circuit.
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
Topics Modeling with hardware description languages (HDLs).
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Digital System Verification
‘if-else’ & ‘case’ Statements
Verilog Coding Guideline
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Topics Modeling with hardware description languages (HDLs).
Topics HDL coding for synthesis. Verilog. VHDL..
ECE 551: Digital System Design & Synthesis
SYNTHESIS OF SEQUENTIAL LOGIC
ECE-C662 Introduction to Behavioral Synthesis Knapp Text Ch
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
CaseZ In Verilog there is a casez statement, a variation of the case statement that permits "z" and "?“ values to be treated during case-comparison as.
332:437 Lecture 8 Verilog and Finite State Machines
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
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
332:437 Lecture 8 Verilog and Finite State Machines
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

102-1 Under-Graduate Project: RTL Coding Style Speaker:黃乃珊 Adviser: Prof. An-Yeu Wu Date: 2013/12/12

Outline Principles of RTL Coding Styles Debugging Tool: nLint Readability Finite state machine (FSM) Coding for synthesis Partitioning for synthesis Debugging Tool: nLint

Pre-RTL Preparation Checklist Communicate design issues with your teammates Naming conventions, directory trees and other design organizations Have a specification for your design Everyone should have a specification BEFORE they start coding Design partition Follow the specification’s recommendations for partition Break the design into major functional blocks 1. Discuss with teammates 2. Maybe timing constraint, throughput, I/O Design partition: divide and conquer

RTL Coding Style Start Cmpt End haha55 yaya66 Sum_2 Multiply_0 Create a block level drawing of your design before you begin coding. Draw a block diagram of the functions and sub-functions of your design. Hierarchy design Always think of the poor guy who has to read your RTL code. Easy to understand. Meaningful names. Comments and headers.

Outline Principles of RTL Coding Styles Debugging Tool: nLint Readability Finite state machine (FSM) Coding for synthesis Partitioning for synthesis Debugging Tool: nLint Coding for readability Focusing on lexical conventions and basic RTL constructs Coding for portability create code that is technology-independent, compatible with various simulation tools Guidelines for clocks and resets … Coding for synthesis achieve the best compile times and synthesis results, including: testability, performance, simplification of static timing analysis, gate-level circuit behavior that matches that of the original RTL code Partitioning for Synthesis Better synthesis results Faster compile runtimes Ability to use simpler synthesis strategies to meet timing

File Headers Include informational header at the top of every source file, including scripts. Filename Author information, e.g. name, email… Description of function and list of key features of the module Available parameters Reset scheme and clock domain Date the file was created and modified Critical timing and asynchronous interface A corporation-wide standard template

File Header Example: DCT.v

Identifiers Naming Rule Begin with an alpha character (a-z, A-Z) or an underscore (_) and can contain alphanumeric, dollar signs ($) and underscore. Examples of illegal identifiers: 34net a*b_net n@238 Up to 1023 characters long Case sensitive e.g. sel and SEL are different identifiers

General Naming Conventions(1/3) Lowercase letters for all signals, variables, and port names. reg is used in procedural block Uppercase letters for constants and user-defined types. e.g. `define MEM_WIDTH 16 Verilog is case sensitive Meaningful names Use ram_addr for RAM address bus instead of ra Develop, document, and use a naming convention consistently throughout a design.

General Naming Conventions(2/3) Use clk for the clock signal If more than one clock, use clk as the prefix for all clock signals (clk1, clk2, clk_interface) For active low signals, use *_n If the reset signal is active low, use rst_n Similarly, for active high signals, use *_p For input of a register, use *_w For output of a register, use *_r For input signals, use *_i For output signals, use *_o

Example Reg1 Com. Logic Reg2 Top For connection Logic data_i reg1_w assign reg1_w = data_i; assign reg2_w = com1_o; assign com1_i = reg1_r; always @ (posedge clk_p) begin reg1_r <= reg1_w; reg2_r <= reg2_w; end always @(*) begin com1_o = com1_i + 4’d5; data_i reg1_w reg1_r com1_i com1_o data_o Reg1 Com. Logic reg2_w reg2_r Reg2 Top For connection Logic

General Naming Conventions(3/3) Use [x:0] (instead of [0:x]) when describing multi-bit buses A somewhat arbitrary suggested “standard” Use parameter to improve readability module car (out, in1, in2); ………… parameter S0_STOP = 2’d0, S1_RUN = 2’d1; case (state) S0_STOP: ….. Don’t use HDL reserved words e.g. xor, nand , module Use a consistent ordering helps improve the readability of the code and reduce s the chance of accidentally swapping order between connected buses

Use comments Use comments appropriately to explain Brief, concise, explanatory Avoid “comment clutter”– obvious functionality does not need to be commented Single-line comments begin with // Multiple-line comments start with /* and end with */ Use indentation to improve the readability of continued code lines and nested loops e.g.

Module Instantiation Always use explicit mapping for ports, use named mapping rather than positional mapping module_a ( clk, s1_i, s1_o, s2_i, s2_o );

Use loops and arrays Using loop to increase readability Loop is usually used as memory initialization for example:

Outline Principles of RTL Coding Styles Debugging Tool: nLint Readability Finite state machine (FSM) Coding for synthesis Partitioning for synthesis Debugging Tool: nLint Coding for readability Focusing on lexical conventions and basic RTL constructs Coding for portability create code that is technology-independent, compatible with various simulation tools Guidelines for clocks and resets … Coding for synthesis achieve the best compile times and synthesis results, including: testability, performance, simplification of static timing analysis, gate-level circuit behavior that matches that of the original RTL code Partitioning for Synthesis Better synthesis results Faster compile runtimes Ability to use simpler synthesis strategies to meet timing

Finite State Machines FSM have widespread application in digital systems. Most frequently used in controller Mealy Machine: The next state and the outputs depend on the present state and the inputs. Moore Machine: The next state depends on the present state and the inputs, but the output depends on only the present state. output = f (In, CS) output = f (CS)

Modeling FSM in Verilog Sequential Circuits Memory elements of States (S) Combinational Circuits Next-state Logic (NL) Output Logic (OL) Three coding styles (1) Separate S, OL and NL (2) Combines NL+ OL, separate S (3) Combine S + NL, separate OL 􀃎 Not recommended!! Mix the comb. and seq. circuits

Style (1) Separate S, NL, OL

Style (2) Combine NL+OL; Separate S

Outline Principles of RTL Coding Styles Debugging Tool: nLint Readability Finite state machine (FSM) Coding for synthesis Partitioning for synthesis Debugging Tool: nLint Coding for readability Focusing on lexical conventions and basic RTL constructs Coding for portability create code that is technology-independent, compatible with various simulation tools Guidelines for clocks and resets … Coding for synthesis achieve the best compile times and synthesis results, including: testability, performance, simplification of static timing analysis, gate-level circuit behavior that matches that of the original RTL code Partitioning for Synthesis Better synthesis results Faster compile runtimes Ability to use simpler synthesis strategies to meet timing

Reset Signal Use the reset signal to initialize registered signals dct_r <= 1’b0; dct_r <= dct_w; Do not use an initial statement to initialize the signal

Avoid Latches (1/2) Avoid using any latches in your design Use a design checking tool (nLint) to check for latches in your design Poor Coding Styles Latch inferred because of missing else condition Latches inferred because of missing assignments and missing condition As an exception, you can instantiate technology-independent GTECH D latches. However, all latches must be instantiated and you must provide documentation that lists each latch and describes any special timing requirements that result from the latch. Register files, memories, FIFOs, and other storage elements are examples of situations in which D latches are permitted.

Avoid Latches (2/2) Avoid inferred latches Fully assign outputs for all input conditions

Avoid Combinational Feedback Combinational feedback cause making accurate static timing analysis very hard.

Sensitivity List (1/3) For combinational blocks, the sensitivity list must include every signal that is read by the process. Signals that appear on the right side of an assign statement Signals that appear in a conditional expression For simplicity, Verilog 2001 supports always @ (*)

Sensitivity List (2/3) Include a complete sensitivity list in each of always blocks If not, the behavior of the pre-synthesis design may differ from that of the post-synthesis netlist.

Sensitivity List (3/3) For sequential blocks The sensitive list must include the clock signal. If an asynchronous reset signal is used, include reset in the sensitivity list. Use only necessary signals in the sensitivity lists Unnecessary signals in the sensitivity list slow down simulation

Combinational vs. Sequential Blocks Combinational logic Use blocking (=) assignments Execute in sequential order Sequential logic Use nonblocking (<=) assignments Execute concurrently Do not make assignments to the same variable from more than one always block. Multiple Assignment + A B C sum_1 sum_2 always@(*) begin sum_1 = A + B; sum_2 = sum_1 + C; end m1_w m1_r clk always@(posedge clk) begin m1_r <= m1_w; m2_r <= m2_w; end m2_w m2_r clk

case Statement Fully specified verilog case statements result in a single-level multiplexer Partially specified Verilog case statements result in latches case (sel) 2’b00: outc = a; 2’b01: outc = b; 2’b10: outc = c; default: outc = d; endcase;

if-then-else Statement An if-then-else statement infers a priority-encoded, cascaded combination of multiplexers. if (sel == 2’b00) outi = a; else if (sel = 2’b01) outi = b; else if (sel = 2’b10) outi = c; else outi = d;

case vs. if-then-else Statements case statements are preferred if the priority-encoding structure is not required The multiplexer is faster. if-then-else statement can be useful if you have a late-arriving signal Connect the signal to a in last slide A conditional assignment may also be used to infer a multiplexer. assign z = (sel_a) ? a : b; In a cycle-based simulator, the case statement simulates faster than the if-then-else statement. For large multiplexers, a case statement will simulate faster than a conditional assignment on most simulators, and especially on cycle-based simulators.

Outline Principles of RTL Coding Styles Debugging Tool: nLint Readability Finite state machine (FSM) Coding for synthesis Partitioning for synthesis Debugging Tool: nLint Coding for readability Focusing on lexical conventions and basic RTL constructs Coding for portability create code that is technology-independent, compatible with various simulation tools Guidelines for clocks and resets … Coding for synthesis achieve the best compile times and synthesis results, including: testability, performance, simplification of static timing analysis, gate-level circuit behavior that matches that of the original RTL code Partitioning for Synthesis Better synthesis results Faster compile runtimes Ability to use simpler synthesis strategies to meet timing

Register All Outputs For each subblock of a hierarchical macro design, register all output signals from the subblock. Makes output drive strengths and input delays predictable All the inputs of each block arrive with the same relative delay. Output drive strength is equal to the drive strength of the average flip-flop.

Related Combinational Logic in a Single Module Keep related combinational logic together in the same module R1 A B C R2 Bad clk clk R1 ABC R2 Better Synthesis tools cannot move logic across hierarchical boundaries during default compile operations Improved sequential mapping during optimization because no hierarchical boundaries exist between the sequential logic and the combinational logic that drives it. clk clk R1 ABC R2 Best clk clk

Outline Principles of RTL Coding Styles Debugging Tool: nLint Readability Finite state machine (FSM) Coding for synthesis Partitioning for synthesis Debugging Tool: nLint Coding for readability Focusing on lexical conventions and basic RTL constructs Coding for portability create code that is technology-independent, compatible with various simulation tools Guidelines for clocks and resets … Coding for synthesis achieve the best compile times and synthesis results, including: testability, performance, simplification of static timing analysis, gate-level circuit behavior that matches that of the original RTL code Partitioning for Synthesis Better synthesis results Faster compile runtimes Ability to use simpler synthesis strategies to meet timing

GUI nLint -gui &

Import Design

Edit File

Lint -> Run

Fix Warning 1

Search Rule Right click -> Search Rule

No Error & Warning

Check for Synthesizable (1/2) SpringSoft nLint Check for correct mapping of your design Not so power in detecting latches Synopsys Design Compiler Synthesis Tool The embedded Presto Compiler can list your flip-flops and latches in details > dv -no_gui > read_verilog yourdesign.v

Check for Synthesizable (2/2) Checking latches using Design Compiler