Compilation error with invalid type and undefined variables

Hi, guys,

I am using questasim 10.6c to test the example from chapter 10 of “UVM Primer”. I got compilation error:_*** Error: D:\Document\questa_prj\tinlyalu_oop\coverage.svh(23): Invalid type ‘operation_t’. Please check the type of the variable ‘op_set’.
** Error: D:\Document\questa_prj\tinlyalu_oop\coverage.svh(27): (vlog-2730) Undefined variable: ‘op_set’.**_*when I compiler the sv header file which has class definition. All of the header files have the similar problem. The enum data type “opeartion_t” is defined in a separate package file and the package file also includes those four header files.
So could anyone kindly tell me why the data type is not visible in the class? Thank you so much.

The package file is:

package tinyalu_pkg;
  typedef enum bit[2:0] {no_op  = 3'b000,
                               add_op = 3'b001, 
                               and_op = 3'b010,
                               xor_op = 3'b011,
                               mul_op = 3'b100,
                               rst_op = 3'b111} operation_t;      


`include "coverage.svh"
`include "tester.svh"
`include "scoreboard.svh"
`include "testbench.svh"
endpackage : tinyalu_pkg

and one of the header file is:

class coverage;
  
   virtual tinyalu_bfm bfm;


   byte         unsigned        A;
   byte         unsigned        B;
   operation_t  op_set;

   covergroup op_cov;

      coverpoint op_set {
         bins single_cycle[] = {[add_op : xor_op], rst_op,no_op};
         bins multi_cycle = {mul_op};

         bins opn_rst[] = ([add_op:mul_op] => rst_op);
         bins rst_opn[] = (rst_op => [add_op:mul_op]);

         bins sngl_mul[] = ([add_op:xor_op],no_op => mul_op);
         bins mul_sngl[] = (mul_op => [add_op:xor_op], no_op);

         bins twoops[] = ([add_op:mul_op] [* 2]);
         bins manymult = (mul_op [* 3:5]);


      }

   endgroup
   /* other code*/
endclass

In reply to Joker0208:

Your code compiles ok for me, so there is likely something in your actual code that is different then what you posted.

If you can post a complete example that others can run which exhibits the exact error you are seeing, perhaps more assistance can be provided.

Also, you mention ‘compile the sv header file’, which doesn’t make sense. If you are compiling the package, you don’t need to compile the individual header files.

In reply to cgales:

In reply to Joker0208:
Your code compiles ok for me, so there is likely something in your actual code that is different then what you posted.
If you can post a complete example that others can run which exhibits the exact error you are seeing, perhaps more assistance can be provided.
Also, you mention ‘compile the sv header file’, which doesn’t make sense. If you are compiling the package, you don’t need to compile the individual header files.

The code is exactly the same with the GitHub code, the link is Your text to link here….
Now I move the enum type definition to another package and import it to the header file, then it get compiled. So I am suspecting the header file cannot see the definition of ‘operation_t’ to get it compiled.

In reply to Joker0208:

Please post the command you are using to compile your code.

In reply to cgales:
I did not use the command line to compile the code. I just compile all in the project section.

In reply to Joker0208:

Look at the run.do script in the example you pointed to for assistance in compiling the code.

In reply to cgales:

Thank you so much. Now it works with the script