Home / Learn Verilog / Verilog Syntax Basics: Comments, Identifiers, Keywords, Numbers
Verilog Syntax Basics: Comments, Identifiers, Keywords, Numbers
Case sensitivity, comments, names, numbers and the shape of a statement.
The gistCase sensitivity, comments, names, numbers and the shape of a statement.
The idea, explained simply
The basic idea
Verilog source is plain text. Statements end with semicolons, blocks use begin and end, comments use // and /* */, and names are case sensitive.
Why this comes up
Small syntax slips cause long confusing error lists. A solid grounding saves time.
The mechanics
Identifiers start with a letter or underscore and may contain digits and $. Keywords are lowercase. Numbers can be sized: 8'hFF means 8 bits, hexadecimal, value FF.
Where it is used
- Reading code
- Writing clean files
- Code reviews
Number literals
Same value, different basesVerilog: edit and run
All four notations on the first line print 255. x and z are real values in hardware simulation.
| Element | Example | Notes |
|---|---|---|
| Line comment | // text | to end of line |
| Block comment | /* text */ | can span lines |
| Identifier | data_in, _q, Q1 | case sensitive |
| Keyword | module, assign | all lowercase |
| Number | 4'b1010 | size, base, value |
| String | "hello" | used in $display |
| Operator | + - & | ^ ~ | see operators section |
Tip:Choose one style: snake_case names, one module per file, 2 or 4 space indentation. Consistency matters more than which style.
Quick check
1. 8'hFF equals...
FF hexadecimal = 255.
2. Verilog identifiers are...
Data and data are different names.