flasher07 Posted May 13, 2016 Report Share Posted May 13, 2016 Hi , Please help me the following code, module fork_join_any_process(); int me[3]; task automatic print_value; input [7:0] value; input [7:0] delay; begin $display("Waiting Passed value %d",value); #(delay) $display("@%g Passed Value %d Delay %d", $time, value, delay); end endtask initial begin me[0] = 1; me[1] = 2; me[2] = 3; repeat(5) begin fork foreach(me[i]) fork automatic int id = me[i]; print_value (10+id,id); join_none foreach(me[i]) fork automatic int id = me[i]; print_value (20+id,id); join_none // wait fork; join_any disable fork; $display(" Disable Fork "); // for (int i = 0 ; i < 3 ;i++) begin // fork // print_value (10+i,7); // print_value (20+i,7); // print_value (30+i,7); // join_any // if ( i < 2 ) begin // print_value (50+i,7); // print_value (60+i,7); // end // end end $display("@%g Came out of fork-join", $time); #20 $finish; end endmodule Expecting the output as: Waiting Passed value 11Waiting Passed value 12Waiting Passed value 13Waiting Passed value 21Waiting Passed value 22Waiting Passed value 23@1 Passed Value 11 Delay 1Disable forkWaiting Passed value 11Waiting Passed value 12Waiting Passed value 13Waiting Passed value 21Waiting Passed value 22Waiting Passed value 23@1 Passed Value 11 Delay 1 But unable to get that, Please help me with this. Thanks a lot !! Quote Link to comment Share on other sites More sharing options...
dave_59 Posted May 13, 2016 Report Share Posted May 13, 2016 You use fork/join_any statements when you want to create a number of time consuming processes and block waiting for one of them to finish. You create two processes, but they do not bloc - the finish immediately because they have fork/join_none statements in them . What you probably meant was something like initial begin me[0] = 1; me[1] = 2; me[2] = 3; repeat(5) begin : repeat_loop fork begin : b1 foreach(me) fork automatic int id = me; print_value (10+id,id); join_none wait fork; end : b1 begin :b2 foreach(me) fork automatic int id = me; print_value (20+id,id); join_none wait fork; end : b2 join_any disable fork; $display(" Disable Fork "); end :repeat_loop $display("@%g Came out of fork-join", $time); #20 $finish;end // initial begin karandeep963 and flasher07 2 Quote Link to comment Share on other sites More sharing options...
flasher07 Posted May 16, 2016 Author Report Share Posted May 16, 2016 Many Thanks for the help Dave !! This is what needed , I really appreciate your efforts. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.