26 November 2011

Verilog HDL: Operators, Number Specification, Underscore Characters, Strings, Identifiers and Keywords, Escaped Identifiers

Operators:

Unary          : Precede the operand; always comes left of the operand. Eg: a=~b;
Binary         : Appear between two operands. Eg: a=b&&c;
Conditional : Have two separate operators that separate three operands. Eg: a=b?c:d;

Number Specificaton:

Sized :

syntax:

Size             --> no. of bits in the number; only decimal
Base format --> for decimal : ‘d or ‘D
Hex :’h or ‘H
Binary : ‘b or ‘B
Octal : ‘o or ‘O

Number -> 0 to 9(if deci)
0 to F(if hex)
0 to 8(if oct)

Eg:
4‘b1011    //4 bit binary no.
12’habf      //12 bit hex no.
16’d255     //16 bit decimal no.

Unsized Numbers:

Numbers that are specified without are decimal numbers by default.

Eg:
23456     //32 bit decimal no. by default
‘hc3       //32 bit hex no. by default
‘o21       //32 bit oct no. by default

X or Z values:

X ---> denotes unknown value
Z ---> denotes a high impedance value

Eg:

12’h13X     //12 bit hex no.;4 LSBs are unknown
6’hx          //6 bit hex no.;all 6 bits are unknown
32’bz          //32 bit high impedance number

Negative Numbers:

Eg :

-6’d3         //8 bit negative no. stored as 2’s complement of 3
-6sd3        //used for performing signed integer math
4’d-2       //illegal specification : ‘-’ is not allowed between and

Underscore Characters:

An underscore character “-” is allowed anywhere in a number except the first character. Underscore characters are allowed only to improve readability of numbers and are ignored by Verilog.

Strings:

• Should be enclosed by double quotes
• Must be in a single line without carriage return
• Treated as a sequence of one byte ASCII values
Eg:        "This is asic-soc blog”    //is a string

Identifiers and Keywords:

• Special reserved identifiers
• Are in lowercase

Eg:

reg value;          //’reg’ is keyword; ‘value’ is an identifier

input clk;          //’input’ is a keyword; ‘clk’ is an identifier

Escaped Identifiers:

• Begin with a backslash(\) character
• End with whitespace(space, tab or newline)
• Neither the backslash nor the terminating whitespace is considered to be a part of the identifier
Eg:
\a+s+v+d

\**asic-soc-vlsi-design-blog**