Hay!
I have used a post_randomize function in my sequence_item class.
Also I have used for loop, while loop, if statements inside it
i am using .randomize() inside a task in sequence class.
when i am running the post_randomize() function is not executing.
plz help me out this.
In reply to jd_jagdish:
Could you please show your sequence body task and the definition of the seq_item.
In reply to jd_jagdish:
Did you check the return value from the call to randomize()? post_randomize() does not get called if the solver fails.
In reply to chr_sue:
This is my code
//sequence_item class
class packet extends uvm_sequence_item;
//input signal that can be randomize
rand bit start_1;
rand bit ble;
rand bit cca;
// output logic signal that should not be randomize
logic result;
`uvm_object_utils_begin(packet)
`uvm_field_int(start_1,UVM_ALL_ON|UVM_DEC)
`uvm_field_int(ble,UVM_ALL_ON|UVM_DEC)
`uvm_field_int(cca,UVM_ALL_ON|UVM_DEC)
`uvm_object_utils_end
int cnt=0;
bit count=0;
constraint valid{
//start inside {[0:1]};
cca inside {[0:1]};
ble inside {[0:1]};
}
function void post_randomization();
while(cnt<4)
begin
if (count==1)
begin
start_1=1;
cca=0;
ble=0;
count=~count;
end
else
begin
start_1=0;
cca=0;
ble=0;
count=~count;
end
cnt=cnt+1;
end
if(cnt==4)
begin
count=1;
cnt=cnt+1;
end
else if(cnt>4)
begin
cca=1;
ble=1;
end
else
begin
cca=1;
ble=0;
end
end
endfunction
function new (string name="packet");
super.new(name);
endfunction
endclass:packet
//sequence class
class packet_sequence extends uvm_sequence#(packet);
`uvm_object_utils(packet_sequence)
bit start_1;
bit ble;
bit cca;
function new (string name="packet_sequence");
super.new(name);
endfunction
task body();
packet ref_pkt;
ref_pkt=packet::type_id::create("ref_pkt");
repeat(50)
begin
`uvm_create(req)
assert(ref_pkt.randomize with {ref_pkt.start_1==0;ref_pkt.ble==0;ref_pkt.cca==0;});
req.copy(ref_pkt);
start_1=req.start_1;
cca=req.cca;
ble=req.ble;
start_item(req);
req.print(uvm_default_line_printer);
finish_item(req);
`uvm_create(req)
assert(ref_pkt.randomize with {ref_pkt.start_1==1;ref_pkt.ble==0;ref_pkt.cca==1;});
req.copy(ref_pkt);
start_1=req.start_1;
cca=req.cca;
ble=req.ble;
start_item(req);
req.print(uvm_default_line_printer);
finish_item(req);
end
endtask
endclass:packet_sequence
In reply to jd_jagdish:
2 things:
(1) do you see the diagnostic messages (print) in your log-file?
(2) why you are using a copy (req) of your original data packet (ref_pkt)?
In reply to chr_sue:
yes i am getting the print messages in log file.
The “req” that i have used is not required. I simply used to check what’s happening.
In reply to jd_jagdish:
If you see the print messages from post_randomize it will be definitely executed.
I gues you are getting in the driver the ref_pkt instead of req.