UVM學習筆記--phase機制

1.UVM phase 概覽

UVM採用phase機制來自動化運行testbench各個仿真過程。UVM phase支持顯示或隱式的同步方案,運行過程中的線程控制和跳轉。用戶只要把代碼填入對應的phase,這些代碼就會自動在正確的時間執行。各個phase執行順序如下圖所示:

See the source image

相較於OVM,UVM新增了12個小的task phase,如下圖:

其中run_phase和uvm新增加的12個小phase是並行執行的。 

2 按是否消耗仿真時間,所有phase可以分成兩大類

    <1>  function phase:不消耗仿真時間,而其也可分成兩大類:
          a. 繼承自uvm_bottomup_phase, 在UVM component樹中,自下而上的執行, 如connect_phase
          b. 繼承自uvm_topdown_phase, 在UVM component樹中,自上而下執行, 如build_phase
    <2>  task phase:消耗仿真時間的,也稱動態運行(run-time)phase. 

下圖是各個phase的繼承關係,從中可以看出

UVM Phase Classes

 

自上而下(top-down) function phase:build和final phase。

自下而上(bottom-up)f unction phase:  connect, end_of_elaboration,start_of_simulation, extract, check, report。

task phase: run_phase以及其他12個小phase: pre_reset, reset_phase, post_reset, pre_configure, configure, post_configure, 
pre_main, main, post_main, pre_shutdown, shutdown, post_shutdown, 如下圖:

UVM run time phases

 

3 task phase的同步

一個UVM驗證平臺有許多component組成,每個component都有自己的run_phase,以及從pre_reset 到post_shuddown的12個小phase。只有所有component的一個小task phase 完成,整個仿真平臺纔開始下一個小task phase的執行。 各個component的run_phase之間,以及run_phase於最後一個小phase--post_shutdown_phase之間,都有這樣的同步。

See the source image

4. super.xxx_phase

除了super.build_phase,其他super.xxx_phase幾乎沒做任何事情,因此,除了build_phase,其他phase可不必加super.xxx_phase.

在super.build_phase中,主要完成自動獲取config_db中參數的功能,如果自定義的component無需獲取任何參數,也可省略。

5. phase的跳轉

默認情況下各phase是從上到下按時間順序執行,但可以自定義做必要的跳轉,如在main_phase執行過程中,突然遇到reset信號被置起,可以用jump()實現從mian_phase到reset_phase的跳轉:

phase.jump(uvm_reset_phase::get())

task my_driver::main_phase(uvm_phase phase);
  `uvm_info("driver", "main phase", UVM_LOW)
  fork
    while(1) begin
      seq_item_port.get_next_item(req);
      drive_one_pkt(req);
      seq_item_port.item_done();
    end
    begin
      @(negedge vif.rst_n);
      phase.jump(uvm_reset_phase::get());
    end
  join
endtask

跳轉的限制

不能跳轉到build到start_of_function的function phase, 也不能跳轉到run_phase. 從pre_reset_phase後的所有phase都可以作爲jump()的參數。 除了向前跳轉,也可向後跳轉。除了向run-time phase跳轉,甚至可以向final_phase等function phase跳轉。

phase的調試

  • 在命令行加UVM_PHASE_TRACE,可以將進入和退出個phase的信息打印到log中。

        <sim command> +UVM_PHASE_TRACE

  • 在指定phase設置verbosity:

       <sim command> +uvm_set_verbosity=<comp>,<id>,<verbosity>,<phase> 

      例如:simv   +uvm_set_verbosity=uvm_test_top.env.mdl,my_model,UVM_NONE,main  +UVM_TESTNAME=my_case0 +UVM_PHASE_TRACE  -l tmp.log

       注意,其中參數<phase> 不需要phase後綴,如上面例子將uvm_test_top.env.mdl的main_phase中打印的信息屏蔽掉,命令行裏用的是+uvm_set_verbosity=uvm_test_top.env.mdl,my_model,UVM_NONE,main 。

  • 設置timeout時間

      1. 通過命令行:<sim command> +UVM_TIMEOUT=<timeout>,<overridable>
             如<sim command> +UVM_TIMEOUT="300ns, YES" 

      2.通過在base test中使用set_timeout(): uvm_top.set_timeout(500ns,0);

          必要時需要修改宏定義:`define UVM_DEFAULT_TIMEOUT 9200s

   


參考
UVM實戰(卷1) (張強 著)

UVM基礎之------uvm phases機制

UVM Phases

UVM Phasing page from www.learnuvmverification.com

UVM Tutorial for Candy Lovers – 22. Phasing

UVM_Presentation_DAC2011_Final

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章