begin-end/fork-join

Begin-end顺序执行

[例3]:parameterd=50; //声明d是一个参数

reg [7:0] r; //声明r是一个8位的寄存器变量

begin //由一系列延迟产生的波形

#d r = 'h35;

#d r = 'hE2;

#d r = 'h00;

#d r = 'hF7;

#d -> end_wave; //触发事件end_wave

End

块内的语句是按顺序执行的,即只有上面一条语句执行完后下面的语句才能执行。每条语句的延迟时间是相对于前一条语句的仿真时间而言的

fork-join并行执行

[例4]:fork

#50 r = 'h35;

#100 r = 'hE2;

#150 r = 'h00;

#200 r = 'hF7;

#250 -> end_wave; //触发事件end_wave.

join

在这个例子中用并行块来替代了前面例子中的顺序块来产生波形,用这两种方法生成的波形是一样

的。

块内每条语句的延迟时间是相对于程序流程控制进入到块内时的仿真时间的。

fork-join_none

it does not wait for any forked process is complete and thus starts execution statementsafter the join_none statement without waiting for forked process.

fork-join_any

it waits for al least one process to complete, before it starts executing statements following join_any statement.

Example:

initial begin
$display("@%0d: start fork...join_any example",$time);
#10 $display("@%0d: sequential after #10", $time);
fork
    $display("@%0d: parallel start", $time);
    #50 $display("@%0d: parallel after #50", $time);
    #10 $display("@%0d: parallel after #10", $time);
    begin
        #30 $display("@%0d: sequential after #20", $time);
        #10 $display("@%0d: sequential after #10", $time);
    end
join_any
$display("@%0d: after join_any", $time);
#80 $display("@%0d: final after #80", $time);
end
Note in the results, the statement $display("after join_any") completes after the first statement in the parallel block.





你可能感兴趣的:(FPGA)