conditional_expression ::=
// from Annex
A.8.3
expression cond_predicate ? { attribute_instance } expression : expression
If any operand is real, the
result is real, except before the ? in the ternary operator. If no operand is real and any
operand is shortreal, the
result is shortreal.
If any operand,
except before the ? in the ternary operator, is real, the result is real. Otherwise, if any operand, except before the ? in
the ternary operator, is shortreal, the result is shortreal.
The following unary operators give the signedness of the operand: ~ ++ -- + -. All
other operators shall follow the same rules as Verilog for performing signed
and unsigned operations.
The rules for determining the signedness
of SystemVerilog expression types shall be the same as those for Verilog. A shortreal converted to an integer
by type coercion shall be signed.
typedef
struct {
logic
[7:0] a;
bit
b;
bit
signed [31:0] c;
string
s;
} sa;
sa s2;
initial
s2 = {bit[31:0]:1 int:1, default:0, string:""};
// set all to 0 except the
// array of bits to 1 and
// string to ""
initial #10 s1 = {default:’1, s
= : ""}; // set all to 1 except s to
""
typedef union tagged {
struct {
bit
[4:0] reg1, reg2, regd;
} Add;
union tagged {
bit
[9:0] JmpU;
struct {
bit
[1:0] cc,;
bit
[9:0] addr;
} JmpC;
} Jmp;
} Instr;
bind
+ function float float faddif(int, float
float);
bind
+ function float float faddfi(float float, int);
bind
+ function float float faddrf(real, float float);
bind
+ function float float faddrf(shortreal, float float);
bind
+ function float float faddfr(float float, real);
bind
+ function float float faddfr(float float, shortreal);
bind
+ function float float faddff(float float, float float);
bind
+ function float float fcopyf(float float); // unary +
bind
+ function float float fcopyi(int); // unary +
bind
+ function float float fcopyr(real); // unary +
bind
+ function float float fcopyr(shortreal); // unary +
float float A, B, C, D;
function float float fcopyi (int i);
float float o;
bind
= function float float fcopyi(int); // cast int to float
bind
= function float float fcopyr(real); // cast
real to float
bind
= function float float fcopyr(shortreal); // cast shortreal to
float
float float A, B;
bind
+ function float float faddff(float float, float float);
stream_expression ::=
expression [ with [ array_range_expression ] ]
| array_identifier [ with [ array_range_expression
] ]
stream_expression ::=
expression [ with [ array_range_expression ] ]
| array_identifier [ with [ array_range_expression
] ]
The array range expression within the
with construct must be of integral type and evaluate to
values that lie within the bounds of a fixed-size array, or to positive values
for dynamic arrays or queues. The array identifier expression
before the with can be
any one-dimensional unpacked array (including a queue). The expression within the with is
evaluated immediately before its corresponding array is streamed (i.e., packed
or unpacked). Thus, the expression can refer to data that is unpacked by the
same operator but before the array. If the expression refers to variables that
are unpacked after the corresponding array (to the right of the array) then the
expression is evaluated using the previous values of the variables.
When used within the context of an unpack operation and the array-identifier designates array is a
variable-sized array, the array it shall be resized to accommodate the range
expression. If the array-identifier designates
array is a
fixed-sized array and the range expression evaluates to a range outside the
extent of the array, only the range that lies within the array is unpacked and
an error is generated. If the range expression evaluates to a range smaller
than the extent of the array (fixed or variable sized), only the specified items
are unpacked into the designated array locations; the remainder of the array is
unmodified.
In the example above, the pack operation could have
been written as either:
q
= {<<bytebyte{p.header, p.len, p.payload with [0 +: p.len], p.crc}};
or
q
= {<<bytebyte{p.header, p.len, p.payload with [0 : p.len-1], p.crc}};
or
q
= {<<bytebyte{p}};
cond_predicate ::= // from Annex A.6.6
expression_or_cond pattern expression_or_cond_pattern { &&
expression_or_cond_pattern }