|
|
|
|
|
|
|
|
|
|
|
|
Structure expressions
|
|
|
A structure expression (packed or unpacked) can be built from member expressions using braces and commas, with the members in declaration order. Replicate operators can be used to set the values for the exact number of members. Each member expression shall be evaluated in the context of an assignment to the type of the corresponding member in the structure. It can also be built with the names of the members. |
|
|
|
|
|
|
|
|
|
|
|
Example - struct expressions
|
|
|
|
|
|
1 module struct_expr_operator();
2
3 typedef struct {
4 int x;
5 int y;
6 } myStruct;
7
8 myStruct s1;
9 int k = 1;
10
11 initial begin
12 #1 s1 = '{1, 2+k};
13 // by position
14 #1 $display("Value of x = %g y = %g by position", s1.x, s1.y);
15 #1 s1 = '{x:2, y:3+k};
16 // by name
17 #1 $display("Value of s1 ", s1, " by name");
18 #1 $finish;
19 end
20
21 endmodule
You could download file struct_expr_operator.sv here
|
|
|
|
|
|
Simulator Output
|
|
|
|
|
|
Value of x = 1 y = 3 by position
Value of s1 2 4 by name
|
|
|
|
|
|
Tagged union expressions and member accesss
|
|
|
A tagged union expression (packed or unpacked) is expressed using the keyword tagged followed by a tagged union member identifier, followed by an expression representing the corresponding member value. For void members the member value expression is omitted. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|