What is a UVM agent?
Agent將Sequencer、Driver和Monitor封裝到單一instance中,並透過TLM interface將這些component連接起來。Agent也有類似將UVM agent設定為主動(active)或被動(passive)的設置,也有類似開關的config可以開啟/關閉functional coverage或類似更改parameter的config。
Types of Agents
- Active:
- 會產生
Sequencer,Driver,Monitor全部的instance - 會將data透過
Driver驅動至DUT
- 會產生
- Passive:
- 只會產生
Monitor的instance - 只有checking和coverage,並不會送任何資料到DUT
- 如果沒有任何資料要驅動到DUT的話,可以用Passive mode
- 只會產生
How to find out if a UVM agent is active or passive?
繼承uvm_agent的class會有一個get_is_active()的function可以得到UVM agent是Active mode還是Passive mode。
1 | class my_agent extends uvm_agent; |
Steps to create a UVM agent
建立一個繼承
uvm_agent的class,然後註冊到factory上1
2
3
4
5
6
7
8
9
10class my_agent extends uvm_agent;
`uvm_component_utils (my_agent)
function new (string name = "my_agent", uvm_component parent = null);
super.new (name, parent);
endfunction
...
endclass宣告agent內要用的component
1
2
3
4
5
6
7
8class my_agent extends uvm_agent;
...
my_driver drv_0;
my_monitor mon_0;
uvm_sequencer #(my_data) seqr_0;
agent_cfg agt_cfg_0;
...
endclass在build phase將component實例化
1
2
3
4
5
6
7
8
9
10
11
12class my_agent extends uvm_agent;
...
virtual function void build_phase (uvm_phase phase);
if (get_is_active()) begin
m_seqr0 = uvm_sequencer#(my_data)::type_id::create ("m_seqr0", this);
m_drv0 = my_driver::type_id::create ("m_drv0", this);
end
m_mon0 = my_monitor::type_id::create ("m_mon0", this);
endfunction
...
endclass將agent元件連接在一起
1
2
3
4
5
6
7class my_agent extends uvm_agent;
virtual function void connect_phase (uvm_phase phase);
if (get_is_active())
m_drv0.seq_item_port.connect (m_seqr0.seq_item_export);
endfunction
endclass
What does a UVM agent do?
通常會建立一個agent來提供特定於protocol的task來產生transactions、檢查結果和執行覆蓋。例如,可以為 WishBone protocol建立 UVM agent,其sequencer將產生可傳送至driver的 data item。然後,driver將這些data item的object轉換為實際pin level的signal並將它們驅動到 DUT。monitor可以被動的只接收來自 DUT 的輸出,將它們轉換回另一個data item class object ,並將其分發到testbench中等待該data item的所有components中。
How to configure a UVM agent as active or passive?
A user-defined agent derived from uvm_agent has an internal variable called is_active which is of enum type uvm_active_passive_enum. By default, all agents are active.
從繼承uvm_agent自己定義的agent有一個 is_active 的變量,enum type為 uvm_active_passive_enum。default值為Active狀態。
1 | // set to passive |