[UVM]UVM TLM FIFO使用方法總結

                     UVM TLM FIFO用法總結

 

  • 目录

一、TLM FIFO Overview

二、TLM FIFO Classes

三、TLM FIFO Methods

3.1、new

3.2、size

3.3、used

3.4、is_empty

3.5、is_full

3.6、flush

四、Summary of TLM FIFOs


       The TLM FIFO provides storage for the transactions between two independently running processes. We have seen put and get methods operates with only one outstanding transaction at a time i.e it is allowed to send the transaction Only after consumption of the previously sent transaction, in this case, the sender and receiver must be in sync else lead to blocking in one of the components.

       What if the case where the sender needs not wait for the receiver acknowledgment, it just wants to store it in memory and the receiver can consume whenever required. in this sender and The receiver needs not to be in sync. Yes With TLM FIFO it is possible.

            

 

一、TLM FIFO Overview

  • In TLM FIFO, the sender pushes the transactions to FIFO and whenever it required reiver pops it out or fetches from the FIFO
  • Transactions are put into the FIFO via the put_export method
  • Transactions are fetched from the FIFO via the get_peek_export method
  • As its FIFO (First In First Out), transactions are fetched from the FIFO in the order they are put

 

二、TLM FIFO Classes

uvm_tlm_fifo #(T)

       This class provides storage of transactions between two independently running processes

 

三、TLM FIFO Methods

3.1、new

  •   This is a constructor method used for the creation of TLM FIFO
function new (string name,
              uvm_component parent,
              int size=1);
  • The name and parent are the normal uvm_component constructor arguments
  • The size indicates the maximum size of the FIFO; a value of zero indicates no upper bound

3.2、size

  • Calling size() returns the size of the FIFO
  • A return value of 0 indicates the FIFO capacity has no limit

3.3、used

  • Returns the number of entries put into the FIFO

3.4、is_empty

  • Returns 1 when there are no entries in the FIFO, 0 otherwise

3.5、is_full

  • Returns 1 when the number of entries in the FIFO is equal to its size, 0 otherwise

3.6、flush

  • Calling flush method will Remove all entries from the FIFO
  • after the flush method call used method returns 0 and the is_empty method returns 1

 

四、Summary of TLM FIFOs

             

 

五、TLM Analysis FIFO Example

 5.1、

            

 5.2 

           

 

 5.2、Implementing analysis port in comp_a

class component_a extends uvm_component;
  
  transaction                             trans;
  //Step-1. Declaring analysis port
  uvm_analysis_port#(transaction)         analysis_port;
  
  `uvm_component_utils(component_a)
  
  //---------------------------------------
  // Constructor
  //---------------------------------------
  function new(string name, uvm_component parent);
    super.new(name, parent);
    
    //Step-2. Creating analysis port
    analysis_port = new("analysis_port", this);
  endfunction : new
  //---------------------------------------
  // run_phase
  //---------------------------------------
  virtual task run_phase(uvm_phase phase);
    phase.raise_objection(this);
    
    trans = transaction::type_id::create("trans", this);
    void'(trans.randomize());
    `uvm_info(get_type_name(), $sformatf(" tranaction randomized"), UVM_LOW)
    `uvm_info(get_type_name(), $sformatf(" Printing trans, \n %s", trans.sprint()), UVM_LOW)
    
    `uvm_info(get_type_name(),$sformatf(" Before calling port write method"),UVM_LOW)
    //Ste-3. Calling write method
    analysis_port.write(trans);
    `uvm_info(get_type_name(), $sformatf(" After  calling port write method"), UVM_LOW)
    
    phase.drop_objection(this);

  endtask : run_phase

endclass : component_a

 5.3、Implementing analysis FIFO in comp_b

class component_b extends uvm_component;
  
  transaction                              trans;
  //Step-1. Declaring analysis FIFO
  uvm_tlm_analysis_fifo #(transaction)     analy_fifo;  
  `uvm_component_utils(component_b)
  
  //---------------------------------------
  // Constructor
  //---------------------------------------
  function new(string name, uvm_component parent);
    super.new(name, parent);
    //Step-2. Creating analysis FIFO
    analy_fifo = new("analy_fifo", this);
  endfunction : new
  
  //---------------------------------------
  // run_phase
  //---------------------------------------
  virtual task run_phase(uvm_phase phase);
    phase.raise_objection(this);
    
    #100;
    `uvm_info(get_type_name(), $sformatf(" Before calling analysis fifo get method"), UVM_LOW)
    //Step.3 - Getting trans from FIFO
    analy_fifo.get(trans);
    `uvm_info(get_type_name(), $sformatf(" After  calling analysis fifo get method"), UVM_LOW)
    `uvm_info(get_type_name(), $sformatf(" Printing trans, \n %s",trans.sprint()), UVM_LOW)
    
    phase.drop_objection(this);

  endtask : run_phase

endclass : component_b

5.4、Connecting analysis port and analysis FIFO in env

function void connect_phase(uvm_phase phase);
  //Connecting analysis port to analysis FIFO
  comp_a.analysis_port.connect(comp_b.analy_fifo.analysis_export);
endfunction : connect_phase

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

元直数字电路验证

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

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

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

打赏作者

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

抵扣说明:

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

余额充值