In reply to bharath123:
It looks like you are coming form an e background. I would avoid using the event altogether and just call the task instead of using the event trigger.
Also, your last reply added more complexity that wasn’t in your original post. I’m sure your missing a lot more. Like, your tasks have no blocking statements. They should be functions if that is the case. If they do have blocking statements, then you need to show more code. Otherwise, this should work for you:
///////////////////////////////////////////////////////////////////////////////////////
module main;
class c;
rand bit [4:0] my_var;
bit local_var;
function void t_logic;
if(my_var < 20) begin
my_new;
$display("variable in range my_var=%d",my_var);
end
else
$display("variable out of range my_var=%d",my_var);
my_new();
endfunction:t_logic
function void my_new;
$display("my random variable is :%d",my_var);
endfunction:my_new
endclass
initial begin
c evc;
for(int i=1;i<10;i++) begin
evc=new();
$display("Inside repeat");
evc.randomize();
evc.t_logic();
end
end
initial begin
#1000 $finish;
end
endprogram
/////////////////////////////////////////////////////////////////////