Professional Documents
Culture Documents
Motorola Verilog HDL Coding
Motorola Verilog HDL Coding
IPMXDSRSHDL00001
V3.0
evision History
Revision History
Motorola reserves the right to make changes without further notice to any products herein to improve reliability, function or design.
Motorola does not assume any liability arising out of the application or use of any product or circuit described herein; neither does
it convey any license under its patent rights nor the rights of others. Motorola products are not designed, intended, or authorized
for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain
life, or for any other application in which the failure of the Motorola product could create a situation where personal injury or death
may occur. Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall
indemnify and hold Motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims,
costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or
death associated with such unintended or unauthorized use, even if such claim alleges that Motorola was negligent regarding the
design or manufacture of the part. Motorola and B are registered trademarks of Motorola, Inc. Motorola, Inc. is an Equal
Opportunity/Affirmative Action Employer.
Table of Contents
List of Figures
Introduction
Reference Information
Naming Conventions
R 7.3.1 At most one module per file
R 7.3.2 File naming conventions
R 7.3.3 Separate analog, digital, and mixed-signal Verilog files
R 7.3.4 Alphanumeric and underscores allowable character set
R 7.3.5 First character of a name is a letter
G 7.3.6 Avoid escaped names
R 7.3.7 Underscore separate names composed of several words
R 7.3.8 Consistent spelling and style of signal names
R 7.3.9 Verilog names are equivalent to documentation names
R 7.3.10 Names representing constants are upper case
R 7.3.11 Net, variable, construct and instance names are lower case
R 7.3.12 All names must be unique irrespective of case
R 7.3.13 Use meaningful names
R 7.3.14 Verilog and VHDL keywords not allowed
R 7.3.15 Global text macros include module name
R 7.3.16 Restricted use of suffixes
R 7.3.17 Active low signal names end in _b
R 7.3.18 Clock signal names end in _clk
G 7.3.19 Unconnected output signal names end in _nc
G 7.3.20 Three-state signal names end in _z
G 7.3.21 State machine next state names end in _next or _ns
G 7.3.22 Test mode signal names end in _test
G 7.3.23 Scan enable signal names end in _se
G 7.3.24 Analog signal names end in _ana
G 7.3.25 Register output names end in _reg
G 7.3.26 Multiple suffix signal name order
G 7.3.27 Signal name lengths do not exceed 32 characters
G 7.3.28 Avoid uncommon abbreviations
G 7.3.29 Document abbreviations and additional naming conventions
G 7.3.30 Consistent names throughout hierarchy
G 7.3.31 Instance names equal module names
Comments
R 7.4.1 Each file must contain a file header
R 7.4.2 Use file header boundary tags (+FHDR & -FHDR)
R 7.4.3 Include file name
R 7.4.4 Include point of contact information
7.1 Introduction
The Verilog HDL coding standards pertain to Virtual Component (VC) 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 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 that a model can be adapted to an
application. The modeling practices 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 as synthesizable code. Additionally, these standards apply to
all other code written in Verilog, such as testbenches and monitors. Some of the standards explicitly state
the type of code to which they apply, and exceptions to the standards are noted.
The rules were determined to be items that enable rapid SoC design, integration, and production, as well
as enable maintainability by someone other than the original author. Note that in many cases, a guideline
may fit this definition, however, at this point it may have a large number of exceptions, tool limitations, or
a deeply entrenched opposing usage which prohibited the rule designation.
7.1.1 Deliverables
The deliverables to the IP Repository are defined in Section 2 VC Block Deliverables. These
deliverables include:
• Synthesizable RTL Source Code (L1)
• Testbench (V1)
• Drivers (V2)
• Monitors (V3)
• Detailed Behavioral Model (V4)
• Stub Model (V6)
• Formal Model Checking (V12)
[1] Reuse Methodology Manual for System-on-a-Chip Designs, M. Keating, P. Bricaud, Kluwer
Academic Publishers, 2nd Edition, 1999.
[2] IEEE Verilog Hardware Description Language, IEEE Standard 1364-1995.
7.2.2 Terminology
Base address: An address in the allocated address space to which offsets are added to access registers.
HDL: Hardware Description Language.
Mask plug: Physically a mask plug is just a wire either connected to VDD or VSS, or a choice of two
inputs (hardwired switch) used to configure a module without changing anything internal to that module.
This avoids resynthesis when changing the configuration.
PLL: Phase Locked Loop.
RTL: Register Transfer Level.
Text macro: ‘define.
Top level module: Module at the highest level of the VC design hierarchy.
UDP: User Defined Primitive.
A 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).
The following naming conventions do not apply to third-party PLI tasks.
R 7.3.4 Alphanumeric and underscores allowable character set
Names must be composed of alphanumeric characters or underscores [A-Z, a-z, 0-9,_]. Consecutive underscores are not
allowed.
reason: Double underscores will not work with VHDL.
R 7.3.11 Net, variable, construct and instance names are lower case
Consistent lower case spelling of hardware structures that have a close correlation to the structure of the circuit being
modeled must be used. Therefore, all letters must be lower case for:
• nets
• variables
• constructs, such as functions, tasks, named blocks, modules, or UDPs
• instances, such as gates, modules, or UDPs
reason: Differentiates signals from objects that do not change during simulation and maintains a consistent look and
feel between designs. Consistent use of case prevents confusion and errors.
exception: Common CMD tasks in functional verification (see Section 9 Functional Verification).
example: cpu_bus_access_reg
7.4 Comments
Comments are required to describe the functionality of HDL code. In particular, comments must supply
context information that is not seen locally.
Every RTL and behavioral Verilog file will be documented with the header shown in Figure 7-1. The
format of the header must match the figure to ensure the ability to parse the header with a software tool.
The capitalized keywords in the header may be used as search points for types of information. This
template format assures consistency. The header shown is the minimum required, and additions may be
made after the REUSE ISSUES section. Additionally, a copyright and company confidential header may
be included at the top of the header.
// +FHDR------------------------------------------------------------------------
// Optional Copyright (c)
// Optional Company Confidential
// -----------------------------------------------------------------------------
// FILE NAME :
// DEPARTMENT :
// AUTHOR :
// AUTHOR’S EMAIL :
// -----------------------------------------------------------------------------
// RELEASE HISTORY
// VERSION DATE AUTHOR DESCRIPTION
// 1.0 YYYY-MM-DD name
// -----------------------------------------------------------------------------
// KEYWORDS : General file searching keywords, leave blank if none.
// -----------------------------------------------------------------------------
// PURPOSE : Short description of functionality
// -----------------------------------------------------------------------------
// PARAMETERS
// PARAM NAME RANGE : DESCRIPTION : DEFAULT : UNITS
// e.g.DATA_WIDTH [32,16] : width of the data : 32 :
// -----------------------------------------------------------------------------
// REUSE ISSUES
// Reset Strategy :
// Clock Domains :
// Critical Timing :
// Test Features :
// Asynchronous I/F :
// Scan Methodology :
// Instantiations :
// Synthesizable (y/n) :
// Other :
// -FHDR------------------------------------------------------------------------
Each additional construct (function, task, user-defined primitive) within files will also be documented with
the following header. Figure 7-2 contains the header for Verilog functions, user-defined primitives, and
tasks. The format of the header must match the figure to ensure the ability to parse the header with a
software tool. The capitalized keywords in the headers may be used as search points for types of
information. This template format assures consistency.
// +HDR ------------------------------------------------------------------------
// NAME :
// TYPE :TYPE can be func, task, primitive
// -----------------------------------------------------------------------------
// PURPOSE : Short description of functionality
// -----------------------------------------------------------------------------
// PARAMETERS
// PARAM NAME RANGE : DESCRIPTION : DEFAULT : UNITS
// e.g. DATA_WIDTH_PP [32,16] : width of the data : 32 :
// -----------------------------------------------------------------------------
// Other : Leave blank if none.
// -HDR ------------------------------------------------------------------------
Comments are required to describe the functionality and flow of HDL code. They must be sufficient for
another designer to understand and maintain the code.
R 7.4.25 Comment functional sections
Each functional section of the code must be preceded by comments describing the code’s intent and function.
reason: Aids understanding of the code.
reason: Improves readability. When writing a code block (begin, case, if statements etc.), it is useful to complete the
frame first, in particular to put the end of the code block down to align with the begin.
// +FHDR------------------------------------------------------------------------
// FILE NAME : prescaler.v
// DEPARTMENT : department name
// AUTHOR : name of author
// AUTHOR’S EMAIL : email address
// -----------------------------------------------------------------------------
// RELEASE HISTORY
// VERSION DATE AUTHOR DESCRIPTION
// 1.0 1998-09-12 tommyk initial version
// 2.0 1998-11-11 mkentley Updated for SRS compatibility
// 2.1 1999-10-25 markl Cleaned up prescaler bypass.
// Added comments in header.
// -----------------------------------------------------------------------------
// KEYWORDS : clock divider, divide by 16
// -----------------------------------------------------------------------------
// PURPOSE : divide input clock by 16.
// -----------------------------------------------------------------------------
// PARAMETERS
// PARAM NAME RANGE : DESCRIPTION : DEFAULT : UNITS
// N/A
// -----------------------------------------------------------------------------
// REUSE ISSUES
// Reset Strategy : Asynchronous, active low system level reset
// Clock Domains : system_clock, clock_in
// Critical Timing : N/A
// Test Features : Prescaler is bypassed when scan_mode is asserted
// Asynchronous I/F : reset_b
// Scan Methodology : Mux-D
// Instantiations : N/A
// Synthesizable : Y
// Other : uses synthesis directive to infer a mux to
// avoid glitching clock_out and clock_out_b
// -FHDR------------------------------------------------------------------------
module prescaler(
clock_out, clock_out_b,
clock_in, system_clock,
scan_mode, reset_b
);
if (!reset_b)
count <= 4’b0000; // reset counter
else if (count == 4’b1111)
count <= 4’b0000; // roll the counter over
else
count <= count + 4’b0001; // increment counter
fast slow
clock clock
logic logic
note: Pay particular attention to the interface where there is a frequency difference. For example, a lower frequency
clock domain cannot guarantee to receive a signal of single period width from a higher frequency clock
domain. The higher frequency domain must supply signals with the following minimum active period:
tactive = tslow + tsetup + thold, where:
tactive is the minimum active period of a interfacing signal
tslow is the clock period of the receiving clock domain that has the low frequency
tsetup is the setup time of the receiving D-type flip-flop
thold is the hold time of the receiving D-type flip-flop
tactive must take into account the different propagation delay paths for the interfacing signal. In addition skew
must be also taken into consideration.
exception: Not applicable to non-synthesizable modules (e.g., Bus Functional Models, Bus Monitors or Analog
Behavioral Models) unless they are intended to be synthesized for emulation.
reason: Design tools do not adequately support the development of asynchronous designs. Reliable timing verifica-
tion, including the detection of glitches and hazards, will in general require extensive simulation with SPICE,
which is expensive and time consuming.
exception: Not applicable to non-synthesizable modules (e.g., Bus Functional Models, Bus Monitors or Analog
Behavioral Models) unless they are intended to be synthesized for emulation.
G 7.8.14 Use text macros for register field positions and values
It is recommended to use text values for register field positions and field values rather than numerical constants. The fields
may be one or more bits or the entire register.
reason: Improves readability, and maintainability. Reduces the chance of using the wrong bits or the wrong value.
example: `define CNT_WHAT cnt_ctrl[7:5] // What to count
parameter CNT_ADDR = 2`b00 // count address matches
parameter CNT_DATA = 2`b01 // count data matches
always @(`CNT_WHAT)
case (`CNT_WHAT)
`CNT_ADDR: cnt_in = cnt_addr ;
`CNT_DATA: cnt_in = cnt_data ;
endcase // (`CNT_WHAT)
Q D
scan_mode Q
EN
clk
G 7.10.18 Use a cycle wide enable signal for signals with multicycle paths
It is recommended that a signal propagated through a multicycle path be qualified by a one clock cycle wide enable signal at
the receiving register.
reason: Failure to do so will result in potential metastability problems at the output of the receiving register.
note: Using multicycle paths has severe implications on test and their usage must be carefully evaluated and
completely documented.
example: This example illustrates an acceptable use of the full_case directive. State machine:
case (state_cur) // synthesis full_case directive
IDLE : if (frame) state_next = BUSY;
BUSY : begin
if (!frame && !irdy) state_next = IDLE;
if (( frame && hit && !terminate ) state_next = XDATA;
end
XDATA : if (frame && stop && !trdy ) state_next = BACKOFF
BACKOFF : if ( !frame) state_next = TURNA;
TURNA : if ( !frame) state_next = IDLE;
endcase
FINAL PAGE OF
42
PAGES