What is UVM environment?
UVM environment包含多個可重複使用的驗證元件,並根據應用程式的要求定義他的default config。例如UVM environment可能會有用於不同interface的多個agent、一個common的scoreboard和額外的checker。
它還可能包含其他較小的environment,這些environment已在block level驗證過了,然後將其整合到子系統中。可以把block level驗證中使用的某些component和sequence在system level驗證計劃中重複使用。
為什麼驗證元件不應該直接放在測試class中?
技術上可以直接在uvm_test中直接產生agent和scoreboard的instance。
1 | class base_test extends uvm_test; |
但不建議這樣做,因為會有以下缺點:
- 測試不可reuse,因為測試依賴特定的environment結構
- 寫測試的人需要知道如何配置environment
- 如果要改變topology要更新很多測試檔案要花很多時間
因此,通常會建議從uvm_env開始建立testbench相關的class,然後可以在多個測試中實例化uvm_env。這樣environment的topology有改變的話可以反應在所有測試中。另外environment應該要有可以為了彈性調整enable/disable不同驗證模組的設置。
Steps to create a UVM environment
建立一個繼承
uvm_env的class,然後註冊到factory上1
2
3
4
5
6
7
8class my_env extends uvm_env;
`uvm_component_utils(my_env)
function new(string name = "my_env", uvm_component parent = null);
super.new(name, parent);
endfunction
...
endclass宣告其他verification component然後在
build_phase的時候將他們實例化1
2
3
4
5
6
7
8
9
10
11
12
13
14class my_env extends uvm_env;
apb_agnt apb_agent_0;
func_cov func_cov_0;
scbd sb_0;
env_cfg env_cfg_0;
virtual function void build_phase (uvm_phase phase);
super.build_phase (phase);
apb_agent_0 = apb_agnt::type_id::create ("apb_agent_0", this);
func_cov_0 = func_cov::type_id::create ("func_cov_0", this);
sb_0 = scbd::type_id::create ("sb_0", this);
endfunction
...
endclass在
connect_phase把不同component連接起來1
2
3
4
5
6
7
8class my_env extends uvm_env;
...
virtual function void connect_phase (uvm_phase phase);
// Connect in here
// ...
endfunction
...
endclass