D01. Lexical Resourses
D01. Lexical Resourses
D01. Lexical Resourses
1. Case Sensitivity:
• Verilog is case sensitive.
• Keywords, system tasks, and system functions are in lowercase, while user-defined identifiers are case sensitive.
module caseExample;
input A;
output B;
assign B = a; // Error, 'a' is different from 'A'
due to case sensitivity.
endmodule
2. Whitespace:
• Verilog ignores spaces, tabs, and line breaks, except to separate tokens.
• Whitespace is used to make the code more readable.
module whitespaceExample;
input A;
output B;
endmodule
3. Comments:
• Comments are denoted by double slashes `//` for single-line comments.
• `/ * */` for multi-line comments.
• They are used for documentation and explanations within the code.
module commentsExample;
/* This is
a multi-line comment */
input A;
output B;
assign B = A + 1;
endmodule
4. Identifiers:
• Identifiers in Verilog are used for naming modules, variables, and other elements.
• They must start with a letter or an underscore and can contain letters, digits, and underscores.
module identifierExample;
input data_in;
output data_out;
wire clk;
endmodule
5. Keywords:
• Verilog has a set of reserved keywords like module, input, output, and always, which have special meanings in the language.
module keywordExample;
input A, B;
output Y;
endmodule
6. Literals:
• Verilog supports different literal types, including binary, octal, decimal, and hexadecimal.
• For example, 8'hFF represents an 8-bit hexadecimal value.
module literalExample;
endmodule
7. Operators:
• Verilog uses various operators like +, -, *, /, ==, !=, &&, ||, etc., for arithmetic and logical operations.
module operatorExample;
reg A = 1;
reg B = 0;
wire C;
endmodule
8. Strings:
module stringExample;
initial
$display("Hello, World");
initial
endmodule
9. Numbers:
• Verilog supports both integer and real numbers.
• Real numbers include decimal points or an exponent notation.
module numberExample;
endmodule