I have the following base class:
class base_transaction extends uvm_sequence_item();
int rand_int_list [$];
bit rand_bit_list [$];
bit [31:0] data [$];
//uvm_object_utils\
`uvm_object_utils(base_transaction)
//constructor
function new(string name = "base_transaction");
super.new(name);
endfunction: new
//add to list functions
function void add_rand_int(ref int mem);
$display("array size is %d before push", rand_int_list.size());
rand_int_list.push_back(mem);
$display("array size is %d after push", rand_int_list.size());
//rand_int_list[rand_int_list.size()] = mem;
endfunction: add_rand_int
function void add_rand_bit(ref bit mem);
// rand_bit_list.
rand_bit_list[rand_bit_list.size()] = mem;
endfunction: add_rand_bit
//function my_randomize
function int my_randomize(int seed);
int temp, success;
if (rand_int_list.size > 0)
begin
for (int i = 0; i < rand_int_list.size(); i++)
begin
// temp = $urandom_range(1,11);
temp = (($urandom(seed)) + 1);
rand_int_list[i] = temp - 1;
success = (temp && success);
end
if(success == 0)
return 0;
end
if (rand_bit_list.size() > 0)
begin
for (int i = 0; i < rand_bit_list.size(); i++)
begin
// temp = $urandom_range(1,11);
temp = (($urandom(seed)) + 1);
rand_bit_list[i] = temp - 1;
success = (temp && success);
end
if(success == 0)
return 0;
else
return 1;
end
endfunction: my_randomize
endclass: base_transaction
I have the following class which extend the base class:
class tx_transaction extends base_transaction;
bit [15:0] data_xi;
bit [15:0] data_xq;
int mem_int = 2, mem_int_a = 5; //TODO- delete
//uvm_object_utils\
`uvm_object_utils(tx_transaction)
//constructor
function new(string name = "tx_transaction");
super.new(name);
endfunction: new
function void add_rand_macro();
add_rand_int(mem_int);
add_rand_int(mem_int_a);
endfunction: add_rand_macro
//TODO - DELETE
function void foo();
$display("rand mem int: %d %d", mem_int, mem_int_a);
endfunction: foo
endclass: tx_transaction
I call the following function from the sequence (tx_trx - is tx_transaction instance, and i is iterator):
tx_trx.add_rand_macro();
tx_trx.my_randomize(i+1);
tx_trx.foo();
For some reason the foo function display allwas 2 5 (memt_int, mem_int_a), though those values are updated by the my_randomize function (which random the array which the member class are passed by ref)