The problem I see is that the “am” object is not instanced. Yo could either instance it with a new or create, or you can declare in the class a static object. In that case, per 1800’2012 section 8.9, “The static class properties can be used without creating an object of that type.” Below are a couple of changes I made.
class address_check extends uvm_reg;
max.configure(this, 6, 8, "RO", 0, `UVM_REG_DATA_WIDTH'h170e>>8, 1, 1, 1);
max = max.value[5:0];
// Adding this
static int max_int=max.value[4:0];
...
endclass
module address();
reg [4:0]adr;
address_check am=new(); // added the new
initial begin
adr=address_check.max_int; // One option
adr = am.max.value[4:0]; // Another option, needed the new()
end
endmodule
8.9 Static class properties
The previous examples have only declared instance class properties. Each instance of the class (i.e., each object of type Packet) has its own copy of each of its six variables. Sometimes only one version of a variable is required to be shared by all instances. These class properties are created using the keyword static. Thus, for example, in the following case, all instances of a class need access to a common file descriptor:
class Packet ;
static integer fileID = $fopen( “data”, “r” );
Now, fileID shall be created and initialized once. Thereafter, every Packet object can access the file descriptor in the usual way:
Packet p;
c = $fgetc( p.fileID );
*** The static class properties can be used without creating an object of that type.
Thanks for your reply.
I tried the second option by adding new in the module but compiler is giving error.
I tried to take the instance of the class in another class and then accessing the value. But that also didn’t worked for me.
class address_check extends uvm_reg;
max.configure(this, 6, 8, “RO”, 0, `UVM_REG_DATA_WIDTH’h170e>>8, 1, 1, 1);
max = max.value[5:0];
…
endclass
class check extends uvm_reg;
address_check adr;
end class
module address();
reg [4:0]temp;
check chk = new();----------- in this part compiler giving error of unexpected =, if not doing a new am not able fetch the value.
initial begin
temp = chk.adr.max.value4:0];
end
endmodule
I was taking reference from LRM but in that I didn’t find, use of method new of class instance inside the module.
class C;
function new();
endfunction
static int x=10;
endclass
module m;
int y;
C c=new();
initial begin
y=c.x;
c=null;
y=c.x;
c=new();
c.x=8;
end
endmodule