00001 // $Id: ovm__transaction_8sv-source.html,v 1.1 2008/10/07 21:54:13 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 00030 super.new(name); 00031 this.initiator = initiator; 00032 m_transaction_id = -1; 00033 00034 endfunction // ovm_transaction 00035 00036 00037 // set_transaction_id 00038 function void ovm_transaction::set_transaction_id(integer id); 00039 m_transaction_id = id; 00040 endfunction 00041 00042 // get_transaction_id 00043 function integer ovm_transaction::get_transaction_id(); 00044 return (m_transaction_id); 00045 endfunction 00046 00047 // set_initiator 00048 // ------------ 00049 00050 function void ovm_transaction::set_initiator(ovm_component initiator); 00051 this.initiator = initiator; 00052 endfunction 00053 00054 // get_initiator 00055 // ------------ 00056 00057 function ovm_component ovm_transaction::get_initiator(); 00058 return initiator; 00059 endfunction 00060 00061 // get_event_pool 00062 // -------------- 00063 00064 function ovm_event_pool ovm_transaction::get_event_pool(); 00065 return m_event_pool; 00066 endfunction 00067 00068 00069 // is_active 00070 // --------- 00071 00072 function bit ovm_transaction::is_active(); 00073 return (tr_handle != 0); 00074 endfunction 00075 00076 00077 // get_begin_time 00078 // -------------- 00079 00080 function time ovm_transaction::get_begin_time (); 00081 return begin_time; 00082 endfunction 00083 00084 00085 // get_end_time 00086 // ------------ 00087 00088 function time ovm_transaction::get_end_time (); 00089 return end_time; 00090 endfunction 00091 00092 00093 // get_accept_time 00094 // --------------- 00095 00096 function time ovm_transaction::get_accept_time (); 00097 return accept_time; 00098 endfunction 00099 00100 00101 // do_accept_tr 00102 // ------------- 00103 00104 function void ovm_transaction::do_accept_tr(); 00105 return; 00106 endfunction 00107 00108 00109 // do_begin_tr 00110 // ------------ 00111 00112 function void ovm_transaction::do_begin_tr(); 00113 return; 00114 endfunction 00115 00116 00117 // do_end_tr 00118 // ---------- 00119 00120 function void ovm_transaction::do_end_tr(); 00121 return; 00122 endfunction 00123 00124 // do_print 00125 // -------- 00126 00127 function void ovm_transaction::do_print (ovm_printer printer); 00128 string str; 00129 ovm_component tmp_initiator; //work around $swrite bug 00130 super.do_print(printer); 00131 if(accept_time != -1) 00132 printer.print_time("accept_time", accept_time); 00133 if(begin_time != -1) 00134 printer.print_time("begin_time", begin_time); 00135 if(end_time != -1) 00136 printer.print_time("end_time", end_time); 00137 if(initiator != null) begin 00138 tmp_initiator = initiator; 00139 `ifdef INCA 00140 $swrite(str,"@%0d", tmp_initiator); 00141 `else 00142 `endif 00143 printer.print_generic("initiator", initiator.get_type_name(), -1, str); 00144 end 00145 endfunction 00146 00147 function void ovm_transaction::do_copy (ovm_object rhs); 00148 ovm_transaction txn; 00149 super.do_copy(rhs); 00150 if(rhs == null) return; 00151 if(!$cast(txn, rhs) ) return; 00152 00153 accept_time = txn.accept_time; 00154 begin_time = txn.begin_time; 00155 end_time = txn.end_time; 00156 initiator = txn.initiator; 00157 stream_handle = txn.stream_handle; 00158 tr_handle = txn.tr_handle; 00159 record_enable = txn.record_enable; 00160 endfunction 00161 00162 // do_record 00163 // --------- 00164 00165 function void ovm_transaction::do_record (ovm_recorder recorder); 00166 string s; 00167 super.do_record(recorder); 00168 if(accept_time != -1) 00169 void'(m_do_data ("accept_time", accept_time, 0, OVM_RECORD, 00170 $bits(accept_time), 0)); 00171 if(initiator != null) 00172 m_record_field_object("initiator", initiator, 00173 ovm_auto_options_object.recorder, 0); 00174 endfunction 00175 00176 // get_tr_handle 00177 // --------- 00178 00179 function integer ovm_transaction::get_tr_handle (); 00180 return tr_handle; 00181 endfunction 00182 00183 00184 // disable_recording 00185 // ----------------- 00186 00187 function void ovm_transaction::disable_recording (); 00188 record_enable = 0; 00189 endfunction 00190 00191 00192 // enable_recording 00193 // ---------------- 00194 00195 function void ovm_transaction::enable_recording (string stream); 00196 string scope; 00197 int lastdot; 00198 for(lastdot=stream.len()-1; lastdot>0; --lastdot) 00199 if(stream[lastdot] == ".") break; 00200 00201 if(lastdot) begin 00202 scope = stream.substr(0, lastdot-1); 00203 stream = stream.substr(lastdot+1, stream.len()-1); 00204 end 00205 this.stream_handle = ovm_create_fiber(stream, "TVM", scope); 00206 record_enable = 1; 00207 endfunction 00208 00209 00210 // is_recording_enabled 00211 // -------------------- 00212 00213 function bit ovm_transaction::is_recording_enabled (); 00214 return record_enable; 00215 endfunction 00216 00217 00218 // accept_tr 00219 // --------- 00220 00221 function void ovm_transaction::accept_tr (time accept_time = 0); 00222 ovm_event e; 00223 00224 if(accept_time != 0) 00225 this.accept_time = accept_time; 00226 else 00227 this.accept_time = $time; 00228 00229 do_accept_tr(); 00230 e = m_event_pool.get("accept"); 00231 00232 if(e!=null) 00233 e.trigger(); 00234 endfunction 00235 00236 // begin_tr 00237 // ----------- 00238 00239 function integer ovm_transaction::begin_tr (time begin_time=0); 00240 return m_begin_tr(begin_time, 0, 0); 00241 endfunction 00242 00243 // begin_child_tr 00244 // -------------- 00245 00246 //Use a parent handle of zero to link to the parent after begin 00247 function integer ovm_transaction::begin_child_tr (time begin_time=0, 00248 integer parent_handle=0); 00249 return m_begin_tr(begin_time, parent_handle, 1); 00250 endfunction 00251 00252 // m_begin_tr 00253 // ----------- 00254 00255 function integer ovm_transaction::m_begin_tr (time begin_time=0, 00256 integer parent_handle=0, 00257 bit has_parent=0); 00258 ovm_event e; 00259 00260 if(begin_time != 0) 00261 this.begin_time = begin_time; 00262 else 00263 this.begin_time = $time; 00264 00265 // May want to establish predecessor/successor relation 00266 // (don't free handle until then) 00267 if(record_enable) begin 00268 00269 if(ovm_check_handle_kind("Transaction", tr_handle)==1) 00270 end_tr(); 00271 00272 if(!has_parent) 00273 tr_handle = ovm_begin_transaction("Begin_No_Parent, Link", 00274 stream_handle, get_type_name(),"","",begin_time); 00275 else begin 00276 tr_handle = ovm_begin_transaction("Begin_End, Link", 00277 stream_handle, get_type_name(),"","",begin_time); 00278 if(parent_handle) 00279 ovm_link_transaction(parent_handle, tr_handle, "child"); 00280 end 00281 00282 ovm_default_recorder.tr_handle = tr_handle; 00283 record(ovm_default_recorder); 00284 00285 if(ovm_check_handle_kind("Transaction", tr_handle)!=1) 00286 $display("tr handle %0d not valid!",tr_handle); 00287 00288 end 00289 else 00290 tr_handle = 0; 00291 00292 e = m_event_pool.get("begin"); 00293 00294 do_begin_tr(); //execute callback before event trigger 00295 00296 if(e!=null) 00297 e.trigger(); 00298 00299 return tr_handle; 00300 endfunction 00301 00302 00303 // end_tr 00304 // ------ 00305 00306 function void ovm_transaction::end_tr (time end_time=0, bit free_handle=1); 00307 ovm_event e; 00308 00309 if(end_time != 0) 00310 this.end_time = end_time; 00311 else 00312 this.end_time = $time; 00313 00314 do_end_tr(); // Callback prior to actual ending of transaction 00315 00316 if(is_active()) begin 00317 ovm_default_recorder.tr_handle = tr_handle; 00318 record(ovm_default_recorder); 00319 00320 ovm_end_transaction(tr_handle,end_time); 00321 00322 if(free_handle && ovm_check_handle_kind("Transaction", tr_handle)==1) 00323 begin 00324 ovm_free_transaction_handle(tr_handle); 00325 end 00326 tr_handle = 0; 00327 end 00328 00329 e = m_event_pool.get("end"); 00330 00331 if(e!=null) 00332 e.trigger(); 00333 endfunction 00334 00335 00336 // convert2string 00337 // -------------- 00338 00339 function string ovm_transaction::convert2string(); 00340 return sprint(); 00341 //return "empty"; 00342 endfunction 00343 00344 00345 00346 00347 00348
![]() 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 Version: 1.4.6 Mon Sep 29 14:23:30 2008 |