dmitryl
1
Hi All,
Is there a way to cast/convert an enum type to a string?
My function receives a value of enum type. I want to $display the received value. How can I do so?
Will the following work (val_enum is a variable of enum type)?
$display(“Value: $0s”,val_enum);
Thank you!
In reply to dmitryl:
You can use “.name” method of enum to display the string value of enum.
function dispaly(my_enum_t my_enum);
$display("Value: $0s",my_enum.name);
endfunction
dmitryl
3
In reply to sharvil111:
Thanks! Where can I see what methods/properties are applicable to the enum types? I believe .name is one of them…
In reply to dmitryl:
In reply to sharvil111:
Thanks! Where can I see what methods/properties are applicable to the enum types? I believe .name is one of them…
In the IEEE Std 1800-2012 the SV LRM section 6.19.5 Enumerated type methods you can see the applicable methods.
HTH
-R