Verilog identifier and keyword
1. Identifier:
Identifiers in Verilog HDL refer to the combination of all names used to declare data, variables, ports, case aliases, etc., except for keywords. For example, input A, where a is an identifier that represents the name of an input port.
The Verilog HDL identifier can be any combination of letters, numbers, $, and underscores, but the first character of the identifier must be a letter or underscore. In addition, identifiers are case sensitive.
The following are all valid representations:
Count, count, a, y, _mem, ab0, x
123;
Illegal identifier:
123a, $we, we#, oe#, cs#, % ABC, etc
Notice that Count, Count is a different identifier.
2. Keywords:
Keywords are special identifiers reserved by Verilog syntax for port definitions, data type definitions, assignment identifiers, process handling, and so on. The keyword must be lowercase.
For example, input, output,wire, REg, always, begin, end, and module are all keywords. Keywords must use lowercase letters. Those with uppercase letters can only be used as common identifiers, such as Input. Input does not have the function of a keyword, although it appears that only the letter I is uppercase.
Keywords that can be used for synthesis:
Keyword list:
Each keyword has a special meaning, so keywords cannot be used as general identifiers. With so many keywords and some keywords that are not commonly used, how do you ensure that keywords are not misused as general identifiers? Generally, the editors (Quartus II,Vivado, etc.) that provide Verilog’s comprehensive EDA tools recognize Verilog keywords and display them in different colors or highlights, so they are easy to distinguish. Figure 1 shows a portion of the display of keywords in the Editor provided by Quartus II. Therefore, it is very easy to find and correct mistakes once they are used. Of course, the compiler will also report an error message when compiling, easy to troubleshoot.
Figure 1
As can be seen from Figure 1, in Quartus II’s text editing interface, keywords are displayed in blue, so once keywords are wrongly used as common identifiers, they can be identified by color.