工業製造
産業用モノのインターネット | 工業材料 | 機器のメンテナンスと修理 | 産業プログラミング |
home  MfgRobots >> 工業製造 >  >> Industrial programming >> Verilog

Verilog インターおよびイントラ割り当て遅延

Verilog 遅延ステートメントでは、代入演算子の左側または右側に遅延を指定できます。

割り当て間の遅延

  
  
	// Delay is specified on the left side
	#<delay> <LHS> = <RHS>

  

相互割り当て delay ステートメントには、代入演算子の LHS に遅延値があります。これは、ステートメント自体が後に実行されることを示します 遅延は期限切れになり、遅延制御の最も一般的に使用される形式です。

  
  
module tb;
  reg  a, b, c, q;
  
  initial begin
    $monitor("[%0t] a=%0b b=%0b c=%0b q=%0b", $time, a, b, c, q);
    
    // Initialize all signals to 0 at time 0
    a <= 0;
    b <= 0;
    c <= 0;
    q <= 0;
    
    // Inter-assignment delay: Wait for #5 time units
    // and then assign a and c to 1. Note that 'a' and 'c'
    // gets updated at the end of current timestep
    #5  a <= 1;
    	c <= 1;
    
    // Inter-assignment delay: Wait for #5 time units
    // and then assign 'q' with whatever value RHS gets
    // evaluated to
    #5 q <= a & b | c;

    #20;
  end
  
endmodule

  

ステートメントが 10 時間単位で評価され、a、b、c の組み合わせである RHS が 1 に評価されるため、q は時間 10 単位で 1 になることに注意してください。

シミュレーションログ
xcelium> run
[0] a=0 b=0 c=0 q=0
[5] a=1 b=0 c=1 q=0
[10] a=1 b=0 c=1 q=1
xmsim: *W,RNQUIE: Simulation is complete.

割り当て内の遅延

  
  
	// Delay is specified on the right side
	<LHS> = #<delay> <RHS>

  

任務内 delay は、代入演算子の RHS に遅延がある場合です。これは、ステートメントが評価され、RHS のすべてのシグナルの値が最初に取得されることを示します。次に、だけ結果の信号に割り当てられます 遅延が期限切れになります。

  
  
module tb;
  reg  a, b, c, q;
  
  initial begin
    $monitor("[%0t] a=%0b b=%0b c=%0b q=%0b", $time, a, b, c, q);
  
	// Initialize all signals to 0 at time 0  
    a <= 0;
    b <= 0;
    c <= 0;
    q <= 0;
    
    // Inter-assignment delay: Wait for #5 time units
    // and then assign a and c to 1. Note that 'a' and 'c'
    // gets updated at the end of current timestep
    #5  a <= 1;
    	c <= 1;

    // Intra-assignment delay: First execute the statement
    // then wait for 5 time units and then assign the evaluated
    // value to q
    q <= #5 a & b | c;
    
    #20;
  end
endmodule

  

q への代入がログにないことに注意してください!

シミュレーションログ
xcelium> run
[0] a=0 b=0 c=0 q=0
[5] a=1 b=0 c=1 q=0
xmsim: *W,RNQUIE: Simulation is complete.

これは、5 時間単位で a と c がノンブロッキング ステートメントを使用して割り当てられるためです。 ノンブロッキングの動作 ステートメントは RHS が評価されるようなものですが、その時間ステップの最後にのみ変数に割り当てられます。

そのため、a と c の値は 1 に評価されますが、次のノンブロッキング ステートメント (q のステートメント) が実行されたときにはまだ割り当てられていません。したがって、q の RHS が評価されると、a と c にはまだ古い値の 0 が含まれているため、$monitor になります。 ステートメントを表示するための変更を検出しません。

変化を観察するために、a と c への割り当てステートメントをノンブロッキングからブロッキングに変更してみましょう。

  
  
	...
	
	// Non-blocking changed to blocking and rest of the
	// code remains the same
    #5  a = 1;
    	c = 1;
    
    q <= #5 a & b | c;
    
   	...

  
シミュレーションログ
xcelium> run
[0] a=0 b=0 c=0 q=0
[5] a=1 b=0 c=1 q=0
[10] a=1 b=0 c=1 q=1
xmsim: *W,RNQUIE: Simulation is complete.


Verilog

  1. Verilog の紹介
  2. Verilog チュートリアル
  3. Verilog 構文
  4. Verilog 連結
  5. Verilog 割り当て
  6. Verilog ブロッキング &ノンブロッキング
  7. Verilog 関数
  8. Verilog タスク
  9. Verilog 遅延制御
  10. Verilog ゲート遅延
  11. Verilog クロック ジェネレーター