00001 //---------------------------------------------------------------------- 00002 // Copyright 2007-2008 Mentor Graphics Corporation 00003 // Copyright 2007-2008 Cadence Design Systems, Inc. 00004 // All Rights Reserved Worldwide 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the 00007 // "License"); you may not use this file except in 00008 // compliance with the License. You may obtain a copy of 00009 // the License at 00010 // 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // 00013 // Unless required by applicable law or agreed to in 00014 // writing, software distributed under the License is 00015 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 // CONDITIONS OF ANY KIND, either express or implied. See 00017 // the License for the specific language governing 00018 // permissions and limitations under the License. 00019 //---------------------------------------------------------------------- 00020 00021 `ifndef OVM_SEQUENCE_ITEM_SVH 00022 `define OVM_SEQUENCE_ITEM_SVH 00023 00024 typedef class ovm_sequence_base; 00025 typedef class ovm_sequencer_base; 00026 00027 class ovm_sequence_item extends ovm_transaction; 00028 00029 local integer m_sequence_id = -1; 00030 protected bit m_use_sequence_info = 0; 00031 protected integer m_depth = -1; 00032 protected ovm_sequencer_base m_sequencer = null; 00033 protected ovm_sequence_base m_parent_sequence = null; 00034 static bit issued1=0,issued2=0; 00035 bit print_sequence_info = 0; 00036 00037 function new (string name = "ovm_sequence_item", 00038 ovm_sequencer_base sequencer = null, 00039 ovm_sequence_base parent_sequence = null); 00040 super.new(name); 00041 if (sequencer != null) begin 00042 if (!issued1) begin 00043 issued1=1; 00044 ovm_report_warning("deprecated", 00045 {"ovm_sequence_item::new()'s sequencer_ptr argument has been deprecated. ", 00046 "The sequencer is now specified at the time a sequence is started ", 00047 "using the start() task."}); 00048 end 00049 m_sequencer = sequencer; 00050 end 00051 if (parent_sequence != null) begin 00052 if (!issued2) begin 00053 issued2=1; 00054 ovm_report_warning("deprecated", 00055 {"ovm_sequence_item::new()'s parent_sequence argument has been deprecated. ", 00056 "The parent sequence is now specified at the time a sequence is started ", 00057 "using the start() task."}); 00058 end 00059 m_parent_sequence = parent_sequence; 00060 end 00061 endfunction // new 00062 00063 function string get_type_name(); 00064 return "ovm_sequence_item"; 00065 endfunction 00066 00067 // Macro for factory creation 00068 `ovm_object_registry(ovm_sequence_item, "ovm_sequence_item") 00069 00070 function void set_sequence_id(integer id); 00071 m_sequence_id = id; 00072 endfunction 00073 00074 function integer get_sequence_id(); 00075 return (m_sequence_id); 00076 endfunction 00077 00078 function void set_use_sequence_info(bit value); 00079 m_use_sequence_info = value; 00080 endfunction 00081 00082 function bit get_use_sequence_info(); 00083 return (m_use_sequence_info); 00084 endfunction 00085 00086 function void set_id_info(ovm_sequence_item item); 00087 assert (item != null) else begin 00088 ovm_report_fatal(get_full_name(), "set_id_info called with null parameter"); 00089 end 00090 this.set_transaction_id(item.get_transaction_id()); 00091 this.set_sequence_id(item.get_sequence_id()); 00092 endfunction 00093 00094 function void set_sequencer(ovm_sequencer_base sequencer); 00095 m_sequencer = sequencer; 00096 m_set_p_sequencer(); 00097 endfunction // void 00098 00099 function ovm_sequencer_base get_sequencer(); 00100 return (m_sequencer); 00101 endfunction // ovm_sequencer_base 00102 00103 function void set_parent_sequence(ovm_sequence_base parent); 00104 m_parent_sequence = parent; 00105 endfunction 00106 00107 function ovm_sequence_base get_parent_sequence(); 00108 return (m_parent_sequence); 00109 endfunction 00110 00111 function void set_depth(integer value); 00112 m_depth = value; 00113 endfunction 00114 00115 function integer get_depth(); 00116 00117 // If depth has been set or calculated, then use that 00118 if (m_depth != -1) begin 00119 return (m_depth); 00120 end 00121 00122 // Calculate the depth, store it, and return the value 00123 if (m_parent_sequence == null) begin 00124 m_depth = 1; 00125 end else begin 00126 m_depth = m_parent_sequence.get_depth() + 1; 00127 end 00128 00129 return (m_depth); 00130 endfunction 00131 00132 virtual function bit is_item(); 00133 return(1); 00134 endfunction 00135 00136 virtual task start_item(ovm_sequence_item item, integer set_priority = -1); 00137 if(item == null) 00138 m_sequencer.ovm_report_fatal("NULLITM", {"attempting to start a null item from item/sequence '", get_full_name(), "'"}); 00139 item.m_start_item(m_sequencer, this, set_priority); 00140 endtask 00141 00142 virtual task finish_item(ovm_sequence_item item, integer set_priority = -1); 00143 item.m_finish_item(item.get_sequencer(), this, set_priority); 00144 endtask // finish_item 00145 00146 virtual task m_start_item(ovm_sequencer_base sequencer_ptr, ovm_sequence_item sequence_ptr, 00147 integer set_priority); 00148 ovm_sequence_base this_seq; 00149 ovm_sequencer_base target_seqr; 00150 00151 target_seqr = this.get_sequencer(); 00152 00153 if (target_seqr == null) begin 00154 ovm_report_fatal("STRITM", "sequence_item has null sequencer"); 00155 end 00156 00157 assert($cast(this_seq, sequence_ptr)); 00158 target_seqr.wait_for_grant(this_seq, set_priority); 00159 if (target_seqr.recording_detail != OVM_NONE) begin 00160 void'(target_seqr.begin_tr(this, "aggregate items")); 00161 end 00162 sequence_ptr.pre_do(1); 00163 endtask 00164 00165 virtual task m_finish_item(ovm_sequencer_base sequencer_ptr, ovm_sequence_item sequence_ptr, integer set_priority = -1); 00166 ovm_sequence_base this_seq; 00167 ovm_sequencer_base target_seqr; 00168 00169 target_seqr = this.get_sequencer(); 00170 assert($cast(this_seq, sequence_ptr)); 00171 sequence_ptr.mid_do(this); 00172 target_seqr.send_request(this_seq, this); 00173 target_seqr.wait_for_item_done(this_seq, -1); 00174 if (target_seqr.recording_detail != OVM_NONE) begin 00175 target_seqr.end_tr(this); 00176 end 00177 00178 sequence_ptr.post_do(this); 00179 endtask // m_finish_item 00180 00181 // get_full_name 00182 // ------------- 00183 00184 function string get_full_name(); 00185 if(m_parent_sequence != null) 00186 get_full_name = {m_parent_sequence.get_full_name(), "."}; 00187 else if(m_sequencer!=null) 00188 get_full_name = {m_sequencer.get_full_name(), "."}; 00189 if(get_name() != "") 00190 get_full_name = {get_full_name, get_name()}; 00191 else begin 00192 ovm_sequence_item tmp; 00193 tmp = this; 00194 $swrite(get_full_name, "%sitem_", get_full_name, tmp); 00195 end 00196 endfunction 00197 00198 // get_root_sequence_name 00199 // --- 00200 00201 function string get_root_sequence_name(); 00202 ovm_sequence_base root_seq; 00203 root_seq = get_root_sequence(); 00204 if (root_seq == null) 00205 return ""; 00206 else 00207 return root_seq.get_name(); 00208 endfunction 00209 00210 virtual function void m_set_p_sequencer(); 00211 return; 00212 endfunction 00213 00214 // get_root_sequence 00215 // --- 00216 00217 function ovm_sequence_base get_root_sequence(); 00218 ovm_sequence_item root_seq_base; 00219 ovm_sequence_base root_seq; 00220 root_seq_base = this; 00221 while(1) begin 00222 if(root_seq_base.get_parent_sequence()!=null) begin 00223 root_seq_base = root_seq_base.get_parent_sequence(); 00224 $cast(root_seq, root_seq_base); 00225 end 00226 else 00227 return root_seq; 00228 end 00229 endfunction 00230 00231 // ovm_report_* should do this for the user for sequence messages!!! 00232 // get_sequence_path 00233 // ----------------- 00234 00235 function string get_sequence_path(); 00236 ovm_sequence_item this_item; 00237 string seq_path; 00238 this_item = this; 00239 seq_path = this.get_name(); 00240 while(1) begin 00241 if(this_item.get_parent_sequence()!=null) begin 00242 this_item = this_item.get_parent_sequence(); 00243 seq_path = {this_item.get_name(), ".", seq_path}; 00244 end 00245 else 00246 return seq_path; 00247 end 00248 endfunction 00249 00250 // do_print 00251 // -------- 00252 00253 function void do_print (ovm_printer printer); 00254 string temp_str1; 00255 int depth = get_depth(); 00256 super.do_print(printer); 00257 if(print_sequence_info || m_use_sequence_info) begin 00258 printer.print_field("depth", depth, $bits(depth), OVM_DEC, ".", "int"); 00259 if(m_parent_sequence != null) begin 00260 temp_str1 = m_parent_sequence.get_full_name(); 00261 end 00262 printer.print_string("parent sequence", temp_str1); 00263 temp_str1 = ""; 00264 if(m_sequencer != null) begin 00265 temp_str1 = m_sequencer.get_full_name(); 00266 end 00267 printer.print_string("sequencer", temp_str1); 00268 end 00269 endfunction 00270 00272 // 00273 // Deprecated functions 00274 // 00276 00277 function void set_parent_seq(ovm_sequence_base parent); 00278 static bit issued=0; 00279 if (!issued) begin 00280 issued=1; 00281 ovm_report_warning("deprecated", 00282 {"ovm_sequence_item::set_parent_seq() has been deprecated and ", 00283 "replaced by set_parent_sequence()"}); 00284 end 00285 set_parent_sequence(parent); 00286 endfunction 00287 00288 function ovm_sequence_base get_parent_seq(); 00289 static bit issued=0; 00290 if (!issued) begin 00291 issued=1; 00292 ovm_report_warning("deprecated", 00293 {"ovm_sequence_item::get_parent_seq() has been deprecated and ", 00294 "replaced by get_parent_sequence()"}); 00295 end 00296 return(get_parent_sequence()); 00297 endfunction // ovm_sequence_base 00298 00299 virtual task pre_do(bit is_item); 00300 return; 00301 endtask // pre_body 00302 00303 virtual task body(); 00304 return; 00305 endtask 00306 00307 virtual function void mid_do(ovm_sequence_item this_item); 00308 return; 00309 endfunction 00310 00311 virtual function void post_do(ovm_sequence_item this_item); 00312 return; 00313 endfunction 00314 00315 virtual task wait_for_grant(integer item_priority = -1, bit lock_request = 0); 00316 return; 00317 endtask 00318 00319 virtual function void send_request(ovm_sequence_item request, bit rerandomize = 0); 00320 return; 00321 endfunction 00322 00323 virtual task wait_for_item_done(integer transaction_id = -1); 00324 return; 00325 endtask // wait_for_item_done 00326 00327 endclass 00328 `endif
![]() Intelligent Design Verification Project: OVM, Revision: 2.0.1 |
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.5.5 Wed Jan 7 19:27:18 2009 |