1module assignment; 2 3 function int bar(); 4 return 0; 5 endfunction 6 7 // src/tlm2/uvm_tlm2_generic_payload.svh:494 8 string msg = $sformatf("GP miscompare between '%s' and '%s':\nlhs = %s\nrhs = %s", 9 bar(), 1, 2, 3); 10 11 // LRM 10.9.1 Array assignment patterns 12 bit unpackedbits [1:0] = '{1,1}; 13 int unpackedints [1:0] = '{1'b1, 1'b1}; 14 int y; 15 int unpackedints2 [1:0] = '{2 {y}}; 16 int n[1:2][1:3] = '{2{'{3{y}}}}; 17 18 struct {int a; time b;} abkey[1:0]; 19 abkey = '{'{a:1, b:2ns}, '{int:5, time:$time}}; 20 21 struct {int a; time b;} abkey_fun[1:0] = '{'{a:bar(), b:2ns}, '{int:5, time:$time}}; 22 23 // LRM 10.9.2 Structure assignment patterns 24 typedef struct { 25 int x; 26 int y; 27 } st; 28 int k = 1; 29 st s1 = '{1, 2+k}; // by position; 30 st s2 = '{x:2, y:3+k}; // by name 31 struct { int x; int y; } s3 = '{1, 2+k}; 32 struct { int x; int y; } s4 = '{x:2, y:3+k}; 33 34 st s5 = '{default:2}; 35 36 typedef struct { int a; shortreal b; } ab; // LRM 5.10 37 ab abkey[1:0] = '{'{a:1, b:1.0}, '{int:2, shortreal:2.0}}; 38 39 struct { 40 int A; 41 struct { 42 int B, C; 43 } BC1, BC2; 44 } ABC, DEF; 45 ABC = '{A:1, BC1:'{B:2, C:3}, BC2:'{B:4,C:5}}; 46 DEF = '{default:10}; 47 48 typedef struct { 49 logic [7:0] a; 50 bit b; 51 bit signed [31:0] c; 52 string s; 53 } sa; 54 sa s2 = '{int:1, default:0, string:""}; 55 56 // LRM 10.10 Unpacked array concatenation 57 int A3[1:3]; 58 A3 = {1, 2, 3}; // unpacked array concatenation: A3[1]=1, A3[2]=2, A3[3]=3 59 A3 = '{1, 2, 3}; // array assignment pattern: A3[1]=1, A3[2]=2, A3[3]=3 60 61 typedef int AI3[1:3]; 62 AI3 A3; 63 int A9[1:9]; 64 A3 = '{1, 2, 3}; 65 A9 = {A3, 4, 5, A3, 6}; // legal, gives A9='{1,2,3,4,5,1,2,3,6} 66 A9 = '{9{1}}; // legal, gives A9='{1,1,1,1,1,1,1,1,1} 67 // array concatenation 68 A9 = {A3, 4, AI3'{5, 6, 7}, 8, 9}; // legal, A9='{1,2,3,4,5,6,7,8,9} 69 70endmodule 71 72