*W, ENUMERR This assignment is a violation of SystemVerilog strong typing rules for enumeration datatypes

Hi guys,

I’m having this warning when I’m assigning an enumeration data type to a virtual interface variable that is also an enumeration datatype.
The warning is pointing on the code below:


s_vif.spi_mode <= ADDRESSABLE_MODE;

s_vif is a virtual interface.
spi_mode is an enumeration data type coming from a typedef.

May I know how to fix this warning?

Thanks.

In reply to Reuben:

Please show all declarations.

In reply to dave_59:

what is the warning you are getting?

In reply to Abhyudha:

Declaration inside env package where scoreboard is located:


typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;

Declaration inside virtual interface:


typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;

interface spi_vif();
  spi_mode_e spi_mode;
endinterface : spi_vif

Inside scoreboard:


spi_vif s_vif;

// Then uvm_config_db get here to get the virtual interface

// Then inside a virtual function void write
s_vif.spi_mode <= ADDRESSABLE_MODE;

Warning message is:
*W, ENUMERR This assignment is a violation of SystemVerilog strong typing rules for enumeration datatypes

You have written two different typedefs. You need to have one typedef in a package, and import it into both scopes.

Please see http://go.mentor.com/package-import-versus-include

In reply to dave_59:

Hi Dave,

Thanks for the suggestion.
I did some changes on the declaration and the warning has gone. However, there’s a new warning.
It says that “Disallowed virtual interface hierarchical reference object type” pointint to this code in
the scoreboard:


s_vif.spi_mode <= ADDRESSABLE_MODE;

The changes I did are below:


// spi_die_env_pkg
package spi_die_env_pkg;
  typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;

  import spi_agent_pkg::*; // spi_if is here and it is using spi_mode_e
  import sw_data_agent_pkg::*; // sw_data_if is here and it is using spi_mode_e

  // Environment components included here
endpackage : spi_die_env_pkg


`include "spi_if.sv" // Note that this interface is outside the package

package spi_agent_pkg;
  typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;

  typedef virtual spi_if spi_vif;

  // spi_agent components included here
endpackage : spi_agent_pkg


`include "sw_data_if.sv" // Note that this interface is outside the package

package sw_data_agent_pkg;
  typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;

  typedef virtual sw_data_if sw_data_vif;

  // sw_data_agent components included here
endpackage : sw_data_agent_pkg


// spi_if
interface spi_if();
  typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;
  
  spi_mode_e spi_mode = ADDRESSABLE_MODE;
endinterface : spi_if


// sw_data_if
interface sw_data_if();
  typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;
  
  spi_mode_e spi_mode = ADDRESSABLE_MODE;
endinterface : sw_data_if

If I remove the typedef in the spi_die_env_pkg, I’m having a compile error saying that the scoreboard can’t see spi_mode.
If I remove the typedef in the spi_agent_pkg, I’m having a compile error saying that the monitor can’t see spi_mode.
If I remove the typedef in the interface, I’m having a compile error saying that the interface can’t see spi_mode_e.

In reply to Reuben:

There should only be one typedef spi_mode_e in only one package. Any other package, interface, or module that needs that typedef needs to import the package with the typedef.

Also note that package imports do not chain like `include files. If you have package A that imports a package B, importing package A does not give you all the definitions in package B. There is an export mechanism to the chaining, but that is probably more complicated than just making sure you import all the necessary packages that are needed.

In reply to dave_59:

Hi Dave,

I changed my code again, this time I only put one typedef on a single package, and then imports
the spi_mode_e on the packages that will use it. But still, I’m having a compile error saying that spi_agent_pkg could not be bound and undeclared identifier to one of the members of enum.


// spi_die_env_pkg
package spi_die_env_pkg;

  import spi_agent_pkg::*; // Since spi_agent_pkg is imported, then typedef enum spi_mode_e is also under the scope of spi_die_env_pkg
  import sw_data_agent_pkg::*;

  // Environment components included here
endpackage : spi_die_env_pkg


`include "spi_if.sv" // Note that this interface is outside the package

package spi_agent_pkg;
  typedef enum {ADDRESSABLE_MODE, ROUND_ROBIN, DAISY_CHAIN} spi_mode_e;

  typedef virtual spi_if spi_vif;

  // spi_agent components included here
endpackage : spi_agent_pkg


`include "sw_data_if.sv" // Note that this interface is outside the package

package sw_data_agent_pkg;
  import spi_agent_pkg::spi_mode_e; // I imported it here to let the components of this agent to see this typedef enum

  typedef virtual sw_data_if sw_data_vif;

  // sw_data_agent components included here
endpackage : sw_data_agent_pkg


// spi_if
interface spi_if();
  import spi_agent_pkg::spi_mode_e;
  
  spi_mode_e spi_mode = ADDRESSABLE_MODE;
endinterface : spi_if


// sw_data_if
interface sw_data_if();
  import spi_agent_pkg::spi_mode_e;
  
  spi_mode_e spi_mode = ADDRESSABLE_MODE;
endinterface : sw_data_if

The compile errors are pointing to spi_if:
import spi_agent_pkg::spi_mode_e;

Error message: Package spi_agent_pkg could not be bound

In reply to Reuben:

Hi Dave,

I have solved it! =)
I need to fix the hierarchy of the inclusion of the packages before compiling it.
That’s the reason why spi_agent_pkg cannot be bounded.

What I did is, I created another package and I put all the typedef enum on it and then import it on the packages and interfaces
that will use that.

Thanks for your advice.