user2692669
user2692669

Reputation: 461

Groups inside structs

Can I have groups inside a struct?

pseudo-code:

typedef struct {
     input_group {
             logic a;
     }
     output_group {
             logic b;
     }
} my_signals_list

Upvotes: 1

Views: 1332

Answers (1)

Tudor Timi
Tudor Timi

Reputation: 7573

Short answer: no.

If you want to have signals grouped like this, why not create a struct for the input group and a struct for your output group?

typedef struct {
  logic a;
} input_group_s;

typedef struct {
  logic b;
} output_group_s;

typedef struct {
  input_group_s input_group;
  output_group_s output_group;
} my_signals_list;

As Greg points out in the comments, you can also have nested struct definitions inside the main struct:

typedef struct {
  struct { logic a; } input_group;
  struct { logic b; } output_group;
} my_signals_list;

If you want to specify signals for a module in a nice encapsulated fashion, I would suggest using an interface, though.

Upvotes: 3

Related Questions