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 integer m_next_transaction_id = 1; 00033 protected ovm_sequencer_base m_sequencer = null; 00034 protected ovm_sequence_base m_parent_sequence = null; 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 m_sequencer = sequencer; 00042 m_parent_sequence = parent_sequence; 00043 endfunction // new 00044 00045 function string get_type_name(); 00046 return "ovm_sequence_item"; 00047 endfunction 00048 00049 // Macro for factory creation 00050 `ovm_object_registry(ovm_sequence_item, "ovm_sequence_item") 00051 00052 function void set_sequence_id(integer id); 00053 m_sequence_id = id; 00054 endfunction 00055 00056 function integer get_sequence_id(); 00057 return (m_sequence_id); 00058 endfunction 00059 00060 function void set_use_sequence_info(bit value); 00061 m_use_sequence_info = value; 00062 endfunction 00063 00064 function bit get_use_sequence_info(); 00065 return (m_use_sequence_info); 00066 endfunction 00067 00068 function void set_id_info(ovm_sequence_item item); 00069 assert (item != null) else begin 00070 ovm_report_fatal(get_full_name(), "set_id_info called with null parameter"); 00071 end 00072 this.set_transaction_id(item.get_transaction_id()); 00073 this.set_sequence_id(item.get_sequence_id()); 00074 endfunction 00075 00076 function void set_sequencer(ovm_sequencer_base sequencer); 00077 m_sequencer = sequencer; 00078 m_set_p_sequencer(); 00079 endfunction // void 00080 00081 function ovm_sequencer_base get_sequencer(); 00082 return (m_sequencer); 00083 endfunction // ovm_sequencer_base 00084 00085 function void set_parent_sequence(ovm_sequence_base parent); 00086 m_parent_sequence = parent; 00087 endfunction 00088 00089 function ovm_sequence_base get_parent_sequence(); 00090 return (m_parent_sequence); 00091 endfunction 00092 00093 function void set_depth(integer value); 00094 m_depth = value; 00095 endfunction 00096 00097 function integer get_depth(); 00098 00099 // If depth has been set or calculated, then use that 00100 if (m_depth != -1) begin 00101 return (m_depth); 00102 end 00103 00104 // Calculate the depth, store it, and return the value 00105 if (m_parent_sequence == null) begin 00106 m_depth = 1; 00107 end else begin 00108 m_depth = m_parent_sequence.get_depth() + 1; 00109 end 00110 00111 return (m_depth); 00112 endfunction 00113 00114 virtual function bit is_item(); 00115 return(1); 00116 endfunction 00117 00118 virtual task start_item(ovm_sequence_item item); 00119 if(item == null) 00120 m_sequencer.ovm_report_fatal("NULLITM", {"attempting to start a null item from item/sequence '", get_full_name(), "'"}); 00121 item.m_start_item(m_sequencer, this); 00122 endtask 00123 00124 virtual task finish_item(ovm_sequence_item item, integer set_priority = -1); 00125 item.m_finish_item(item.get_sequencer(), this, set_priority); 00126 endtask // finish_item 00127 00128 virtual task m_start_item(ovm_sequencer_base sequencer_ptr, ovm_sequence_item sequence_ptr); 00129 ovm_sequence_base this_seq; 00130 00131 assert($cast(this_seq, sequence_ptr)); 00132 m_sequencer.wait_for_grant(this_seq); 00133 if (m_sequencer.recording_detail != OVM_NONE) begin 00134 void'(m_sequencer.begin_tr(this, "aggregate items")); 00135 end 00136 sequence_ptr.pre_do(1); 00137 endtask 00138 00139 virtual task m_finish_item(ovm_sequencer_base sequencer_ptr, ovm_sequence_item sequence_ptr, integer set_priority = -1); 00140 ovm_sequence_base this_seq; 00141 00142 assert($cast(this_seq, sequence_ptr)); 00143 sequence_ptr.mid_do(this); 00144 m_parent_sequence.send_request(this); 00145 m_sequencer.wait_for_item_done(this_seq, -1); 00146 if (m_sequencer.recording_detail != OVM_NONE) begin 00147 m_sequencer.end_tr(this); 00148 end 00149 sequence_ptr.post_do(this); 00150 endtask // m_finish_item 00151 00152 // get_full_name 00153 // ------------- 00154 00155 function string get_full_name(); 00156 if(m_parent_sequence != null) 00157 get_full_name = {m_parent_sequence.get_full_name(), "."}; 00158 else if(m_sequencer!=null) 00159 get_full_name = {m_sequencer.get_full_name(), "."}; 00160 if(get_name() != "") 00161 get_full_name = {get_full_name, get_name()}; 00162 else begin 00163 ovm_sequence_item tmp; 00164 tmp = this; 00165 $swrite(get_full_name, "%sitem_", get_full_name, tmp); 00166 end 00167 endfunction 00168 00169 // get_root_sequence_name 00170 // --- 00171 00172 function string get_root_sequence_name(); 00173 ovm_sequence_base root_seq; 00174 root_seq = get_root_sequence(); 00175 if (root_seq == null) 00176 return ""; 00177 else 00178 return root_seq.get_name(); 00179 endfunction 00180 00181 virtual function void m_set_p_sequencer(); 00182 return; 00183 endfunction 00184 00185 // get_root_sequence 00186 // --- 00187 00188 function ovm_sequence_base get_root_sequence(); 00189 ovm_sequence_item root_seq_base; 00190 ovm_sequence_base root_seq; 00191 root_seq_base = this; 00192 while(1) begin 00193 if(root_seq_base.get_parent_seq()!=null) begin 00194 root_seq_base = root_seq_base.get_parent_seq(); 00195 $cast(root_seq, root_seq_base); 00196 end 00197 else 00198 return root_seq; 00199 end 00200 endfunction 00201 00202 // ovm_report_* should do this for the user for sequence messages!!! 00203 // get_sequence_path 00204 // ----------------- 00205 00206 function string get_sequence_path(); 00207 ovm_sequence_item this_item; 00208 string seq_path; 00209 this_item = this; 00210 seq_path = this.get_name(); 00211 while(1) begin 00212 if(this_item.get_parent_seq()!=null) begin 00213 this_item = this_item.get_parent_seq(); 00214 seq_path = {this_item.get_name(), ".", seq_path}; 00215 end 00216 else 00217 return seq_path; 00218 end 00219 endfunction 00220 00221 // do_print 00222 // -------- 00223 00224 function void do_print (ovm_printer printer); 00225 string temp_str1; 00226 int depth = get_depth(); 00227 super.do_print(printer); 00228 if(print_sequence_info || m_use_sequence_info) begin 00229 printer.print_field("depth", depth, $bits(depth), OVM_DEC, ".", "int"); 00230 if(m_parent_sequence != null) begin 00231 temp_str1 = m_parent_sequence.get_full_name(); 00232 end 00233 printer.print_string("parent sequence", temp_str1); 00234 temp_str1 = ""; 00235 if(m_sequencer != null) begin 00236 temp_str1 = m_sequencer.get_full_name(); 00237 end 00238 printer.print_string("sequencer", temp_str1); 00239 end 00240 endfunction 00241 00243 // 00244 // Deprecated functions 00245 // 00247 00248 function void set_parent_seq(ovm_sequence_base parent); 00249 set_parent_sequence(parent); 00250 endfunction 00251 00252 function ovm_sequence_base get_parent_seq(); 00253 return(get_parent_sequence()); 00254 endfunction // ovm_sequence_base 00255 00256 virtual task pre_do(bit is_item); 00257 return; 00258 endtask // pre_body 00259 00260 virtual task body(); 00261 return; 00262 endtask 00263 00264 virtual function void mid_do(ovm_sequence_item this_item); 00265 return; 00266 endfunction 00267 00268 virtual function void post_do(ovm_sequence_item this_item); 00269 return; 00270 endfunction 00271 00272 virtual task wait_for_grant(integer item_priority = -1, bit lock_request = 0); 00273 return; 00274 endtask 00275 00276 virtual function void send_request(ovm_sequence_item request, bit rerandomize = 0); 00277 return; 00278 endfunction 00279 00280 virtual task wait_for_item_done(integer transaction_id = -1); 00281 return; 00282 endtask // wait_for_item_done 00283 00284 endclass 00285 `endif
![]() 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 |