![[信息与通信]Verilog_Coding_Style.doc_第1页](http://file.renrendoc.com/FileRoot1/2019-2/22/fd6ecb84-4cc3-45aa-8403-007dbb2206d3/fd6ecb84-4cc3-45aa-8403-007dbb2206d31.gif)
![[信息与通信]Verilog_Coding_Style.doc_第2页](http://file.renrendoc.com/FileRoot1/2019-2/22/fd6ecb84-4cc3-45aa-8403-007dbb2206d3/fd6ecb84-4cc3-45aa-8403-007dbb2206d32.gif)
![[信息与通信]Verilog_Coding_Style.doc_第3页](http://file.renrendoc.com/FileRoot1/2019-2/22/fd6ecb84-4cc3-45aa-8403-007dbb2206d3/fd6ecb84-4cc3-45aa-8403-007dbb2206d33.gif)
![[信息与通信]Verilog_Coding_Style.doc_第4页](http://file.renrendoc.com/FileRoot1/2019-2/22/fd6ecb84-4cc3-45aa-8403-007dbb2206d3/fd6ecb84-4cc3-45aa-8403-007dbb2206d34.gif)
![[信息与通信]Verilog_Coding_Style.doc_第5页](http://file.renrendoc.com/FileRoot1/2019-2/22/fd6ecb84-4cc3-45aa-8403-007dbb2206d3/fd6ecb84-4cc3-45aa-8403-007dbb2206d35.gif)
已阅读5页,还剩37页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Verilog Coding Style Verilog HDL Coding Rules1. IntroductionThe general coding standards pertain to design generation and deal with naming conventions, documentation of the code and the format, or style, of the code. Conformity to these standards simplifies reuse by describing insight that is absent from the code, making the code more readable and assuring compatibility with most tools. Any exceptions to the rules specified in this standard, except as noted, must be justified and documented.The methodology standards promote reuse by ensuring a high adaptability among applications. The intent of this document is to ensure that the gate level implementation is identical to the HDL code as it is understood by a standard Verilog simulator. Partitioning can affect the ease with which a model can be adapted to an application. The modeling complex behavior section deals with structures that are typically difficult to address well in a synthesis environment and are needed to ensure pre- and post-synthesis consistency. These standards apply to behavioral as well assynthesizable code.2 Reference Information2.1 Documented References1. Reuse Methodology Manual for System-on-a-Chip Designs, M. Keating, P. Bricaud, KluwerAcademic Publishers, 2nd Edition, 1999.2.2 TerminologyHDL : Hardware Description LanguageMTBF: Mean Time Between FailuresPLL : Phase Locked LoopRTL : Register Transfer Level3 Naming Conventions3.1 File NamingRULE 3.1 One design unit per fileA file must not contain more than one design unit. Everything contained in a design unit must be completely contained in a single module/endmodule construct.Reason: Simplify design modifications.RULE 3.2 File naming conventionsThe file name is the same with the block name, and should be composed in the following way:.where: is the name of the design unit (i.e., module name). signifies that it is a Verilog file:.v Verilog file for RTL.vg Verilog file for Gate Level Design.vhd for vhdl file.Reason: Simplify understanding the design structure, and file contents.Example: spooler.v Synthesizable Verilog code for module spoolerNote: Refer to the design Block Deliverables section for model naming conventions.RULE 3.3 Analog and digital Verilog filesAn individual file must contain: (1) only analog Verilog (with the .va file extension); or (2) only digital Verilog (with the .v file extension) or (3) only explicit mixed analog/digital Verilog (with the .va file extension).Reason: Analog compilers may not handle digital constructs, and vice versa.RULE 3.4 Asynchronous module must be declared explicitly as “async” in name3.2 Naming of HDL Code ItemsA meaningful name very often helps more than several lines of comment. Therefore, names should be meaningful (i.e., the nature and purpose of the object it refers to should be obvious and unambiguous).RULE 3.5 Develop a naming conventionDevelop a naming convention for the design, including blocks, ports and signals. Document it and use if consistently throughout the designRULE 3.6 Allowable character setNames must be composed of alphanumeric characters or underscores A-Z, a-z, 0-9, _ (see RULE 3.5)Exception: Consecutive underscores are not allowed.Reason: Double underscores will not work with hardware emulationRULE 3.7 First character of a nameNames must start with a letter, not a number or underscore (see RULE 3.4)Reason: Names starting with a number or underscore may cause conflicts with tools.RULE 3.8 All names must be unique irrespective of caseCase must not be used to differentiate cell names or signals.Reason: Use of some tools may not be able to differentiate on the basis of case. Moving designs between Verilog (case sensitive) to VHDL (case insensitive) is facilitated by a case insensitive design style.RULE 3.9 Consistent use of signal namesConsistent usage in the spelling and naming style of signals, variables and design unit names must be used. This includes case and naming conventions. Signal name should keep the same across the hierarchies.Reason: Improve readability, remove confusion, avoid buffer insertion during synthesis.RULE 3.10 Constant, parameter and block label are upper caseConsistent upper case spelling of parameter and constant names must be used. Therefore, all letters must be uppercase for: constants. parameters macros block labelsReason: Provide a mechanism to identify objects that do not go through data changes during simulation.RULE 3.11 Pad names should be capitalizedRULE 3.12 Signal, constructs and instance labels are lower caseConsistent lower case spelling of signal and construct names, and instance labels must be used. Therefore, all letters must be lower case for: signals constructs instance labelsReason: Differentiate signals and constructs from objects that do not change data during simulation, and maintains a consistent look and feel between designs.RULE 3.13 Meaningful signal and variable namesThe lower-case name must contain the purpose of the variable/signal.Reason: Description of what not how aids in understanding the design.Example: data_bus, set_priorityRULE 3.14 Meaningful constant namesA constant name must describe the purpose of the constant. The type of the constant must be obvious by the purpose and is not part of the name. Constants are upper-case.Reason: Meaningful names are particularly important for constants.Example: Good naming: SBUS_DATA_BITS, MEMORY_WIDTH, CLK_PERIODExample: Bad naming: ADDRESS_SIZE is not clear if it refers to the number of bits or the size of the address space.RULE 3.15 Meaningful construct namesConstruct names such as functions, modules, tasks, etc. must be named according to what they do rather than how they do it. Construct names are lower case.Reason: Description of what, not how, aids in understanding the design. How can be seen from the code, what may not be immediately obvious.)RULE 3.16 Meaningful instance labelsInstance labels must be named according to what task is carried out by the construct, not according to how it is done.The instance name must be begun from u_. Instance labels are lower case.Reason: Description of what, not how, aids in understanding the design.Example: u_addr_decode, u_bit_stuff, u_sbus_ifRULE 3.17 Use symbolic constants instead of “magic” hard coded numeric valuesE.g., the following statement is not recommended:Always (posedge clk)If (reset)Image_width = #1 10d640;Elseit is recommended as the following:define DEFAULT_IMAGE_WIDTHAlways (posedge clk)If (reset)Image_width = #1 DEFAULT_IMAGE_WIDTH;ElseRULE 3.18 Top-level signals should be named including the abbreviation of driving blockand target blockTop level signals between IPs should be named including driving block abbreviation and target block abbreviation as pre-fixE.g., drv_tgt_signalnamedrv: driving block name abbr.tgt: target block name abbr.RULE 3.19 Global signals should be named explicitly including the source information.If one signal drives more than one module, the name should include the source module informationE.g., drv_signalname drv: driving block name abbr.RULE 3.20 Underscore separate names composed of several wordsFor names composed of several words, underscore separated lower case letters must be used. Do not separate using upper or lower case.Reason: Improve readability.Example: ram_addrRULE 3.21 Active low signal names use _nFor active low signals, end the signal name with an underscore followed by a lowercase character (for example, -b or _n). Use the same lowercase character to indicate active low signals throughout the design. For standardization, we recommend to use _n in our design. Where a signal uses active low polarity, it must use the suffix _n.Reason: Meaningful, consistent names aid in understanding the design.Example: enable_data_n, reset_n.RULE 3.22 Clock signal names use _clkUse the name clk for the clock signal. If there is more than one clock in the design, use clk as the suffix fro all clock signals, such as xxx_clk.Reason: Meaningful, consistent names aid in understanding the design.Example: fifo_transmit_clkException: Signals whose names obviously indicate clocks (i.e., system_clock or clk32m).RULE 3.23 Use the same name _reset for reset signal.Use the name reset for reset signals. If there is more than one clock in the design use reset as the suffix for all reset signals, such as xxx_reset. If the reset signal is active low, use reset_n.Reason: Meaningful, consistent names aid in understanding the design.RULE 3.24 Signal bundlingUnrelated signals must not be bundled into buses.Reason: Help to understand the module.RULE 3.25 Three-state signal names use _z suffixIt is recommended that Tri-state signals use the suffix _z.Reason: Meaningful, consistent names aid in understanding the design.Example: ram_data1_zRULE 3.26 State machine signal names use _next and _current suffixUse a distinctive suffix for state variable names. Recommended names are _current for the current state, and _next for the next state.Reason: Meaningful, consistent names aid in understanding the design.Example: transmit_nextRULE 3.27 Test mode signal names use tm_ prefixIt is recommended that test mode signals use the prefix tm_.Reason: Meaningful, consistent names aid in understanding the design.Example: tm_usbphy_bisttm_tigh_highRULE 3.28 Scan enable signal names use _se suffixIt is recommended that scan enable signals use the suffix _se.Reason: Meaningful, consistent names aid in understanding the design.RULE 3.29 Analog signal names use _ana suffixIt is recommended that analog signals use the suffix _ana.Reason: Help to understand the design when analog signals are differentiated, especially useful when using a raphical viewer.RULE 3.30 Multiple suffix signal name priorityFor signals that may contain multiple suffixes, the following priority, from highest to lowest, is recommended:1. _b2. _z3. _clk4. _ntThe highest priority suffix is recommended to be the last suffix to the signal.Example: ram_data1_z_b, receive_clk_b.RULE 3.31 Signal name lengths less than 28 charactersIt is recommended that signal name length not exceed 28 characters. Shorter names increase readability. The characters does not include the hierarchy.Reason: Longer name lengths may cause conflicts with tools.RULE 3.32 Avoid abbreviations except for commonly known acronymsIt is recommended that abbreviations, especially abbreviations with only one letter, be avoided unless it is acommonly known acronym.Reason: Use of meaningful names.Exception: Generally known abbreviations or acronyms, like RAM, and loop counters. Loop counters may be named with a single letter like I or N, because they represent an index. Some back end tools concatenate all hierarchy names and put a limit on the total name length. In that case abbreviations might be required for hierarchy names. The abbreviations must be explained in a comment.RULE 3.33 Document abbreviations and additional naming conventionsIt is recommended that any abbreviations used in the module be documented. Any naming conventions used in the module that are in addition to the conventions required or recommended in the SRS should be documented.Reason: What may be an obvious abbreviation to the original designer could be obscure when themodule is reused.RULE 3.34 Consistent ordering for multi-bit busesWhen describing multi-bit buses, use a consistent ordering of bits. For Verilog, we recommended use (x:0). Using a consistent ordering helps improve the readability of the code and reduces the chance of accidently swapping order between connected buses.Reason: Improve readability, remove confusion, and keep consistency in the design.RULE 3.35 Do not use HDL reserved wordsDo not use VHDL or Verilog reserved words for names of any elements in your RTL source file. Because macro designs must be translatable from VHDL to Verilog and vice versa, it is important not to use VHDL reserved words in Verilog code, and not to use Verilog reserved words in VHDL code.Reason: Help to understand the HDL model.RULE 3.36 Verilog names are equivalent to documentation namesAll signals and blocks in the Verilog RTL that are referenced in the documentation are recommended to maintain the same name as in the documentation.Reason: Help to understand the HDL model.RULE 3.37 Constant definition filesKeep constant and parameter definitions in one or a small number of files with names. It is recommended for the file as: _define.vSource files should not make references to constant definition files with the include statement, since this will cause problems if the core is instantiated multiple times in the design, but with different constant values. We recommended that constant definition files be specified only on tool command lines.RULE 3.37 Define timescale before each designThe timescale will not be changed after another timescale definition is met, so the timescale may be not appropriate if it adopt one which is defined for other module.4 CommentsComments are required to describe the functionality of a design unit. In particular, comments must supply context information that is not seen locally.4.1 File HeadersFigure 1 shows the standard file headers to be used for Verilog files. This template format assures consistency.RULE 4.1 Include a header at the top of source fileInclude a header at the top of the source file, including scripts.RULE 4.2 Each file must contain a file headerEvery file must contain a header as shown in Figure 1. All fields must be included, even if the data is N/A.Reason: Provide a standard means of supplying pertinent design information.RULE 4.3 Include file nameThe header must include the name of the file.Reason: Provide an easy way to determine what a file contains.RULE 4.4 Include file construct typeThe header must include the top level construct contained in the file.Reason: Provide an easy way to determine what a file contains.Example: module, macromoduleRULE 4.5 Include point of contact informationEvery file header must include the originating department, author, and authors email address.Reason: Require for inquiries beyond the scope of the documentation for the design.RULE 4.6 Include a release historyHeader must include release history only for the design changes checked into the Repository. This information is useful to the integrator. Local release history should not be included in the header.Reason: Require to track the revision history of the design./+FHDR-/ Copyright (c) 2004, ISVIEW./ ISVIEW Confidential Proprietary/-/ MODULE NAME :/-/ DESCRIPTION : Short description of functionality/ -/ AUTHOR :/ EMAIL :/-/ Revision history/ VERSION Date AUTHOR DESCRIPTION/ 1.0 6 Oct 98 name/-FHDR-Figure 1 Verilog File HeaderRULE 4.7 Include a keyword sectionThe header must contain a section of the searching keywords. This string may contain a few word synopsis of the modules functionality, or list systems and buses that the module was designed to work with.Reason: Keywords provide a quick searching mechanism and aid the design integrator in the appropriate selection of blocks. If there are no keywords, the entry should be left blank.Example: address decoder, coldfire, sbusRULE 4.8 Include a purpose sectionThe header must contain a purpose section describing the modules functionality. The purpose must describe what the unit provides and not how.Reason: Help to understand the module functionality.RULE 4.9 Include a parameter descriptionHeaders must contain information describing the parameters being used in the construct. The default value must be listed. For Verilog-AMS files, the units of the parameter must also be listed.Reason: Help to understand the HDL code.RULE 4.10 Document the reset strategyThe reset strategy must be documented, including whether the reset is synchronous or asynchronous, internal or external power-on reset, hard versus soft reset, and whether the module is individually resettable for debug purposes.Reason: Improve readability of the code, and highlights test and synthesis steps that must be taken.RULE 4.11 Document the clock domainsThe number of clock domains and clocking strategies must be documented.Reason: Documenting internally generated clocks, or divided down clocks allows better understanding of the code and clocking schemes.RULE 4.12 Document the critical timingCritical timing including external timing relationships must be documented.Reason: The setup-hold and output timing relationships highlight the test and synthesis steps that must be taken.RULE 4.13 Test featuresAny specific test features that are added to the code to speed up testing must be documented.Reason: Improve the ability to understand and test the code on
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 粮食品牌建设与营销策略-洞察阐释
- 一年级下册道德与法治教案
- 校园足球知识竞赛活动方案
- 企业车辆无偿调拨使用合同
- 车辆交易税费垫付借条模板
- 体育馆场所租赁及赛事举办合作协议
- 智能车棚租赁与车辆停放安全保障合同
- 餐饮企业股东合作协议:股权调整与经营管理
- 2025建筑工程施工合同(标准中英)
- 2025护理人员劳动合同书
- DB11∕T 2000-2022 建筑工程消防施工质量验收规范
- 人脸识别门禁系统使用指南
- 酒店安全设施
- 水下机器人研究报告
- 建筑项目部考勤管理制度
- 中班健康课件《我不挑食》
- 中国盐业集团有限公司招聘笔试题库2024
- 2024年人教版小学四年级信息技术(上册)期末试卷附答案
- 运动是良医智慧树知到答案2024年成都师范学院
- 四川省凉山彝族自治州 2023-2024学年八年级下学期7月期末道德与法治试题
- 2024年安徽省高考生物试卷(真题+答案)
评论
0/150
提交评论