首页 文章

声明一组枚举类型

提问于
浏览
1

我想做以下事情:

typedef enum {a, b, c} my_type_e;
typedef enum {receive, transmit} dir_e;

class my_class #(type my_type_e);
  my_type_e variable_name;
endclass

但我想使用dir_e作为索引使“variable_name”成为一个数组 . 例如

my_class class_h;
class_h.variable_name[rx] = a;

要么

my_class class_h;
class_h.variable_name[tx] = c;

那有意义吗?

1 回答

  • 1

    您想声明一个关联数组 .

    class my_class #(type my_type_e);
      my_type_e variable_name[dir_e];
    endclass
    
    my_class class_h;
    class_h.variable_name[receive] = a;
    

相关问题