Академический Документы
Профессиональный Документы
Культура Документы
1 Introduction (informative)
The SystemVerilog operators are a combination of Verilog and C operators. In bot
h languages, the type and
size of the operands is fixed, and hence the operator is of a fixed type and siz
e. The fixed type and size of operators
is preserved in SystemVerilog. This allows efficient code generation.
Verilog does not have assignment operators or increment and decrement operators.
SystemVerilog includes the
C assignment operators, such as +=, and the C increment and decrement operators,
++ and --.
Verilog-2001 added signed nets and reg variables, and signed based literals. The
re is a difference in the rules
for combining signed and unsigned integers between Verilog and C. SystemVerilog
uses the Verilog-2001
rules.
7.2 Operator syntax
Syntax 7-1 Operator syntax (excerpt from Annex A)
7.3 Assignment operators
In addition to the simple assignment operator, =, SystemVerilog includes the C a
ssignment operators and special
bitwise assignment operators: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, <<<=, an
d >>>=. An assignment
operator is semantically equivalent to a blocking assignment, with the exception
that any left hand side index
expression is only evaluated once. For example:
a[i]+=2; // same as a[i] = a[i] +2;
In SystemVerilog, an expression can include a blocking assignment, provided it d
oes not have a timing control.
Note that such an assignment must be enclosed in parentheses to avoid common mis
takes such as using a=b
for a==b, or a|=b for a!=b.
if ((a=b)) b = (a+=1);
assignment_operator ::=
= | += | -= | *= | /= | %= | &= | |= | ^= | <<= | >>= | <<<= | >>>=
conditional_expression ::=
cond_predicate ? { attribute_instance } expression : expression
unary_operator ::=
+ | - | ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
binary_operator ::=
+ | - | * | / | % | == | != | === | !== | =?= | !?= | && | || | **
| < | <= | > | >= | & | | | ^ | ^~ | ~^ | >> | << | >>> | <<<
inc_or_dec_operator ::= ++ | -unary_module_path_operator ::=
! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
binary_module_path_operator ::=
== | != | && | || | & | | | ^ | ^~ | ~^
// from Annex A.6.2
// from Annex A.8.3
// from Annex A.8.6
Accellera
Extensions to Verilog-2001 SystemVerilog 3.1a
Copyright 2004 Accellera. All rights reserved. 63
a = (b = (c = 5));
The semantics of such an assignment expression are those of a function which eva
luates the right hand side,
casts the right hand side to the left hand data type, stacks it, updates the lef
t hand side and returns the stacked
value. The type returned is the type of the left hand side data type. If the lef
t hand side is a concatenation, the
type returned shall be an unsigned integral value whose bit length is the sum of