ovm_sequence.sv

Go to the documentation of this file.
00001 // $Id: ovm__sequence_8sv-source.html,v 1.1 2008/10/07 21:54:35 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 "methodology/sequences/ovm_sequence.svh"
00023 
00024 
00025 // new
00026 // ---
00027 
00028 function ovm_sequence::new (string name="ovm_sequence",  
00029   ovm_sequencer_base sequencer=null,
00030   ovm_sequence parent_seq=null);
00031   super.new(name, sequencer, parent_seq);
00032   id = g_id++;
00033 endfunction
00034 
00035 
00036 // get_id
00037 // ------
00038 
00039 function int ovm_sequence::get_id();
00040   return id;
00041 endfunction
00042 
00043 
00044 // m_set_b_sequencer
00045 // -----------------
00046 
00047 function void ovm_sequence::m_set_b_sequencer();
00048   if($cast(b_sequencer, m_sequencer))
00049     begin end
00050 endfunction
00051 
00052 
00053 // pre_body
00054 // --------
00055 
00056 task ovm_sequence::pre_body();
00057   begin end
00058 endtask
00059 
00060 
00061 // body
00062 // ----
00063 
00064 task ovm_sequence::body();
00065   begin end
00066 endtask
00067 
00068 
00069 // post_body
00070 // ---------
00071 
00072 task ovm_sequence::post_body();
00073   begin end
00074 endtask
00075 
00076 
00077 // pre_do
00078 // ------
00079 
00080 task ovm_sequence::pre_do(bit is_item);
00081   begin end
00082 endtask
00083 
00084 
00085 // mid_do
00086 // ------
00087 
00088 function void ovm_sequence::mid_do(ovm_sequence_item this_item);
00089   begin end
00090 endfunction
00091 
00092 
00093 // post_do
00094 // -------
00095 
00096 function void ovm_sequence::post_do(ovm_sequence_item this_item);
00097   begin end
00098 endfunction
00099 
00100 
00101 // wait_for_relevant
00102 // -----------------
00103 
00104 task ovm_sequence::wait_for_relevant();
00105   event e;
00106   wait_rel_default = 1;
00107   if (is_rel_default != wait_rel_default)
00108     ovm_report_fatal("RELMSM", 
00109       "is_relevant() was implemented without defining wait_for_relevant()");
00110   @e;  // this is intended to never return
00111 endtask
00112 
00113 // is_relevant
00114 // -----------
00115 
00116 function bit ovm_sequence::is_relevant(); 
00117   is_rel_default = 1;
00118   return 1;
00119 endfunction
00120 
00121 
00122 // is_item
00123 // -------
00124 
00125 function int ovm_sequence::is_item(); 
00126   return 0;
00127 endfunction
00128 
00129 
00130 // get_sequence
00131 // ------------
00132 
00133 function ovm_sequence ovm_sequence::get_sequence(int req_kind);
00134   ovm_sequence m_seq;
00135   string m_seq_type;
00136   if (req_kind < 0 || req_kind >= m_sequencer.sequences.size()) begin
00137     ovm_report_error("SEQRNG", 
00138       $psprintf("Kind arg '%0d' out of range. Need 0-%0d",
00139       req_kind,m_sequencer.sequences.size()-1));
00140   end
00141   m_seq_type = m_sequencer.sequences[req_kind];
00142   if (!$cast(m_seq, ovm_factory::create_object(m_seq_type, get_full_name(), 
00143     m_seq_type))) 
00144   begin
00145     ovm_report_fatal("FCTSEQ", 
00146       $psprintf("Factory can not produce a sequence of type %0s.",
00147       m_seq_type));
00148   end
00149   m_seq.print_sequence_info = 1;
00150   return m_seq;
00151 endfunction
00152 
00153 
00154 // get_seq_kind
00155 // --------
00156 
00157 function int ovm_sequence::get_seq_kind(string type_name);
00158   if(m_sequencer)
00159     return m_sequencer.get_seq_kind(type_name);
00160   else 
00161     ovm_report_fatal("NULLSQ", $psprintf("%0s sequencer is null.",
00162       get_type_name()));
00163 endfunction
00164 
00165 
00166 // do_sequence_kind
00167 // ----------------
00168 
00169 task ovm_sequence::do_sequence_kind(int unsigned req_kind);
00170   string m_seq_type;
00171   ovm_sequence m_seq ;
00172   m_seq_type = m_sequencer.sequences[req_kind];
00173 
00174   if (!$cast(m_seq, ovm_factory::create_object(m_seq_type, get_full_name(),
00175     m_seq_type))) 
00176     ovm_report_fatal("FCTSEQ", 
00177       $psprintf("Factory can not produce a sequence of type %0s.", m_seq_type));
00178   m_seq.print_sequence_info = 1;
00179   m_seq.depth = this.depth + 1;
00180   m_seq.set_parent_seq(this);
00181   m_seq.set_sequencer(m_sequencer);
00182   this.pre_do(0); 
00183   //randomize the sequence
00184   assert(m_seq.randomize()) else $fatal;
00185   this.mid_do(m_seq);
00186   ->m_seq.started;
00187   m_seq.body();
00188   ->m_seq.ended;
00189   this.post_do(m_seq);
00190 endtask
00191 
00192 
00193 // create_item
00194 // -----------
00195 
00196 function ovm_sequence_item ovm_sequence::create_item(
00197   ovm_sequence_item type_var, ovm_sequencer_base l_sequencer);
00198 
00199   if (!type_var.is_item()) begin
00200     void'(l_sequencer.get_seq_kind(type_var.get_type_name()));
00201   end
00202 
00203   if (!$cast( type_var , ovm_factory::create_object( type_var.get_type_name(),
00204     this.get_full_name(), type_var.get_name())))
00205   begin
00206     ovm_report_error("FCTRYF", 
00207       $psprintf("Factory could not produce an object of type %0s",
00208       type_var.get_type_name()));
00209   end
00210 
00211   type_var.print_sequence_info = 1;
00212   type_var.set_parent_seq(this);
00213   type_var.set_sequencer(l_sequencer);
00214   type_var.depth = this.depth + 1;
00215   type_var.reseed();
00216   return type_var;
00217 
00218 endfunction
00219 
00220 
00221 // m_sync
00222 // ------
00223 
00224 task ovm_sequence::m_sync(ovm_sequence_item item);
00225   ovm_event ack_process;
00226   ack_process = new({"ack_", item.get_name()});
00227   b_sequencer.m_sequencer_sync(item.get_name(), this, ack_process);
00228   ack_process.wait_trigger();
00229   #0;
00230   if (m_sequencer.recording_detail != OVM_NONE) begin
00231     //record sequence item into aggregate items stream
00232     void'(m_sequencer.begin_tr(item, "aggregate items"));
00233   end
00234 endtask
00235 
00236 
00237 // start_item
00238 // ----------
00239 
00240 task ovm_sequence::start_item(ovm_sequence_item type_var);
00241 
00242   if (type_var.is_item()) begin 
00243     //register with sequencer and begin processing of ovm_sequence_item objects
00244     this.m_sync(type_var);
00245     this.pre_do(1);
00246   end 
00247   //is sequence
00248   else begin 
00249     if (m_sequencer.recording_detail != OVM_NONE)
00250       //record sequences into m_get_root_sequence_name() stream
00251       type_var.tr_handle = m_sequencer.begin_child_tr(
00252         type_var,                          //ovm_transaction tr
00253         type_var.m_parent_seq.tr_handle,   //parent tr_handle
00254         m_get_root_sequence_name()         //string stream_name
00255         );
00256     this.pre_do(0);
00257   end
00258 
00259 endtask
00260 
00261 
00262 // m_post_sync
00263 // -----------
00264 
00265 task ovm_sequence::m_post_sync(ovm_sequence_item item);
00266   b_sequencer.m_last_push_front(item);
00267   b_sequencer.m_item_ready_trigger(item);
00268   b_sequencer.item_done_wait_trigger_data(item); /* wait until driver
00269                                                   completes the item and 
00270                                                   signals item_done_trigger()
00271                                                   */
00272 endtask
00273 
00274 
00275 // finish_item
00276 // -----------
00277 
00278 task ovm_sequence::finish_item( ovm_sequence_item type_var );
00279 
00280   ovm_sequence m_seq;
00281 
00282   //complete processing of ovm_sequence
00283   //for ovm_sequence_item, call mid_do(), send to m_post_sync(), and post_do()
00284   this.mid_do(type_var);
00285   if(type_var.is_item()) begin
00286     this.m_post_sync( type_var );
00287   end
00288   else begin //is sequence 
00289     //for ovm_sequence, call body()
00290     $cast(m_seq, type_var);
00291     //allow users to detect started when a subsequence body()
00292     //calls ovm_do immediately
00293     #0 -> m_seq.started;
00294     m_seq.body();
00295     -> m_seq.ended;
00296   end
00297   this.post_do(type_var);
00298   m_sequencer.end_tr(type_var);
00299 
00300 endtask
00301 
00302 
00303 // grab()
00304 // ------
00305                                                                                 
00306 task ovm_sequence::grab(ovm_sequencer sequencer = null);
00307   if (sequencer == null)
00308     b_sequencer.grab(this);
00309   else
00310     sequencer.grab(this);
00311 endtask
00312                                                                                 
00313                                                                                 
00314 // ungrab()
00315 // ------
00316                                                                                 
00317 function void ovm_sequence::ungrab(ovm_sequencer sequencer = null);
00318   if (sequencer == null)
00319     b_sequencer.ungrab(this);
00320   else
00321     sequencer.ungrab(this);
00322 endfunction
00323 
00324 
00325 // is_blocked()
00326 // ------
00327                                                                                 
00328 function bit ovm_sequence::is_blocked();
00329    return m_block_status;
00330 endfunction
00331 
00332 
00333 // m_set_is_blocked()
00334 // ------
00335                                                                                 
00336 function void ovm_sequence::m_set_is_blocked(bit block_status);
00337    m_block_status = block_status;
00338 endfunction
00339 
00340 
00341 // stop()
00342 // ------
00343                                                                                 
00344 function void ovm_sequence::stop();
00345    disable body;
00346 endfunction
00347 
00348 
00349 // pre_apply
00350 // ---------
00351 
00352 task ovm_sequence::pre_apply();
00353   begin end
00354 endtask
00355 
00356 
00357 // mid_apply
00358 // ---------
00359 
00360 task ovm_sequence::mid_apply();
00361   begin end
00362 endtask
00363 
00364 
00365 // post_apply
00366 // ---------
00367 
00368 task ovm_sequence::post_apply();
00369   begin end
00370 endtask
00371 
00372 
00373 // apply
00374 // -----
00375 
00376 task ovm_sequence::apply(ovm_sequence_item req, output ovm_sequence_item
00377   rsp);
00378   b_sequencer.apply(req,this);
00379   $cast(rsp, b_sequencer.item_done.get_trigger_data());
00380 endtask
00381 
00382 
00383 // start
00384 // -----
00385 
00386 task ovm_sequence::start(ovm_sequencer_base sequencer, ovm_sequence
00387   parent_seq = null);
00388   set_sequencer(sequencer);
00389   set_parent_seq(parent_seq);
00390   pre_body();
00391   body();
00392   post_body();
00393 endtask

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