Hello all,
I’m new to SV and I encountered this error while learning about enums.
I understand that default data type of enum is int. But I’m not sure what is happening here.
Pardon my innocence! Hope you can help me out.
In code::1 I am obtaining the expected result
In code::2 Result is not as I expected
code::1 →
module enum_work;
//typedef enum integer {A, B, C} alphabets;
typedef enum {A, B, C} alphabets;
typedef enum {ADD, SUB, MUL, DIV, MOD} math_operations;
alphabets alpha;
math_operations math;
integer i;
initial begin
i = alpha;
$display("default alpha value - %d",alpha);
i++;
alpha = alphabets'(i);
$display("incremented alpha value - %d",alpha);
end
endmodule
This is the output of code::1
default alpha value - 0
incremented alpha value - 1
code::2 →
module enum_work;
typedef enum integer {A, B, C} alphabets;
//typedef enum {A, B, C} alphabets;
typedef enum {ADD, SUB, MUL, DIV, MOD} math_operations;
alphabets alpha;
math_operations math;
integer i;
initial begin
i = alpha;
$display("default alpha value - %d",alpha);
i++;
alpha = alphabets'(i);
$display("incremented alpha value - %d",alpha);
end
endmodule
This is the output of code::2
default alpha value - x
incremented alpha value - x