Groups inside structs

只愿长相守 提交于 2019-12-11 13:23:03

问题


Can I have groups inside a struct?

pseudo-code:

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

回答1:


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.



来源:https://stackoverflow.com/questions/26275803/groups-inside-structs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!