Vengineerの妄想(準備期間)

人生は短いけど、長いです。人生を楽しみましょう!

UVM 1.0 : examples/simple/hello_world (その5)


トップのクラス(top.sv)は、次のようになっています。
    class top extends uvm_component;  // uvm_componentを継承する

      producer #(packet) p1;          // producerをpacketをテンプレートとして生成する
      producer #(packet) p2;          // producerをpacketをテンプレートとして生成する

      // TLM用のFIFO(uvm_tlm_fifo)をpacketをテンプレートとして生成する
      uvm_tlm_fifo #(packet) f;

      consumer #(packet) c;           // consumerをpacketをテンプレートとして生成する

      `uvm_component_utils(top)       // set_config_xxx/get_config_xxxのためのおまじない

      // newで各インスタンスを生成し、インスタンス間をuvm_tlm_fifo(f)で接続する。
      function new (string name, uvm_component parent=null);

        super.new(name,parent);

        p1 = new("producer1",this);   // producer p1 を生成
        p2 = new("producer2",this);   // producer p2 を生成

        f  = new("fifo",this);        // uvm_tlm_file f を生成

        c  = new("consumer",this);    // cosumer c を生成
 
        p1.out.connect( c.in );                   // p1.out を c.in に接続
        // p2.out を f.blocking_put_export に接続 
        p2.out.connect( f.blocking_put_export );  
        c.out.connect( f.get_export );            // c.out  を f.get_export に接続

      endfunction

      // run_test関数を実行したときに呼ばれる
      task run_phase(uvm_phase phase);  

        phase.raise_objection(this);  // raise_objectionは、drop_objectionとペアで使う
        uvm_top.print_topology();     // 階層全体の情報を表示する
        #1us;
        phase.drop_objection(this);   // raise_objectionは、drop_objectionとペアで使う

      endtask

    endclass
この記述をもっとUVMらしく記述するなら、次のようにします。
    // super.newだけ!
    function new (string name, uvm_component parent=null);
      super.new(name,parent);
    endfunction

    // 各インスタンスは、build_phase関数で生成する
    function void build_phase( uvm_phase phase );
      p1 = new("producer1",this);
      p2 = new("producer2",this);
      f  = new("fifo",this);
      c  = new("consumer",this);
    endfunction

    // インスタンス間は、connect_phase関数で行う
    function void connect_phase ( uvm_phase phase );
      p1.out.connect( c.in );
      p2.out.connect( f.blocking_put_export );
      c.out.connect( f.get_export );
    endfunction

今回で、examples/simple/hello_worldの解説は終了です。
来週は、examples/simple/tlm2/blocking_simpleの解説です。

検証、Verification、SystemVerilog、UVM、Unified Verification Methodology