UVM基礎之------uvm_transaction


uvm_transaction繼承自uvm_object,添加了timing和recording接口,該類是uvm_sequence_item的基類。下邊將做剖析
1. 這個類提供了時間戳屬性(timestamp properties),通知事件(notification events),和交易記錄(transaction recording)支持。
2. 使用這個類作為用戶定義的基礎交易是棄用。其子類uvm_sequence_item應當作為基類為所有用戶定義的事務類型。
3. 這個API的使用意圖是在sequence item執行過程中通過調用uvm_component < uvm_driver >::accept_tr uvm_component::begin_tr uvm_component::end_tr。從而設置對應的時間戳(accept_time,begin_time,and end_tr),觸發對應的event(begin_event and end_event),如果啟用,記錄事務內容特定於供應商的事務數據庫。
4. Note that start_item/finish_item (or `uvm_do* macro) executed from a uvm_sequence #(REQ,RSP) will automatically trigger the begin_event and end_events via calls to begin_tr and end_tr.
5. 雖然方便,但是觸發這些事件通常應該由drivers去標記事務執行期間的進展,標志着一個事務執行期間的進展。 To allow the driver to control sequence item timestamps, events, and recording, you must add +define+UVM_DISABLE_AUTO_ITEM_RECORDING when compiling the UVM package. 
6. 另外,用戶可能使用事務的event pool,events,定義自定義events驅動觸發和序列等。任何中間事件等標記的地址和數據的開始階段事務執行可以通過events pools實現。
7. In pipelined protocols, the driver may release a sequence (return from finish_item() or it’s `uvm_do macro) before the item has been completed.  If the driver uses the begin_tr/end_tr API in uvm_component, the sequence can wait on the item’s end_event to block until the item was fully executed, as in the following example.
8.  task uvm_execute(item, ...);
    // can use the `uvm_do macros as well
    start_item(item);
    item.randomize();
    finish_item(item);
    item.end_event.wait_on();
    // get_response(rsp, item.get_transaction_id()); //if needed
endtask

9. A simple two-stage pipeline driver that can execute address and data phases concurrently might be implemented as follows:
task run();
    // this driver supports a two-deep pipeline
    fork
      do_item();
      do_item();
    join
endtask
 
 
task do_item();
 
  forever begin
    mbus_item req;  
    lock.get();  
    seq_item_port.get(req); // Completes the sequencer-driver handshake  
    accept_tr(req);  
      // request bus, wait for grant, etc.  
    begin_tr(req);  
      // execute address phase  
    // allows next transaction to begin address phase
    lock.put();  
      // execute data phase
      // (may trigger custom "data_phase" event here)  
    end_tr(req);  
  end  
endtask: do_item

1.變量
 
  local integer m_transaction_id = -1;//id
 
  local time    begin_time=-1;//開始記錄的時間
  local time    end_time=-1;//結束記錄的時間
  local time    accept_time=-1;//被接受的時間
 
  local uvm_component initiator;//本實例所屬的component
  local integer       stream_handle;//本實例所屬的流
  local integer       tr_handle;//本實例的handle,即本實例的一個索引值,在某個地方記錄了這個tr.    
  local bit           record_enable = 0;//記錄使能
  local uvm_recorder  m_recorder;//記錄器
 
  const uvm_event_pool events = new;  
  uvm_event begin_event;  
  uvm_event end_event;

 2.function uvm_transaction::new (string name="",
                               uvm_component initiator = null);//該函數設置實例的名字,所屬的
 
component,transaction_id,開始事件,結束事件
 
3.function void uvm_transaction::set/get_transaction_id(integer id);對m_transaction_id的訪問  
4.function void uvm_transaction::set/get_initiator(uvm_component initiator);對initiator的訪問  
5.function uvm_event_pool uvm_transaction::get_event_pool();//返回events  
6.function bit uvm_transaction::is_active();//測試tr_handle是否為空
 7.下列函數顧名思意
 
   function time uvm_transaction::get_begin_time ();
 
   function time uvm_transaction::get_end_time ();
 
   function time uvm_transaction::get_accept_time ();
 
   function integer uvm_transaction::get_tr_handle ();
 
   function void uvm_transaction::disable_recording ();
 
   function bit uvm_transaction::is_recording_enabled ();
8. 下列函數只是一個hook,可以被相應的函數在恰當的地方調用
 
   function void uvm_transaction::do_accept_tr();
 
   function void uvm_transaction::do_begin_tr();
 
   function void uvm_transaction::do_end_tr();
   //下述三個方法用於實現uvm_object里面的方法,
   function void uvm_transaction::do_print (uvm_printer printer);//打印accept/begin/end time,initiator的名字 
   function void uvm_transaction::do_copy (uvm_object rhs);//做一些copy,把各個內部變量做copy 
   function void uvm_transaction::do_record (uvm_recorder recorder);//記錄initiator和accept time
 9.function void uvm_transaction::enable_recording (string stream, uvm_recorder recorder=null);//根據stream生產stream_handle,使能enable_record
      If transaction recording is on, then a call to record is made when the transaction is started and when it is ended.
10.function void uvm_transaction::accept_tr (time accept_time = 0);//生成或者設置accept_time,並觸發accept_event,調用do_accept_tr
       1. Calling accept_tr indicates that the transaction item has been received by a consumer component.
       2.Typically a <uvm_driver> would call uvm_component::accept_tr, which calls this method-- upon return from a get_next_item(), get(), or peek() call on its sequencer port, <uvm_driver::seq_item_port>.
      3.With some protocols, the received item may not be started immediately after it is accepted.  For example, a bus driver, having accepted a request transaction, may still have to wait for a bus grant before begining to execute the request.

      4.  This function performs the following actions:  
           1. The transaction’s internal accept time is set to the current simulation time, or to accept_time if provided and non-zero.  The accept_time may be any time, past or future.
          2. The transaction’s internal accept event is triggered.  Any processes waiting on the this event will resume in the next delta cycle.
          3. The do_accept_tr method is called to allow for any post-accept action in derived classes.

11.function integer uvm_transaction::begin_tr (time begin_time=0); 調用12
     1. 這個function表明transaction已經啟動,並不是另一個transaction的child
     2. Typically a <uvm_driver> would call uvm_component::begin_tr, which calls this method, before actual execution of a sequence item transaction.  Sequence items received by a driver are always a child of a parent sequence.  In this case, begin_tr obtains the parent handle and delegates to begin_child_tr.
     3.  This function performs the following actions:  
          1. The transaction’s internal start time is set to the current simulation time, or to begin_time if provided and non-zero.  The begin_time may be any time, past or future, but should not be less than the accept time.
          2. If recording is enabled, then a new database-transaction is started with the same begin time as above.
          3. The do_begin_tr method is called to allow for any post-begin action in derived classes.
          4. The transaction’s internal begin event is triggered.  Any processes waiting on this event will resume in the next delta cycle.

12.function integer uvm_transaction::m_begin_tr (time begin_time=0,
                                              integer parent_handle=0,
                                              bit has_parent=0);//設置begin_time;
 
   如果record_enable,首先核查本tr_handle是否在recorder中,如果已在,則打印end_tr,否則進行記錄,並返回tr_handle,如果有父handle,則在tr_handle和parent_handle間建立連接,最后檢查tr_handle是否有效。
 
如果record_enable==0,則tr_handle=0;然后調用do_begin_tr();然后觸發begin_event,最后返回tr_handle。
 
13.function integer uvm_transaction::begin_child_tr (time begin_time=0,
                                                  integer parent_handle=0);//調用12,設置has_parent==1.
 
14.function void uvm_transaction::end_tr (time end_time=0, bit free_handle=1);//設置end_time,調用do_end_tr,調用recorder.edn_tr, recorder.free_tr,最后觸發end_event
This function indicates that the transaction execution has ended.  Generally, a consumer component ends execution of the transactions it receives.
 
You must have previously called begin_tr or begin_child_tr for this call to be successful.
 
Typically a <uvm_driver> would call uvm_component::end_tr, which calls this method, upon completion of a sequence item transaction.  Sequence items received by a driver are always a child of a parent sequence.  In this case, begin_tr obtain the parent handle and delegate to begin_child_tr.
This function performs the following actions
 
    The transaction’s internal end time is set to the current simulation time, or to end_time if provided and non-zero.  The end_time may be any time, past or future, but should not be less than the begin time.
    If recording is enabled and a database-transaction is currently active, then the record method inherited from uvm_object is called, which records the final property values.  The transaction is then ended.  If free_handle is set, the transaction is released and can no longer be linked to (if supported by the implementation).
    The do_end_tr method is called to allow for any post-end action in derived classes.
    The transaction’s internal end event is triggered.  Any processes waiting on this event will resume in the next delta cycle.








免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM