I have the following classes I’m trying to compile, and the compiler is giving errors when trying to unroll the `uvm_object_utils_begin macro:
class base_data extends uvm_sequence_item;
//constructor, etc. no macros here
endclass
class my_data extends base_data;
rand int val; uvm_object_utils_begin(my_data) //compiler complains this line have token '#' uvm_field_int(val, UVM_DEFAULT)
`uvm_object_utils_end
//constructors, constraints, etc
endclass
I’m pretty sure I read it somewhere on this site that user should write a wrapper class(base_data in this case) for UVM base classes, so what did I miss here?
Again and again: it is not recommended to use field macros for several reason. In some cases you might run into serious trouble!
But your problem is different. All classes you are using for constructing your testbench and your sequences/ sequence items you have to register with the factory. You are doing this by using
`uvm_object_utils().
Your problem is caused by your base class, which is not registered with the factory.
In reply to soloist_huaxin:
You are probably missing something in your example post. Your example compile fine for me once I add the import and include statements.
And what do you mean by a wrapper class? What you have shown is a simple extended class.
by “wrapper class” I mean the base_data class in my example, a class that I can add capabilities common for all extended objects(add header for display, that sort of thing) without touching the uvm_* classes.
I found what I missed - it’s due to compiling of packages. I put base_data class in one package, something like:
package base_pkg;
import uvm_pkg::*;
`include “base_data.vh”
endpackage
and I put my_data in another package like this:
package my_pkg;
import base_pkg::*;
`include “my_data.vh”
endpackage
I believe I missed “import uvm_pkg::*;” inside my_pkg…