天天看點

UVM入門和進階實驗0

一. 概述

UVM學習流程仍然按照SV時候的核心流程,即:

  • 如何搭建驗證架構
  • 驗證元件之間的連接配接和通信
  • 如何編寫測試用例,繼而完成複用和覆寫率的收斂

我們UVM入門和進階實驗0還是同之前SV驗證明驗0思想一樣,讓大家通過簡單的實驗要求,進而掌握下面的基本概念和仿真操作:

  • 懂得如何編譯UVM代碼。
  • 了解SV和UVM之間的關系。
  • 了解UVM驗證頂層盒子與SV驗證頂層盒子之間的聯系。
  • 掌握啟動UVM驗證的必要步驟。

二. 編譯UVM代碼

(1)導入uvm_dass_inst.sv,sv_class_inst.sv,uvm_test_inst.sv,uvm_compile.sv并且compile select

UVM入門和進階實驗0

(2)編譯檔案uvm_compile.sv,選項為:simulate without optimization,待正常編譯結束。

module uvm_compile;
  // NOTE:: it is necessary to import uvm package and macros
  import uvm_pkg::*; //預編譯的uvm的庫
  `include "uvm_macros.svh"//預編譯的uvm的庫

  initial begin
    `uvm_info("UVM", "Hello, welcome to RKV UVM training!", UVM_LOW)
    #1us;
    `uvm_info("UVM", "Bye, and more gifts waiting for you!", UVM_LOW)
  end
endmodule
           
UVM入門和進階實驗0

uvm_pkg可以在mtiUvm中找到。

UVM入門和進階實驗0

(3)在指令視窗中敲入"run-all",可以觀察到仿真輸出語句:

UVM入門和進階實驗0

三. SV和UVM之間的關系

(1)編譯sv_class_inst

module sv_class_inst;
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  class top;
    function new();
      `uvm_info("SV_TOP", "SV TOP creating", UVM_LOW)
    endfunction
  endclass

  initial begin
    top t; 
    `uvm_info("SV_TOP", "test started", UVM_LOW)
    t = new();
    `uvm_info("SV_TOP", "test finished", UVM_LOW)
  end
endmodule
           

編譯結果:

UVM入門和進階實驗0

反映在sim中的結構圖:

UVM入門和進階實驗0

其實在0時刻的時候建立了t,并且結束了仿真,但是在instance中沒有顯示。獲得顯示的過程為:

首先transcipt中輸入restart

然後點選sv_class_inst,将斷點設定在17行,

再者transcipt中輸入run -all,

點選view-local,

選中initial過程塊,local中會顯示t變量。

UVM入門和進階實驗0

run -all的仿真結果:

UVM入門和進階實驗0

(2)編譯uvm_class_inst

module uvm_compile;
  // NOTE:: it is necessary to import uvm package and macros
  import uvm_pkg::*;
  `include "uvm_macros.svh"
  
  class top extends uvm_component;
    `uvm_component_utils(top)
    function new(string name = "top", uvm_component parent = null);
      super.new(name, parent);
      `uvm_info("UVM_TOP", "SV TOP creating", UVM_LOW)
    endfunction
  endclass

  initial begin
    `uvm_info("UVM", "Hello, welcome to RKV UVM training!", UVM_LOW)
    #1us;
    `uvm_info("UVM", "Bye, and more gifts waiting for you!", UVM_LOW)
  end
endmodule
           

編譯結果:

UVM入門和進階實驗0

run -all仿真結果:

UVM入門和進階實驗0

四. UVM驗證頂層盒子與SV驗證頂層盒子之間的聯系。

編譯并仿真uvm_test_inst.sv

package test_pkg;
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  class top extends uvm_test;
    `uvm_component_utils(top)
    function new(string name = "top", uvm_component parent = null);
      super.new(name, parent);
      `uvm_info("UVM_TOP", "SV TOP creating", UVM_LOW)
    endfunction
    task run_phase(uvm_phase phase);
      phase.raise_objection(this);
      `uvm_info("UVM_TOP", "test is running", UVM_LOW)
      phase.drop_objection(this);
    endtask
  endclass
endpackage

module uvm_test_inst;
  import uvm_pkg::*;
  `include "uvm_macros.svh"
  import test_pkg::*;

  initial begin
    `uvm_info("UVM_TOP", "test started", UVM_LOW)
    run_test("top");
    `uvm_info("UVM_TOP", "test finished", UVM_LOW)
  end

endmodule
           

仿真結果:

UVM入門和進階實驗0