- Use SystemVerilog-2012 conventions, files named as module.sv, one file per module
- Only ASCII, 100 chars per line, no tabs, two spaces per indent for all paired keywords.
- C++ style comments
// - For multiple items on a line, one space must separate the comma and the next character
- Include whitespace around keywords and binary operators
- No space between case item and colon, function/task/macro call and open parenthesis
- Line wraps should indent by four spaces
beginmust be on the same line as the preceding keyword and end the lineendmust start a new line
- Use lower_snake_case for instance names, signals, declarations, variables, types
- Use UpperCamelCase for tunable parameters, enumerated value names
- Use ALL_CAPS for constants and define macros
- Main clock signal is named
clk. All clock signals must start withclk_ - Reset signals are active-low and asynchronous, default name is
rst_n - Signal names should be descriptive and be consistent throughout the hierarchy
- Add
_ito module inputs,_oto module outputs or_iofor bi-directional module signals - The input (next state) of a registered signal should have
_dand the output_qas suffix - Pipelined versions of signals should be named
_q2,_q3, etc. to reflect their latency - Active low signals should use
_n. When using differential signals use_pfor active high - Enumerated types should be suffixed with
_e - Multiple suffixes will not be separated with
_.nshould come firsti,o, oriolast
- Use full port declaration style for modules, any clock and reset declared first
- Use named parameters for instantiation, all declared ports must
be present, no
.* - Top-level parameters is preferred over
`defineglobals - Use symbolically named constants instead of raw numbers
- Local constants should be declared
localparam, globals in a separate .svh file. logicis preferred overregandwire, declare all signals explicitlyalways_comb,always_ffandalways_latchare preferred overalways- Interfaces are discouraged
- Sequential logic must use non-blocking assignments
- Combinational blocks must use blocking assignments
- Use of latches is discouraged, use flip-flops when possible
- The use of
Xassignments in RTL is strongly discouraged, make use of SVAs to check invalid behavior instead. - Prefer
assignstatements wherever practical. - Use
unique caseand always define adefaultcase - Use available signed arithmetic constructs wherever signed arithmetic is used
- When printing use
0band0xas a prefix for binary and hex. Use_for clarity - Use logical constructs (i.e
||) for logical comparison, bit-wise (i.e|) for data comparison - Bit vectors and packed arrays must be little-endian, unpacked arrays must be big-endian
- FSMs: no logic except for reset should be performed in the process for the state register
- A combinational process should first define default value of all outputs in the process
- Default value for next state variable should be the current state