In reply to AshishP:
Hi Dave,
On similar lines, can you explain what should be the ideal behavior for the below code (I was thinking disable fork should disable ff2, please clarify):
class a_bus_monitor;
bit my_event1;
int iter;
task my_monitor();
fork : ft1
forever begin:ff1
#5ns;
$display("Passed 5 ns now");
iter++;
if (iter == 20) begin
$display("Breaking because iter is 20");
break;
end
end
forever begin:ff2
@(my_event1);
$display("At time %0t found an event on my_event1 (= %0d)",$time,my_event1);
if (my_event1 == 0) begin
$display("Disabling fork now");
disable fork; // ???Should not this disable fork disable ff2???
end
end
join
endtask:my_monitor;
endclass
module top;
a_bus_monitor abm1;
initial begin: i1
abm1 = new();
fork:fm1
begin:fmf1
abm1.my_monitor();
end
begin:fmf2
#6ns;
abm1.my_event1 = 1;
#10ns;
abm1.my_event1 = 0;
#20ns;
abm1.my_event1 = 1;
#6ns;
abm1.my_event1 = 0;
end
join
$display("main fork has been joined");
end
endmodule
Questasim 10.3b gives below output: