Hi. I am trying to randomize a varaible in an extended transaction through another class.
The baseclass: “transaction”:
class transaction extends uvm_sequence_item;
/*
some code
*/
the extended class “transaction_pd”:
class transaction_pd extends transaction;
rand int c_pd;
function new(string inst = "transaction_pd");
super.new(inst);
endfunction
`uvm_object_utils_begin(transaction_pd)
`uvm_field_int(c_pd,UVM_ALL_ON)
`uvm_object_utils_end
endclass
the calling for randomization class, “generator”:
class generator extends uvm_sequence#(transaction);
`uvm_object_utils(generator)
rand integer frames;
rand integer rows;
function new(string inst = "generator");
super.new(inst);
endfunction
virtual task body();
req = transaction::type_id::create("GEN_TRANS");
req.print();////req is transaction_pd type, thanks to the factory mechanizem.
for (int i=0; i<frames; i++) begin
for (int j=0; j<rows; j++) begin
start_item(req);
req.randomize() with {c_pd==j;frame==i;row==j;};
finish_item(req); //this will return after item_done from the driver.
end
end
endtask
endclass
The problem is that c_pd is “Undeclared identifier” when I’m trying to randomize it through the with clause. If I don’t do it so its working ok and c_pd is getting a random value, as you can see in the printed transaction_pd object:
# KERNEL: ------------------------------------------------------------------------------
# KERNEL: Name Type Size Value
# KERNEL: ------------------------------------------------------------------------------
# KERNEL: GEN_TRANS transaction_pd - @691
# KERNEL: start_act integral 1 'h1
# KERNEL: data_in da(integral) 70 -
# KERNEL: [0] integral 12 'heb1
# KERNEL: [1] integral 12 'h3ed
# KERNEL: [2] integral 12 'h7f0
# KERNEL: [3] integral 12 'hcc9
# KERNEL: [4] integral 12 'h271
# KERNEL: ... ... ... ...
# KERNEL: [65] integral 12 'h1ba
# KERNEL: [66] integral 12 'h6bf
# KERNEL: [67] integral 12 'he21
# KERNEL: [68] integral 12 'hc09
# KERNEL: [69] integral 12 'h1ee
# KERNEL: row_width integral 10 'h46
# KERNEL: movavgwin_param integral 2 'h1
# KERNEL: frame integral 32 'h0
# KERNEL: row integral 32 'h0
# KERNEL: **c_pd** integral 32 'h2bf09c4a
# KERNEL: begin_time time 64 55
# KERNEL: depth int 32 'd2
# KERNEL: parent sequence (name) string 3 gen
# KERNEL: parent sequence (full name) string 25 uvm_test_top.e.a.seqr.gen
# KERNEL: sequencer string 21 uvm_test_top.e.a.seqr
# KERNEL: ------------------------------------------------------------------------------
# KERNEL: ------------------------------------------------------------------------------
It seems to me that i don’t know something on the randomize function or about object oriented programming in this case.
Thanks.