SV
// UVM パッケージのインクルード
`include "uvm_pkg.sv"
// top モジュール
module tb_top ;
// UVM パッケージのインポート
import uvm_pkg::* ;
// UVM マクロのインクルード
`include "uvm_macro.svh"
// uvm_test のインクルード
`include "my_test.sv"
// initial
initial begin
run_test ( ) ;
end
endmodule
// my_test
// env class のインクルード
`include "my_env.sv"
// クラス定義。uvm_test を継承する
class my_test extends uvm_test ;
// Factory への登録
`uvm_component_utils ( my_test )
// env メンバーの宣言
my_env env ;
// new
function new ( string name = "my_test", uvm_component parent = null ) ;
super.new ( name, parent ) ;
endfunction
// build_phase : メンバーのインスタンス
function void build_phase ( uvm_phase phase ) ;
super.biuld_phase ( phase ) ;
env = my_env::type_id::create ( "my_env", this ) ;
endfunction
// run_phase : テストシナリオ
task run_phase ( uvm_phase phase ) ;
phase.raise_objection ( this ) ;
#100 ;
env.start = 1 ;
wait ( env.start == 0 ) ;
phase.drop_objection ( this ) ;
endtask
endclass
// my_test : 検証環境のトップ
// クラス定義。uvm_env を継承する
class my_env extends uvm_env ;
// start=1 のとき `uvm_info 実行
bit start ;
// Factory への登録
`uvm_component_utils ( my_env )
// new
function new ( string name = "my_env", uvm_component parent = null ) ;
super.new ( name, parent ) ;
endfunction
// run_phase : シミュレーション実行時の動作
// 実際には env の run_phase で何かをすることはない
task run_phase ( uvm_phase phase ) ;
forever begin
wait ( start == 1 ) ;
`uvm_info ( "tb_top", "Hello World", UVM_LOW )
#10 ;
start = 0 ;
end
endtask
endtask