Vengineerの妄想(準備期間)

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

OVM 1.0/1.0.1 : ovm_env::run_testタスクの実装

Verification Engineerの戯言

OVM 1.0/1.0.1対応

ovm_env::run_testタスクは、src/base/ovm_env.sv内で次のように実装されています。

最初に、シミュレータ実行ときのパラメータ引数(+OVM_TESTNAME=...)の部分をチェックしています。
    task ovm_env::run_test(string test_name="");
      bit testname_plusarg;

      testname_plusarg = 0;

      // if test not specified, check plusarg 
      if ($value$plusargs("OVM_TESTNAME=%s", test_name))
        testname_plusarg = 1;
      if ($value$plusargs("TESTNAME=%s", test_name)) begin
        _global_reporter.ovm_report_warning("DPRFT", "+TESTNAME is deprecated, please use +OVM_TESTNAME instead");
        testname_plusarg = 1;
      end
+TESTNAME=でもパラメータ引数ができますが、ワーニングが出ます。+OVM_TESTNAMEと+TESTNAMEを両方指定すると、
上記のコードからわかるように、+TESTNAMEで指定したものになってしまいます。

+OVM_TESTNAME=、+TESTNAME=を指定しないと、run_testタスクの引数がテスト名になります。

次に、指定したテスト名のチェック等を行います。test_nameに何も設定されていないときは、特に何もしません。
      // if test now defined, create it using common factory
      if (test_name != "") begin
        if(ovm_test_top != null) begin
          _global_reporter.ovm_report_error("TTINST", "The ovm_test_top has been set via a previous call to run_test");
        end
        $cast(ovm_test_top, ovm_factory::create_component(test_name, "ovm_test_top", "ovm_test_top", null));

        assert_test_not_found : assert(ovm_test_top != null) else begin
          if (testname_plusarg) begin
            ovm_object::m_sc.scratch1 = 
                { "Requested test from command line (+OVM_TESTNAME=", test_name,
                  ") not found." };
            _global_reporter.ovm_report_fatal("INVTST", ovm_object::m_sc.scratch1);
          end
          else begin
            ovm_object::m_sc.scratch1 = 
                { "Requested test from call to run_test(\"", test_name,
                  "\"); not found." };
            _global_reporter.ovm_report_fatal("INVTST", ovm_object::m_sc.scratch1);
          end
          $fatal;     
        end
      end
      if (m_comp_list.size() == 0) begin
        _global_reporter.ovm_report_fatal("NOCOMP", $psprintf("No components instantiated. You must instantiate at least one component before calling run_test. To run a test, use +OVM_TESTNAME or supply the test name in the argument to run_test(). Exiting simulation."));
          return;
      end
チェックが終わったら、全体のテストを実行するためにrun_global_phaseタスクを実行します。
      if(test_name == "")
        _global_reporter.ovm_report_info("RNTST", $psprintf("Running test ..."),500);
      else
        _global_reporter.ovm_report_info("RNTST", $psprintf("Running test %0s...",test_name),500);

      // run through that phase (run entire test)
      run_global_phase();
run_global_phaseタスクが終了したら、後処理を行います。
      if (finish_on_completion) begin
        fork 
          $finish;
        join_none
      end

    endtask
コード量は多いですが、結構単純です。

検証、Verification、SystemVerilog、OVM、Open Verification Methodology