什么是UVM environment?
UVM environment包含多個可重用的驗證組件,并根據test case的需求進行相應的配置。例如,UVM environment可能具有多個agent(對應不同的interface)、scoreboard、functional coverage collector和一些checker。
對于一個復雜的數字系統,UVM environment可能還集成其他一些較小的UVM environment,這些相對較小的驗證環境用于對各個子系統/模塊進行驗證。所以,被集成的子模塊/系統驗證環境中的很多組件和sequence都是可以復用的。
為什么驗證組件不直接放在test case中?
從技術上講,一些驗證組件可以直接在用戶定義的testcase(uvm_test類)中實例化。
class base_test extends uvm_test;`uvm_component_utils(base_test)apb_agent m_apb_agent;spi_agent m_spi_agent;base_scoreboard m_base_scbd;virtual function void build_phase(uvm_phase phase);// Instantiate agents and scoreboardendfunctionendclass
但是,不建議這樣做:test case不能夠復用,因為它們依賴于特定的驗證環境,針對每個testcase都開發一個uvm environment比較低效。 簡單來說,uvm environment存在的意義就是不同的testcase都使用同一套驗證環境代碼 ,是為了驗證環境的復用性考慮的。
因此,始終建議開發一個比較通用的,適用所有test case的驗證環境, 然后在多個test case中實例化該驗證環境類uvm environment。此外,不同的testcase可以配置、啟動、禁用驗證環境中的各種配置,可能是激勵的隨機機制、agent的active/passive模式,也可能是scoreboard的開關。

創建 UVM environment的步驟
- 創建一個繼承自uvm_env的自定義類,注冊到工廠,并調用 new函數
// my_env is user-given name for this class that has been derived from "uvm_env"class my_env extends uvm_env;// [Recommended] Makes this driver more re-usable`uvm_component_utils (my_env)// This is standard code for all componentsfunction new (string name = "my_env", uvm_component parent = null);super.new (name, parent);endfunction// Code for rest of the steps come hereendclass
聲明和構建驗證環境中各個驗證組件
// apb_agnt and other components are assumed to be user-defined classes that already exist in TBapb_agnt m_apb_agnt;func_cov m_func_cov;scbd m_scbd;env_cfg m_env_cfg;// Build components within the "build_phase"virtual function void build_phase (uvm_phase phase);super.build_phase (phase);m_apb_agnt = apb_agnt::type_id::create ("m_apb_agnt", this);m_func_cov = func_cov::type_id::create ("m_func_cov", this);m_scbd = scbd::type_id::create ("m_scbd", this);// [Optional] Collect configuration objects from the test class if applicableif (uvm_config_db #(env_cfg)::get(this, "", "env_cfg", m_env_cfg))`uvm_fatal ("build_phase", "Did not get a configuration object for env")// [Optional] Pass other configuration objects to sub-components via uvm_config_dbendfunction
在自定義uvm_env類的connect_phase中根據需要連接各個驗證組件
virtual function void connect_phase (uvm_phase phase); // A few examples:// Connect analysis ports from agent to the scoreboard// Connect functional coverage component analysis ports// ...endfunction
UVM Environment 示例(對應上面提到的的驗證環境圖)
class my_top_env extends uvm_env;`uvm_component_utils (my_env)agent_apb m_apb_agt;agent_wishbone m_wb_agt;env_register m_reg_env;env_analog m_analog_env [2];scoreboard m_scbd;function new (string name = "my_env", uvm_component parent);super.new (name, parent);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);// Instantiate different agents and environments herem_apb_agt = agent_apb::type_id::create ("m_apb_agt", this);m_wb_agt = agent_wishbone::type_id::create ("m_wb_agt", this);m_reg_env = env_register::type_id::create ("m_reg_env", this);foreach (m_analog_env[i])m_analog_env[i] = env_analog::type_id::create ($sformatf("m_analog_env%0d",m_analog_env[i]), this);m_scbd = scoreboard::type_id::create ("m_scbd", this);endfunctionvirtual function void connect_phase (uvm_phase phase);// Connect between different environments, agents, analysis ports, and scoreboard hereendfunctionendclass
其中env_analog或env_register中也可以有一些agent和scoreboard。 可以看到UVM在可重用性方面很強大,主要取決于這種分層結構和TLM連接。 也正是因為這種復用,可以分別獨立驗證env_analog和env_register,而在更加上層的驗證環境my_top_env中,可能只需要關注子系統之間的交互。
-
UVM
+關注
關注
0文章
183瀏覽量
20012 -
代碼
+關注
關注
30文章
4967瀏覽量
73954 -
數字系統
+關注
關注
0文章
164瀏覽量
21574
發布評論請先 登錄
數字IC驗證之“什么是UVM”“UVM的特點”“UVM提供哪些資源”(2)連載中...
什么是uvm?uvm的特點有哪些呢
談談UVM中的uvm_info打印
UVM中seq.start()和default_sequence執行順序
The Java Language Environment
Creating An Efficient Verification Environment using Synopsy
Agilent Environment and Social
UVM driver和sequencer的通信
UVM中uvm_config_db機制背后的大功臣
UVM中uvm_config_db機制背后的大功臣
一文詳解UVM設計模式
什么是UVM environment?
評論