Monday, August 10, 2009

GUIDELINES

2 GUIDELINES
The guidelines are broken into two types: rules and suggestions.
All rules start with a number followed by the word RULE. Rules are policies that every coder MUST follow. That is to say, there is no room for exceptions.
All suggestions begin with a number followed by the word CONVENTION. Suggestions are policies that should be followed, but exceptions may be made with cause. Conventions are typically there to make your life, and the life of others working on your code, easier. Please note that not liking a convention is not a valid reason for not following a guideline.
2.1 CONSISTENCY AND READABILITY
2.1.1 GENERAL STYLE GUIDELINES

110 RULE Tabs shall not be used. Use spaces and empty lines to improve the readability of the code.

120 RULE Two spaces shall be used for code indentation.

130 RULE Line length shall be kept to 80 characters or less. When a single line statement is broken into multiple lines, the continuation lines shall be indented to the first line. Example:

if (enable_1 && enable_2 &&
enable_3 && enable_4)

140 RULE Use “_” [underscore] to separate words in identifiers. For example: use priority_encoder rather than priorityEncoder.

150 RULE All identifiers shall consist only of alphanumeric and underscore (dollar sign “$”, while legal in Verilog, is not allowed). All signal, module, and port names shall include lowercase letters only (no uppercase). All defines shall include uppercase letters only (no lowercase). No escaped identifiers are allowed. The size of a name shall be less than or equal to 28 characters. Identifiers may not differ only in case (e.g. don’t have both “foo” and “FOO”).

151 RULE All chip-level port names shall be upper case (this is an exception to rule 150). The pad cell connected to the port shall be explicitly instantiated. Its name shall also be upper case and begin with a U_ prefix. A signal coming into the chip core from a pad cell shall have the suffix _in. A signal going out from the chip core to a pad cell shall have suffix _out. If the pad is bidirectional, the output enable shall have suffix _oe.

160 RULE Only one Verilog statement shall be coded per line.

170 RULE Comments shall be given before each assign statement or group of assign statements that explain the intent of the assign.

180 RULE A Comment paragraph shall be given before each always block that explains the intent of the always block.

190 RULE A Comment paragraph shall be given before each function block that explains the intent of the function.

200 RULE All messages from Verilog RTL shall follow the following standard format:

1) A line of 50 dashes
2) A line enclosed in square brackets containing the following information:

a) Level=, where is "ERROR", "WARNING", "INFO", "VERBOSE" or "DEBUG"
b) Time=, where is the current simulation time, scaled to nano-seconds, followed by the units "ns".
c) File=, where is the name of the verilog file fromwhere the message originated, if available.
d) Line=, where is the line number in the verilog file from where the message originated, if available.
e) Instance=, where is the instance pathname to the Veriog module/block from where the message originated, if available.

Note: b), c), d) and e) are available through the PLI. A PLI call for printing a standard error message will be available.

3) A line containing a left curly brace
4) One or more lines containing the descriptive text for the message.
5) A line containing a right curly brace

Should have example Verilog code (e.g. the code that generates the following message).

Example:

--------------------------------------------------
[Level=ERROR Time=0.000ns File="abc.v" Line=22
Instance=top.design.abc01]
{
The flag word 0x0020 has the incorrect checksum 1, should be 0
}

VERILOG CODING GUIDELINES

1 Introduction

This BLOG specifies the Verilog RTL coding guidelines for ASIC and FPGA design.

1.1 Purpose

The Ageia RTL Verilog coding guidelines specify a style of coding to improve the following aspects of RTL code:

· Synthesis

· Consistency and Readability

· Verification

· Portability

· Maintainability

· Third-party Tool Support

1.2 Scope

These guidelines are valid for any ASIC or FPGA coding that is done for Ageia Technologies either internally or by one of Ageia Technologies’ contractors. These guidelines do not pertain to the verification process. Any Verilog done for the verification of hardware will follow yet-to-be-defined guidelines. Some of these guidelines do not apply to machine generated code, but many do.