UVM TLM通信PORT和IMP使用方法總結
-
目录
4.1、如下圖,A_PORT被連接到B_EXPORT,而B_EXPORT被連接到B_IMP
一.PORT與IMP的類型
PORT | TYPE | IMP | TYPE | TASK/FUNCTION IN COMPONENT B |
A | uvm_blocking_put_port#(my_transaction) | B | uvm_blocking_put_imp#(my_transaction, this) | put |
A | uvm_noblocking_put_port#(my_transaction) | B | uvm_noblocking_put_imp#(my_transaction, this) | try_put can_put |
A | uvm_put_port#(my_transaction) | B | uvm_put_imp#(my_transaction, this) | put try_put can_put |
A | uvm_blocking_get_port#(my_transaction) | B | uvm_blocking_get_imp#(my_transaction, this) | get |
A | uvm_noblocking_get_port#(my_transaction) | B | uvm_noblocking_get_imp#(my_transaction, this) | try_get can_get |
A | uvm_get_port#(my_transaction) | B | uvm_get_imp#(my_transaction, this) | get try_get can_get |
A | uvm_blocking_peek#(my_transaction) | B | uvm_blocking_peek_imp#(my_transaction, this) | peek |
A | uvm_noblocking_peek_port#(my_transaction) | B | uvm_noblocking_peek_imp#(my_transaction, this) | try_peek can_peek |
A | uvm_peek_port#(my_transaction) | B | uvm_peek_imp#(my_transaction, this) | peek try_peek can_peek |
A | uvm_blocking_get_peek#(my_transaction) | B | uvm_blocking_get_peek_imp#(my_transaction, this) | get peek |
A | uvm_noblocking_get_peek_port#(my_transaction) | B | uvm_noblocking_get_peek_imp#(my_transaction, this) | try_get can_get try_peek can_peek |
A | uvm_get_peek_port#(my_transaction) | B | uvm_get_peek_imp#(my_transaction, this) | get try_get can_get peek try_peek can_peek |
A | uvm_blocking_transport_port#(my_transaction) | B | uvm_blocking_transport_imp#(my_transaction, this) | transport |
A | uvm_noblocking_transport_port#(my_transaction) | B | uvm_noblocking_transport_imp#(my_transaction, this) | nb_transport |
A | uvm_transport_port#(my_transaction) | B | uvm_transport_imp#(my_transaction, this) | transport nb_transport |
-
一定要使用IMP 来终结连接关系。PORT 和EXPORT 都不能做为连接关系的终点。
-
在UVM中,只有IMP才能作為連接關係的終點
二.PORT與IMP的代碼實例
2.1.A_PORT
class A extends uvm_component;
`uvm_component_utils(A)
uvm_blocking_put_port#(my_transaction) A_PORT;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
A_PORT = new("A_PORT", this);
endfunction
virtual task main_phase(uvm_phase phase);
my_transaction tr;
repeat(10) begin
#10;
tr = my_transaction::type_id::create("tr");
assert(tr.randomize());
A_PORT.put();
end
endtask
endclass
2.2.B_IMP
class B extends uvm_component;
`uvm_component_utils(B)
uvm_blocking_put_export#(my_transaction) B_EXPORT;
uvm_blocking_put_imp#(my_transaction, B_IMP) B_IMP;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
B_IMP = new("B_IMP", this);
B_EXPORT = new("B_EXPORT", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
B_EXPORT.connect(B_IMP);
endfunction
virtual function void put(my_transaction tr);
`uvm_info("B", "Receive A Transaction", UVM_LOW)
tr.print();
endfunction : put
virtual task main_phase(uvm_phase phase);
endtask
endclass
三、PORT與IMP的鏈接
3.1、在env中建立PORT的IMP的鏈接
class my_env extends uvm_env;
A a_inst;
B b_inst;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
a_inst = A::type_id::creat("a_inst", this);
b_inst = B::type_id::creat("b_inst", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
a_inst.A_PORT.connect(b_inst.B_IMP);
endfunction
endclass : my_env
四、UVM中的IMP
4.1、如下圖,A_PORT被連接到B_EXPORT,而B_EXPORT被連接到B_IMP
4.2、Transaction在PORT中的傳遞
- 當執行A.A_PORT.put(tr)時,此時B.B_IMP會通知B有transaction過來了
- A.A_PORT.put(tr)會調用B.B_EXPORT的put(tr)
- B.B_EXPORT的put(tr)又會調用B.B_IMP的put(tr)
- B.B_IMP.put()又會調用B的相關任務,如B.put(tr)
- 綜上所述,A_PORT的操作最終會落到B.put的這個任務上,這個任務是屬於B的一個任務,與A無關
- 也就是說,這些操作最終要由B這個Component來實現,即要由一個Component來實現接口的操作
- 所以每一個IMP要和一個Component相對應