Process Control in System Verilog
module test;
task automatic do_n_way( int N );
process job[] = new [N];
foreach(job[j]) begin
fork
automatic int k = j;
begin
job[k] = process::self();
#(5+k);
end
join_none
end
foreach(job[j]) // wait for all processes to start
wait( job[j] != null);
$display("All JOB Started !!",$time);
job[1].suspend();
job[1].resume();
job[1].await();
foreach(job[j]) begin
if(job[j].status != process::FINISHED )
job[j].kill();
end
endtask
initial begin
do_n_way(3);
end
endmodule
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////Fork JoinExample///////////////////////////
//////////////////////////////////////////////////////////////////////////
module test;
task automatic do_n_way( int N );
process job[] = new [N];
foreach(job[j]) begin
fork
automatic int k = j;
begin
job[k] = process::self();
#(5+k);
end
join_none
end
foreach(job[j]) // wait for all processes to start
wait( job[j] != null);
$display("All JOB Done !!",$time);
job[1].suspend();
#15
job[1].resume();
job[0].await();
//job[1].await();
foreach(job[j]) begin
if(job[j].status != process::FINISHED )begin
$display("JOb[%0d] killed with status::%0d @%t",j,job[j].status,$time);
job[j].kill();
end
end
foreach(job[j]) begin
$display("JOb[%0d] status ::%0d @%t",j,job[j].status,$time);
end
endtask
initial begin
fork //Try using without fork
do_n_way(3);
do_n_way(4);
join
end
endmodule
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////AWAIT Example///////////////////////////
//////////////////////////////////////////////////////////////////////////
module test;
task automatic do_n_way( int N );
process job[] = new [N];
foreach(job[j]) begin
fork
automatic int k = j;
begin
job[k] = process::self();
#(5+k);
end
join_none
end
foreach(job[j]) // wait for all processes to start
wait( job[j] != null);
$display("All JOB Done !!",$time);
job[1].suspend();
#15
job[1].resume();
job[0].await();
job[1].await();
foreach(job[j]) begin
if(job[j].status != process::FINISHED )begin
$display("JOb[%0d] killed with status :: ",j,job[j].status);
job[j].kill();
end
end
foreach(job[j]) begin
$display("JOb[%0d] status :: ",j,job[j].status);
end
endtask
initial begin
do_n_way(3);
end
endmodule
module test;
task automatic do_n_way( int N );
process job[] = new [N];
foreach(job[j]) begin
fork
automatic int k = j;
begin
job[k] = process::self();
#(5+k);
end
join_none
end
foreach(job[j]) // wait for all processes to start
wait( job[j] != null);
$display("All JOB Started !!",$time);
job[1].suspend();
job[1].resume();
job[1].await();
foreach(job[j]) begin
if(job[j].status != process::FINISHED )
job[j].kill();
end
endtask
initial begin
do_n_way(3);
end
endmodule
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////Fork JoinExample///////////////////////////
//////////////////////////////////////////////////////////////////////////
module test;
task automatic do_n_way( int N );
process job[] = new [N];
foreach(job[j]) begin
fork
automatic int k = j;
begin
job[k] = process::self();
#(5+k);
end
join_none
end
foreach(job[j]) // wait for all processes to start
wait( job[j] != null);
$display("All JOB Done !!",$time);
job[1].suspend();
#15
job[1].resume();
job[0].await();
//job[1].await();
foreach(job[j]) begin
if(job[j].status != process::FINISHED )begin
$display("JOb[%0d] killed with status::%0d @%t",j,job[j].status,$time);
job[j].kill();
end
end
foreach(job[j]) begin
$display("JOb[%0d] status ::%0d @%t",j,job[j].status,$time);
end
endtask
initial begin
fork //Try using without fork
do_n_way(3);
do_n_way(4);
join
end
endmodule
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////AWAIT Example///////////////////////////
//////////////////////////////////////////////////////////////////////////
module test;
task automatic do_n_way( int N );
process job[] = new [N];
foreach(job[j]) begin
fork
automatic int k = j;
begin
job[k] = process::self();
#(5+k);
end
join_none
end
foreach(job[j]) // wait for all processes to start
wait( job[j] != null);
$display("All JOB Done !!",$time);
job[1].suspend();
#15
job[1].resume();
job[0].await();
job[1].await();
foreach(job[j]) begin
if(job[j].status != process::FINISHED )begin
$display("JOb[%0d] killed with status :: ",j,job[j].status);
job[j].kill();
end
end
foreach(job[j]) begin
$display("JOb[%0d] status :: ",j,job[j].status);
end
endtask
initial begin
do_n_way(3);
end
endmodule
No comments:
Post a Comment