2043 1097 DOC Verilog Session 2
2043 1097 DOC Verilog Session 2
Identifiers
Identifiers are names given to objects so that can be referenced in the design.
▪Identifiers are made up of alphanumeric characters, the underscore( _ ) and dollar sign ( $ ).
▪Identifiers start with an alphanumeric character or an underscore.
Escaped Identifiers
▪If a keyword or special character has to be used in an identifier, such an identifier must be preceded by
the backslash ( \ ) character and terminate with whitespace (space, tab, or newline).
- Sized
<size>’<base format><number> e.g. 3’b101
- Unsized
’<base format><number> e.g. ’b101
▪Size: Specified in decimal only and represents NUMBER Of BITS in number. Unsized numbers default to a
compiler specific number of bits ( at least 32 bits ).
▪Base Format:
Represent the radix. Legal base formats are decimal (‘d or ‘D), hexadecimal (‘h or ‘H), binary (‘b or ‘B)
and octal (‘o or ‘O). Numbers, specified without a <base format> specification are decimal numbers by
default.
▪Number:
The number is specified as consecutive digits from 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. Only a subset of
these digits is legal for a particular base.
“Uppercase letters are legal for number specification.”
▪Negative numbers:
Negative numbers can be specified by putting a minus sign before the size for a constant number.
Size constants are always positive.
It is illegal to have a minus sign between < base format > and < number >.
E.g.
▪X or Z values:
Verilog has two symbols for unknown and high impedance values. An unknown value is denoted by an
‘x’. A high impedance value is denoted by ‘z’.
▪‘x’ or ‘z’ sets –
4 bits for a number in hexadecimal base.
3 bits for a number in octal base.
1 bit for a number in binary base.
▪If MSB of a number is 0, x, z the number is automatically extended to fill the most significant bits,
respectively, with 0, x, z.
▪If the MSB is 1, then it is also zero extended.
▪Underscore characters
▪An underscore character “_” is allowed anywhere in a number except the first character.
▪They are used only to increase readability and are ignored by Verilog.
E.g.
▪Question Marks:
▪A question mark “?” is Verilog HDL alternative for z in the context of numbers.
▪The ? Is used to enhance readability in the “casex” and “casez” statements.
- In casex and casez, all “z” values are treated as don’t care. Hence, to distinguish “z” in these
statements “?” is used.
- “?” is also used in context to the UDP with some different meaning.
Note: The size ALWAYS means the TOTAL NUMBER of bits in the number and has nothing to
do with the base specified.
endmodule statement