ENUMERR

Compilation Errors

I like my compilation build to be free from warnings. Here’s how to solve this warning.

myObj.pixelValue[0] = 0;

                                 |

ncvlog: *W,ENUMERR (myChecker.sv,528|34): This assignment is a violation of SystemVerilog strong typing rules for enumeration datatypes.


pixelValue is an enumerated data type like :

typedef enum reg [1:0] {

PV_ONE      = 2’h0,

PV_THREE  = 2’h1,

PV_FIVE     = 2’h2,

PV_TEN      = 2’h3

} e_pixel;

e_pixel pixelValue;


Solution :

I have to cast the integer value 2 to e_pixel format before I can assign it to the enumeration variable. It’s called strong typing.

pixelValue = e_pixel’ (2);

but

pixelValue = PV_THREE;                        // Correct and valid