有一個簡單的辦法,就是用disable語句,它可以kill程序也可以kill task,如果是kill task 那麼在該task裡面衍生的所有程序都會被kill。
task a(ref bit kill_en);
fork:error_chk
begin
.....error check processing
end
wait(kill_en == 1"b1);
disable a; ////kill this task a, and this will kill all the threads spawned in this task.
join_none
endtask
task b(ref bit kill_en);
kill_en = 1"b0 ;
......
if(satisfy kill condition)
kill_en = 1"b1 ;
....
bit kill_en = 0 ;
task a(kill_en);
task 1..2 ...3...;
task b(kill_en);
.......
有一個簡單的辦法,就是用disable語句,它可以kill程序也可以kill task,如果是kill task 那麼在該task裡面衍生的所有程序都會被kill。
task a(ref bit kill_en);
fork:error_chk
begin
.....error check processing
end
begin
wait(kill_en == 1"b1);
disable a; ////kill this task a, and this will kill all the threads spawned in this task.
end
join_none
endtask
task b(ref bit kill_en);
kill_en = 1"b0 ;
......
if(satisfy kill condition)
kill_en = 1"b1 ;
......
endtask
....
bit kill_en = 0 ;
task a(kill_en);
task 1..2 ...3...;
task b(kill_en);
.......