[UVM]史上最全的UVM TLM通信PORT和IMP使用方法總結

                UVM TLM通信PORT和IMP使用方法總結

 

  • 目录

一.PORT與IMP的類型

二.PORT與IMP的代碼實例

2.1.A_PORT

2.2.B_IMP

三、PORT與IMP的鏈接

3.1、在env中建立PORT的IMP的鏈接

四、UVM中的IMP

4.1、如下圖,A_PORT被連接到B_EXPORT,而B_EXPORT被連接到B_IMP

4.2、Transaction在PORT中的傳遞


一.PORT與IMP的類型

PORTTYPEIMPTYPE

TASK/FUNCTION

IN COMPONENT B

Auvm_blocking_put_port#(my_transaction)Buvm_blocking_put_imp#(my_transaction, this)put
Auvm_noblocking_put_port#(my_transaction)uvm_noblocking_put_imp#(my_transaction, this)try_put
can_put
Auvm_put_port#(my_transaction)Buvm_put_imp#(my_transaction, this)put
try_put
can_put
Auvm_blocking_get_port#(my_transaction)Buvm_blocking_get_imp#(my_transaction, this)get
Auvm_noblocking_get_port#(my_transaction)uvm_noblocking_get_imp#(my_transaction, this)try_get
can_get
Auvm_get_port#(my_transaction)Buvm_get_imp#(my_transaction, this)get
try_get
can_get
Auvm_blocking_peek#(my_transaction)Buvm_blocking_peek_imp#(my_transaction, this)peek
Auvm_noblocking_peek_port#(my_transaction)uvm_noblocking_peek_imp#(my_transaction, this)try_peek
can_peek
Auvm_peek_port#(my_transaction)Buvm_peek_imp#(my_transaction, this)peek
try_peek
can_peek
Auvm_blocking_get_peek#(my_transaction)Buvm_blocking_get_peek_imp#(my_transaction, this)get
peek
Auvm_noblocking_get_peek_port#(my_transaction)uvm_noblocking_get_peek_imp#(my_transaction, this)try_get
can_get
try_peek
can_peek
Auvm_get_peek_port#(my_transaction)Buvm_get_peek_imp#(my_transaction, this)get
try_get
can_get
peek
try_peek
can_peek
Auvm_blocking_transport_port#(my_transaction)Buvm_blocking_transport_imp#(my_transaction, this)transport
Auvm_noblocking_transport_port#(my_transaction)uvm_noblocking_transport_imp#(my_transaction, this)nb_transport
Auvm_transport_port#(my_transaction)Buvm_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相對應

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

元直数字电路验证

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值