File: struct_access.sv

package info (click to toggle)
yosys 0.52-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 69,796 kB
  • sloc: ansic: 696,955; cpp: 239,736; python: 14,617; yacc: 3,529; sh: 2,175; makefile: 1,945; lex: 697; perl: 445; javascript: 323; tcl: 162; vhdl: 115
file content (43 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module dut();
typedef struct packed {
  logic a;
  logic b;
} sub_sub_struct_t;

typedef struct packed {
  sub_sub_struct_t c;
} sub_struct_t;

typedef struct packed {
  sub_struct_t d;
  sub_struct_t e;
} struct_t;

parameter struct_t P = 4'b1100;

localparam sub_struct_t f = P.d;
localparam sub_struct_t g = P.e;
localparam sub_sub_struct_t h = f.c;
localparam logic i = P.d.c.a;
localparam logic j = P.d.c.b;
localparam x = P.e;
localparam y = x.c;
localparam z = y.a;
localparam q = P.d;
localparam n = q.c.a;

always_comb begin
  assert(P == 4'b1100);
  assert(f == 2'b11);
  assert(g == 2'b00);
  assert(h == 2'b11);
  assert(i == 1'b1);
  assert(j == 1'b1);
  assert(x == 2'b00);
  assert(y == 2'b00);
  assert(x.c == 2'b00);
  assert(y.b == 1'b0);
  assert(n == 1'b1);
  assert(z == 1'b0);
end
endmodule