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

Verilog タイムスケール スコープ

デフォルトのタイムスケール

Verilog モジュールはモジュールの前にタイムスケールが定義されていることが期待されますが、シミュレータはデフォルトのタイムスケールを挿入する場合があります。システム タスク $printtimescale を使用して、Verilog エラボレートされた階層の任意のスコープで適用される実際のタイムスケールを出力できます。 スコープを引数として受け入れます。

  
  
module tb;
	initial begin
		// Print timescale of this module
		$printtimescale(tb);
		// $printtimescale($root);
	end
endmodule

  

このモジュールの前にタイムスケール ディレクティブが配置されていなくても、シミュレーターは最終的に 1ns/1ns のタイムスケール値を適用したことを確認してください。

シミュレーションログ
xcelium> run
Time scale of (tb) is  1ns /  1ns
xmsim: *W,RNQUIE: Simulation is complete.

標準タイムスケール スコープ

デフォルトでは、ファイルに配置されたタイムスケール ディレクティブは、別のタイムスケール ディレクティブが定義されるまで、ディレクティブに続くすべてのモジュールに適用されます。

  
  
`timescale 1ns/1ps

module tb;
  des m_des();
  alu m_alu();
  
  initial begin
    $printtimescale(tb);
    $printtimescale(tb.m_alu);
	$printtimescale(tb.m_des);
  end
endmodule

module alu;
  
endmodule

`timescale 1ns/10ps

module des;
  
endmodule

  

上記の例では、des のモジュール定義の前にディレクティブが配置されているため、tb と alu は 1ns/1ns のタイムスケールになりますが、des は 1ns/10ps のタイムスケールになります

シミュレーションログ
xcelium> run
Time scale of (tb) is  1ns /  1ps
Time scale of (tb.m_alu) is  1ns /  1ps
Time scale of (tb.m_des) is  1ns /  10ps
xmsim: *W,RNQUIE: Simulation is complete.

Verilog ファイル間の範囲

`include を使用して、他のファイルを現在のファイルに含めることができます これはプリプロセッサ ディレクティブであり、コンパイル前にインクルード ファイルの内容をコンパイラに配置させます。したがって、これは単に他のファイルの内容全体をこのメイン ファイルに貼り付けることと同じです。

  
  
// main.v
`timescale 1ns/1ps

module tb;
  des m_des();
  alu m_alu();
  
  initial begin
    $printtimescale(tb);
    $printtimescale(tb.m_alu);
	$printtimescale(tb.m_des);
  end
endmodule

`include "file_alu.v"
`include "file_des.v"

// file_alu.v
module alu;
endmodule

// file_des.v
`timescale 1ns/10ps

module des;
  
endmodule

  

結果が前の例とまったく同じであることを確認してください。 alu は 1ns/1ps のタイムスケールを取得します。これは、別のファイルに配置したにもかかわらず、コンパイラが alu 定義を見つけるまで有効なままだった最後のディレクティブであるためです。 des は、ディレクティブが定義前に置き換えられたため、1ns/10ps のタイムスケールを取得します。

シミュレーションログ
xcelium> run
Time scale of (tb) is  1ns /  1ps
Time scale of (tb.m_alu) is  1ns /  1ps
Time scale of (tb.m_des) is  1ns /  10ps
xmsim: *W,RNQUIE: Simulation is complete.

ファイルを交換するとタイムスケールが変わる可能性があります

ファイルを含める順序は、タイムスケール ディレクティブの再定義において重要な役割を果たします。これは、以下の例で明らかです。

  
  
// main.v
`timescale 1ns/1ps

module tb;
  des m_des();
  alu m_alu();
  
  initial begin
    $printtimescale(tb);
    $printtimescale(tb.m_alu);
	$printtimescale(tb.m_des);
  end
endmodule

// NOTE! Swapped order of inclusion
`include "file_des.v"
`include "file_alu.v"

// file_alu.v
module alu;
endmodule

// file_des.v
`timescale 1ns/10ps

module des;
  
endmodule

  

モジュール alu が 1ns/10ps のタイムスケールを取得することを確認してください。

シミュレーションログ
xcelium> run
Time scale of (tb) is  1ns /  1ps
Time scale of (tb.m_alu) is  1ns /  10ps
Time scale of (tb.m_des) is  1ns /  10ps
xmsim: *W,RNQUIE: Simulation is complete.

これは、そのファイル内のすべてのモジュールがファイルのインクルードに関係なく正しいタイムスケールを想定するように、ファイルの先頭にタイムスケール ディレクティブを配置する理由の 1 つです。

ただし、このアプローチでは、各ファイルを変更せずに異なるタイムスケール精度 (斜めに続く値) でコンパイルすることが困難になる場合があります。多くのコンパイラとシミュレータには、すべてのモジュールに適用されるデフォルトのタイムスケール値をオーバーライドするオプションも用意されています。


Verilog

  1. Verilog チュートリアル
  2. Verilog 連結
  3. Verilog 割り当て
  4. Verilog ブロッキング &ノンブロッキング
  5. Verilog 関数
  6. Verilog タスク
  7. Verilog 階層参照スコープ
  8. Verilog クロック ジェネレーター
  9. Verilog 数学関数
  10. Verilog タイムフォーマット
  11. Verilog ファイルの IO 操作