i have a randc variable "index" in c_base. i've two new classes (class_1 & class_2) extended from base_class. when randomizing the extended class objects, i observed the variable "index" is having same values in C1 & C2 objects. Below is the simplified copy of my code:
class c_base extends uvm_sequence_item;
rand bit [9:0] index;
`uvm_object_utils_begin(c_base)
`uvm_field_int(index,UVM_ALL_ON)
`uvm_object_utils_end
function new(string name="c_base");
super.new(name);
endfunction
endclass
class class_1 extends c_base;
rand bit [3:0] var1;
rand bit [7:0] var2;
rand bit [3:0] var3;
`uvm_object_utils_begin(class_1)
`uvm_field_int(var1,UVM_ALL_ON)
`uvm_field_int(var2,UVM_ALL_ON)
`uvm_field_int(var3,UVM_ALL_ON)
`uvm_object_utils_end
function new(string name="class_1");
super.new(name);
endfunction
endclass
class class_2 extends c_base;
rand bit [4:0] var4;
rand bit [10:0] var5;
`uvm_object_utils_begin(class_2)
`uvm_field_int(var4,UVM_ALL_ON)
`uvm_field_int(var5,UVM_ALL_ON)
`uvm_object_utils_end
function new(string name="class_2");
super.new(name);
endfunction
endclass
module tst;
class_1 c1[];
class_2 c2[];
c_base q[$];
initial begin
c1=new[20];
c2=new[20];
foreach(c1[i]) begin
c1[i]=class_1::type_id::create($sformatf("c1_%0d",i));
assert( c1[i].randomize() );
q.push_back(c1[i]);
end
foreach(c2[i]) begin
c2[i]=class_2::type_id::create($sformatf("c2_%0d",i));
assert( c2[i].randomize() );
q.push_back(c2[i]);
end
q.sort with(item.index);
$display("---------------");
$display(" Index Name ");
$display("---------------");
for(int i=0; i<q.size();i++) begin
$display(" x%h %s",q[i].index,q[i].get_name());
end
end
endmodule
EdaPlayground link: https://www.edaplayground.com/x/3pk2
For the above code in EdaPlayground, I'm creating 20 objects for both classes and got same index value (x398, x2d7) for a class_1 & class_2 objects.
What I expected was, the index value of all objects will be unique until all combinations are exercised.
My intention is to use "index" as the location of SRAM address to store the packed data of each extended class object.
Is this the expected behavior in SimVision15.20?? Can't i get unique values for variable index?