ovm_transaction.sv

Go to the documentation of this file.
00001 // $Id: ovm__transaction_8sv-source.html,v 1.1 2008/10/07 21:54:54 alex.marin Exp $
00002 //----------------------------------------------------------------------
00003 //   Copyright 2007-2008 Mentor Graphics Corporation
00004 //   Copyright 2007-2008 Cadence Design Systems, Inc.
00005 //   All Rights Reserved Worldwide
00006 //
00007 //   Licensed under the Apache License, Version 2.0 (the
00008 //   "License"); you may not use this file except in
00009 //   compliance with the License.  You may obtain a copy of
00010 //   the License at
00011 //
00012 //       http://www.apache.org/licenses/LICENSE-2.0
00013 //
00014 //   Unless required by applicable law or agreed to in
00015 //   writing, software distributed under the License is
00016 //   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00017 //   CONDITIONS OF ANY KIND, either express or implied.  See
00018 //   the License for the specific language governing
00019 //   permissions and limitations under the License.
00020 //----------------------------------------------------------------------
00021 
00022 `include "base/ovm_transaction.svh"
00023 
00024 // new
00025 // ---
00026 
00027 function ovm_transaction::new (string name="", 
00028                 ovm_component initiator=null);
00029   super.new(name);
00030   this.initiator = initiator;
00031 endfunction
00032 
00033 // set_initiator
00034 // ------------
00035 
00036 function void ovm_transaction::set_initiator(ovm_component initiator);
00037   this.initiator = initiator;
00038 endfunction
00039 
00040 // get_initiator
00041 // ------------
00042 
00043 function ovm_component ovm_transaction::get_initiator();
00044   return initiator;
00045 endfunction
00046 
00047 // get_event_pool
00048 // --------------
00049 
00050 function ovm_event_pool ovm_transaction::get_event_pool();
00051   return m_event_pool;
00052 endfunction
00053 
00054 
00055 // is_active
00056 // ---------
00057 
00058 function bit ovm_transaction::is_active();
00059   return (tr_handle != 0);
00060 endfunction
00061 
00062 
00063 // get_begin_time
00064 // --------------
00065 
00066 function time ovm_transaction::get_begin_time ();
00067   return begin_time;
00068 endfunction
00069 
00070 
00071 // get_end_time
00072 // ------------
00073 
00074 function time ovm_transaction::get_end_time ();
00075   return end_time;
00076 endfunction
00077 
00078 
00079 // get_accept_time
00080 // ---------------
00081 
00082 function time ovm_transaction::get_accept_time ();
00083   return accept_time;
00084 endfunction
00085 
00086 
00087 // do_accept_tr
00088 // -------------
00089 
00090 function void ovm_transaction::do_accept_tr();
00091   return;
00092 endfunction
00093 
00094 
00095 // do_begin_tr
00096 // ------------
00097 
00098 function void ovm_transaction::do_begin_tr();
00099   return;
00100 endfunction
00101 
00102 
00103 // do_end_tr
00104 // ----------
00105 
00106 function void ovm_transaction::do_end_tr();
00107   return;
00108 endfunction
00109 
00110 // do_print
00111 // --------
00112 
00113 function void ovm_transaction::do_print (ovm_printer printer);
00114   string str;
00115   ovm_component tmp_initiator; //work around $swrite bug
00116   super.do_print(printer);
00117   if(accept_time != -1)
00118     printer.print_time("accept_time", accept_time);
00119   if(begin_time != -1)
00120     printer.print_time("begin_time", begin_time);
00121   if(end_time != -1)
00122     printer.print_time("end_time", end_time);
00123   if(initiator != null) begin
00124     tmp_initiator = initiator;
00125 `ifdef INCA
00126     $swrite(str,"@%0d", tmp_initiator);
00127 `else
00128 `endif
00129     printer.print_generic("initiator", initiator.get_type_name(), -1, str);
00130   end
00131 endfunction
00132 
00133 function void ovm_transaction::do_copy (ovm_object rhs);
00134   ovm_transaction txn;
00135   super.do_copy(rhs);
00136   if(rhs == null) return;
00137   if(!$cast(txn, rhs) ) return;
00138 
00139   accept_time = txn.accept_time;
00140   begin_time = txn.begin_time;
00141   end_time = txn.end_time;
00142   initiator = txn.initiator;
00143   stream_handle = txn.stream_handle;
00144   tr_handle = txn.tr_handle;
00145   record_enable = txn.record_enable;
00146 endfunction  
00147 
00148 // do_record
00149 // ---------
00150 
00151 function void ovm_transaction::do_record (ovm_recorder recorder);
00152   string s;
00153   super.do_record(recorder);
00154   if(accept_time != -1)
00155     void'(m_do_data ("accept_time", accept_time, 0, OVM_RECORD, 
00156                      $bits(accept_time), 0));
00157   if(initiator != null) 
00158     m_record_field_object("initiator", initiator, 
00159                           ovm_auto_options_object.recorder, 0);
00160 endfunction
00161 
00162 // get_tr_handle
00163 // ---------
00164 
00165 function integer ovm_transaction::get_tr_handle ();
00166   return tr_handle;
00167 endfunction
00168 
00169 
00170 // disable_recording
00171 // -----------------
00172 
00173 function void ovm_transaction::disable_recording ();
00174   record_enable = 0;
00175 endfunction
00176 
00177 
00178 // enable_recording
00179 // ----------------
00180 
00181 function void ovm_transaction::enable_recording (string stream);
00182   string scope;
00183   int lastdot;
00184   for(lastdot=stream.len()-1; lastdot>0; --lastdot)
00185     if(stream[lastdot] == ".") break;
00186 
00187   if(lastdot) begin
00188     scope = stream.substr(0, lastdot-1);
00189     stream = stream.substr(lastdot+1, stream.len()-1);
00190   end
00191   this.stream_handle = ovm_create_fiber(stream, "TVM", scope);
00192   record_enable = 1;
00193 endfunction
00194 
00195 
00196 // is_recording_enabled
00197 // --------------------
00198 
00199 function bit ovm_transaction::is_recording_enabled ();
00200   return record_enable;
00201 endfunction
00202 
00203 
00204 // accept_tr
00205 // ---------
00206 
00207 function void ovm_transaction::accept_tr (time accept_time = 0);
00208   ovm_event e;
00209 
00210   if(accept_time != 0)
00211     this.accept_time = accept_time;
00212   else
00213     this.accept_time = $time;
00214 
00215   do_accept_tr();
00216   e = m_event_pool.get("accept");
00217 
00218   if(e!=null) 
00219     e.trigger();
00220 endfunction
00221 
00222 // begin_tr
00223 // -----------
00224 
00225 function integer ovm_transaction::begin_tr (time begin_time=0); 
00226   return m_begin_tr(begin_time, 0, 0);
00227 endfunction
00228 
00229 // begin_child_tr
00230 // --------------
00231 
00232 //Use a parent handle of zero to link to the parent after begin
00233 function integer ovm_transaction::begin_child_tr (time begin_time=0,
00234                     integer parent_handle=0); 
00235   return m_begin_tr(begin_time, parent_handle, 1);
00236 endfunction
00237 
00238 // m_begin_tr
00239 // -----------
00240 
00241 function integer ovm_transaction::m_begin_tr (time begin_time=0, 
00242                      integer parent_handle=0, 
00243                      bit has_parent=0);
00244   ovm_event e;
00245 
00246   if(begin_time != 0)
00247     this.begin_time = begin_time;
00248   else
00249     this.begin_time = $time;
00250    
00251   // May want to establish predecessor/successor relation 
00252   // (don't free handle until then)
00253   if(record_enable) begin 
00254 
00255     if(ovm_check_handle_kind("Transaction", tr_handle)==1)
00256       end_tr(); 
00257 
00258     if(!has_parent)
00259       tr_handle = ovm_begin_transaction("Begin_No_Parent, Link", 
00260                     stream_handle, get_type_name(),"","",begin_time);
00261     else begin
00262       tr_handle = ovm_begin_transaction("Begin_End, Link", 
00263                     stream_handle, get_type_name(),"","",begin_time);
00264       if(parent_handle)
00265         ovm_link_transaction(parent_handle, tr_handle, "child");
00266     end
00267 
00268     ovm_default_recorder.tr_handle = tr_handle;
00269     record(ovm_default_recorder);
00270 
00271     if(ovm_check_handle_kind("Transaction", tr_handle)!=1)
00272       $display("tr handle %0d not valid!",tr_handle);
00273 
00274   end
00275   else 
00276     tr_handle = 0;
00277 
00278   e = m_event_pool.get("begin");
00279 
00280   do_begin_tr(); //execute callback before event trigger
00281 
00282   if(e!=null) 
00283     e.trigger();
00284  
00285   return tr_handle;
00286 endfunction
00287 
00288 
00289 // end_tr
00290 // ------
00291 
00292 function void ovm_transaction::end_tr (time end_time=0, bit free_handle=1);
00293   ovm_event e;
00294 
00295   if(end_time != 0)
00296     this.end_time = end_time;
00297   else
00298     this.end_time = $time;
00299 
00300   do_end_tr(); // Callback prior to actual ending of transaction
00301 
00302   if(is_active()) begin
00303     ovm_default_recorder.tr_handle = tr_handle;
00304     record(ovm_default_recorder);
00305   
00306     ovm_end_transaction(tr_handle,end_time);
00307 
00308     if(free_handle && ovm_check_handle_kind("Transaction", tr_handle)==1) 
00309     begin  
00310       ovm_free_transaction_handle(tr_handle);
00311     end
00312     tr_handle = 0;
00313   end
00314 
00315   e = m_event_pool.get("end");
00316 
00317   if(e!=null) 
00318     e.trigger();
00319 endfunction
00320 
00321 
00322 // convert2string
00323 // --------------
00324 
00325 function string ovm_transaction::convert2string();
00326   return sprint();
00327   //return "empty";
00328 endfunction

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 1.1.0
Copyright (c) 2008 Intelligent Design Verification.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included here:
http://www.intelligentdv.com/licenses/fdl.txt
doxygen
Doxygen Version: 1.4.6
Mon Sep 29 14:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV