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.
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
- SystemVerilog Assertions Handbook 3rd Edition, 2013 ISBN 878-0-9705394-3-6
- A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
- Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
- Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 0-9705394-2-8
- Component Design by Example ", 2001 ISBN 0-9705394-0-1
- VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
- VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115