ELEN 468 Lecture 211 ELEN 468 Advanced Logic Design Lecture 21 HDL Coding Styles.

Slides:



Advertisements
Similar presentations
FSM and Efficient Synthesizable FSM Design using Verilog
Advertisements

Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
2/9/20031 ECE 551: Digital System Design & Synthesis Lecture Set 4 4.1: Verilog – Procedural Assignments &Scheduling Semantics 4.2: Verilog – More Behavioral.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 8: Sequential Design Spring 2009 W. Rhett.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
Documentation 1 Comprehending the present – Investing in the future.
Pulse-Width Modulated DAC
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
ELEN 468 Lecture 121 ELEN 468 Advanced Logic Design Lecture 12 Synthesis of Combinational Logic I.
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
ELEN 468 Lecture 81 ELEN 468 Advanced Logic Design Lecture 8 Behavioral Descriptions II.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI System Design Lecture 4 - Advanced Verilog.
ELEN 468 Advanced Logic Design
ELEN468 Lecture 11 ELEN468 Advanced Logic Design Lecture 1Introduction.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Overview Logistics Last lecture Today HW5 due today
Guest Lecture by Ben Magstadt CprE 281: Digital Logic.
ECE 551 Digital System Design & Synthesis Lecture 11 Verilog Design for Synthesis.
Guest Lecture by Ben Magstadt CprE 281: Digital Logic.
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
ECE 2372 Modern Digital System Design
Synthesis Presented by: Ms. Sangeeta L. Mahaddalkar ME(Microelectronics) Sem II Subject: Subject:ASIC Design and FPGA.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
Verilog HDL: A solution for Everybody By, Anil Kumar Ram Rakhyani
Verilog Language Concepts
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
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.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project: RTL Coding Style Speaker: 蔡朝陽 Date: 2010/10/26.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Under-Graduate Project: RTL Coding Style Speaker: MingChun-Hsiao Date: 2012/11/27.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
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.
Introduction to VLSI Design – Lec01. Chapter 1 Introduction to VLSI Design Lecture # 11 High Desecration Language- Based Design.
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,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
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.
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.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Verilog® HDL Behavioral Modeling (2)
Slide 1 3.VHDL/Verilog Description Elements. Slide 2 To create a digital component, we start with…? The component’s interface signals Defined in MODULE.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
CprE 281: Verilog Tutorial Ben Magstadt – Master’s Student Electrical Engineering.
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.
Pusat Pengajian Kejuruteraan Mikroelektronik EMT 351/4 DIGITAL IC DESIGN Verilog Behavioural Modeling (Part 4) Week #
1 Lecture 1: Verilog HDL Introduction. 2 What is Verilog HDL? Verilog Hardware Description Language(HDL)? –A high-level computer language can model, represent.
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
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
Verilog Introduction Fall
Engineering Problem Solving with C++, Etter/Ingber
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
The Verilog Hardware Description Language
Presentation transcript:

ELEN 468 Lecture 211 ELEN 468 Advanced Logic Design Lecture 21 HDL Coding Styles

ELEN 468 Lecture 212 Coding Guidelines Readable Maintainable Reusable

ELEN 468 Lecture 213 Directory Using a common directory structure makes it easy to locate designs Example project directory: bin/project-wide scripts/commands doc/project-level documentation beh/behavioral models rtl/ structural rtl model syn/synthesis scripts & logs phy/physical models and SDF data verif/verif suite and simulation logs

ELEN 468 Lecture 214 Comments Header is always necessary: // main.v // (c) Copyright 2002, Texas A&M University // All rights reserved. // // This file contains proprietary and confidential // information. The content or any derivative // work can only be used by or distributed to // licensed users or owners. // // Description: Demo program for ELEN 468 // // Original author: John Q. Doe // // History: See bottom of the file.

ELEN 468 Lecture 215 Comments Target audience: junior engineers who know the language, but not familiar with the design and must maintain and modify design Describe the function, not the action Useless comments:  k = k + 1; // increment k Useful comments:  k = k + 1; // move pointer to next input bit If you feel you need to explain but can’t find proper words, think.

ELEN 468 Lecture 216 Comments For each module, function and task, describe its function, input/output variables Declaration Layout // poor integer cta, ctb; real ctime; reg [0:31] sum; // good integer cta;// counter for a integer ctb;// counter for b reg [0:31] sum; real ctime; // counting time, for simulation

ELEN 468 Lecture 217 Layout One statement per line No more than 80 characters per line Break long lines Align the line properly #10 bad = something + somethingelse + leftover; #10 good = something + somethingelse + leftover;

ELEN 468 Lecture 218 Indentation Use a minimum of 3 spaces and maximum of 8 spaces for each indentation level. Avoid excess indent due to if-else, begin-end begin if (x == 1’b0) begin y <= x; end else y <= ~x; end endmodule begin if (x == 1’b0) begin y <= x; end else y <= ~x; end endmodule

ELEN 468 Lecture 219 Port Association Name association is more robust than port order mymodule m1(u, v, w, x, y, z); mymodule m2 (.clock(u),.reset(v),.clear(w),.data_in(x),.ctrl_in(y),.sample(z));

ELEN 468 Lecture 2110 Structurally Simple Use no more than 3 levels of nesting Avoid nested loops  Convert nested loops to separate loops Use case instead of if-else  case {a,b,c}  if (a==1’b1) if (b==1’b1) if (c == … No more than 50 consecutive assignments in any block

ELEN 468 Lecture 2111 Name Guidelines Use lower case letters in all user defined identifiers Use upper case for constants Do not rely on case to distinguish uniqueness Separate words using underscore ReadNextInput v.s. read_next_input

ELEN 468 Lecture 2112 Case Do not rely on case to distinguish uniqueness. Easy to make mistake. // bad input ctrl; output Ctrl; // good input ctrl_in; output ctrl_out;

ELEN 468 Lecture 2113 Suffixes Use suffixes to semantically differentiate related variables Type, constant, signal, variable, flipflop, pipeline stage, function Example: ctrl_alu, ctrl_dm, ctrl_reg; Function/purpose is better than implementation Best: data_in, data_out OK: data_32, data_16

ELEN 468 Lecture 2114 Variables Avoid using reserved words in popular languages Have to rename if translated to another language Popular languages: C, C++, Verilog, VHDL, PERL Use meaningful names Poor names: if (e==1’b1) c<=c+1; Good names: if (enable==1’b1) counter<= counter + 1; Use i, j, k, l, m and n as integer variables

ELEN 468 Lecture 2115 Constants Use symbolic constants instead of hard- coded numerical values Bad: reg [255:0] data; Good: reg [WIDTH-1:0] data;

ELEN 468 Lecture 2116 Preserve Names Preserve names across hierarchical boundaries, if possible module traffic(light, pedx, clock); traffic t_univ(.light(light_univ),.pedx(pdex_univ),.clock(clock)); traffic t_texas(.light(light_texas),.pdex(pdex_texas),.clock(clock)); Tracing signals made easy

ELEN 468 Lecture 2117 Race Condition ( posedge clk )// c will get previous b or new b ? c = b; ( posedge clk ) b = a; ( posedge clk )// c will get previous b or new b ? c = b; ( posedge clk ) b = a;

ELEN 468 Lecture 2118 Avoid Race Condition ( posedge clk )// Solution 1: merge always begin c = b; b = a; end ( posedge clk )// Solution 2: intra-assignment delay c = #1 b; ( posedge clk ) b = #1 a; ( posedge clk )// Solution 3: non-blocking assignment c <= b; ( posedge clk ) b <= a; ( posedge clk )// Solution 1: merge always begin c = b; b = a; end ( posedge clk )// Solution 2: intra-assignment delay c = #1 b; ( posedge clk ) b = #1 a; ( posedge clk )// Solution 3: non-blocking assignment c <= b; ( posedge clk ) b <= a;

ELEN 468 Lecture 2119 A Nice Verilog Website