module test; typedef struct packed { logic [9:-1][2:0] a; ///REQ-EXT-10001, REQ-EXT-10004 } ST1; typedef struct { ST1 st1; ST1 st2[2:0]; }ST2; initial begin ST2 st2; st2 = '{2'b01, '{3'b1, 3'b0, 12'b1}}; $display("%", st2); //CHECK-001:'{a:'h1}, st2:'{'a:'h1}, '{a:'h0},'{a:h1}}} end endmodule if I modify ST1 st2[2:0]; to ST1 st2[3:0]; how should I modify the initial value of st2 in initial block?
时间: 2024-03-10 21:51:25 浏览: 47
C/C++中的结构体声明: struct 和 typedef struct 用法
If you modify the definition of ST2 to have an array of 4 ST1 elements, you can modify the initial value of st2 in the initial block as follows:
```
ST2 st2;
st2 = '{2'b01, '{4{3'b1}}, '{4{12'b1}}}; // initialize st2 with 2 ST1 elements of 3'b1 and 2 ST1 elements of 12'b1
$display("%", st2); //CHECK-001:'{a:'h1}, st2:'{'a:'h1}, '{a:'h1},'{a:'h1},'{a:h1}}}
```
This will initialize st2 with 2 ST1 elements of 3'b1 and 2 ST1 elements of 12'b1.
阅读全文