In reply to dave_59:
Hi dave,
// tried to implement sema concept but not working
module tb;
semaphore key = new(1);
task a1();
key.get(1);
$display($realtime, " a1 start");
key.put(1);
$display($realtime, " a1 finished");
endtask
task a2();
key.get(1);
$display($realtime, " a2 start");
key.put(1);
$display($realtime, " a1 finished");
endtask
task a3();
key.get(1);
$display($realtime, " a3 start");
key.put(1);
$display($realtime, " a1 finished");
endtask
task a4();
key.get(1);
$display($realtime, " a4 start");
key.put(1);
$display($realtime, " a1 finished");
endtask
task a5();
key.get(1);
$display($realtime, " a5 start");
key.put(1);
$display($realtime, " a1 finished");
endtask
initial begin
fork
a1();
a2();
a3();
a4();
a5();
join_none
key.get(3);
begin
disable fork;
$display(" fork disabled");
end
end
endmodule