typedef enum {YES, NO} bool;
1. 将一些数字转换成enum;
e.g . bit test = 0;
bool u_bool;
u_bool = boll'(test);
2. 按照enum的名字来打印;
e.g . bit test = 0;
bool u_bool;
u_bool = boll'(test);
$display("bool name is:%s", u_bool.name); 打印结果为YES;
3. u_bool.first(); 返回第一个enum的值;
4. u_bool.last();
5. u_bool.num(), 返回enum的个数;
6. u_bool.next(); 返回下一个enum; 下一个的间隔可以传参,默认1;
typedef enum { red, green, blue, yellow } Colors;
Colors c = c.first;
forever begin
$display( "%s : %d\n", c.name, c );
if( c == c.last ) break;
c = c.next;
end