00001 // $Id: ovm__sequencer__base_8sv-source.html,v 1.1 2008/10/07 21:54:32 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 00023 `include "methodology/sequences/ovm_sequencer_base.svh" 00024 `include "methodology/sequences/ovm_sequence.svh" 00025 00026 00027 // new 00028 // --- 00029 00030 function ovm_seq_prod_if::new (string name="", ovm_component parent = null); 00031 super.new(name, parent); 00032 $cast(parent_as_seqr, parent); 00033 endfunction 00034 00035 00036 // do_print 00037 // -------- 00038 00039 function void ovm_seq_prod_if::do_print (ovm_printer printer); 00040 super.do_print(printer); 00041 if (producer != null) 00042 printer.print_string("sequence producer", producer.get_full_name()); 00043 else 00044 printer.print_string("sequence producer", "NOT_CONNECTED"); 00045 endfunction 00046 00047 00048 // create 00049 // ------ 00050 00051 function ovm_object ovm_seq_prod_if::create (string name=""); 00052 ovm_seq_prod_if i; i=new(name); 00053 return i; 00054 endfunction 00055 00056 00057 // get_type_name 00058 // ------------- 00059 00060 function string ovm_seq_prod_if::get_type_name(); 00061 return "ovm_seq_prod_if"; 00062 endfunction 00063 00064 00065 // connect_if 00066 // ------------- 00067 00068 function void ovm_seq_prod_if::connect_if(ovm_seq_cons_if vseq_if); 00069 vseq_if.seqrb_ref = parent_as_seqr; 00070 producer = vseq_if.get_parent(); 00071 endfunction 00072 00073 00074 00075 // new 00076 // --- 00077 00078 function ovm_sequencer_base::new (string name, ovm_component parent); 00079 super.new(name, parent); 00080 $cast(seq_prod_if, create_component("ovm_seq_prod_if", "seq_prod_if")); 00081 void'(get_config_string("default_sequence", default_sequence)); 00082 void'(get_config_int("count", count)); 00083 void'(get_config_int("max_random_count", max_random_count)); 00084 endfunction 00085 00086 00087 //Implement data functions 00088 function void ovm_sequencer_base::do_copy (ovm_object rhs); 00089 ovm_sequencer_base seqr; 00090 super.do_copy(rhs); 00091 if(rhs == null) return; 00092 if(!$cast(seqr, rhs)) return; 00093 default_sequence = seqr.default_sequence; 00094 for(int i=0; i<seqr.sequences.size(); ++i) 00095 sequences[i] = seqr.sequences[i]; 00096 count = seqr.count; 00097 max_random_count = seqr.max_random_count; 00098 endfunction 00099 00100 function bit ovm_sequencer_base::do_compare (ovm_object rhs, 00101 ovm_comparer comparer); 00102 ovm_sequencer_base seqr; 00103 do_compare = 1; 00104 do_compare = super.do_compare(rhs, comparer); 00105 if(rhs == null) return 0; 00106 if(!$cast(seqr, rhs)) return 0; 00107 do_compare &= comparer.compare_string("default_sequence", default_sequence, 00108 seqr.default_sequence); 00109 for(int i=0; i<seqr.sequences.size(); ++i) 00110 do_compare &= comparer.compare_string($psprintf("sequences[%0d]", i), 00111 sequences[i], seqr.sequences[i]); 00112 do_compare &= comparer.compare_field_int("count", count, seqr.count, $bits(count)); 00113 do_compare &= comparer.compare_field_int("max_random_count", max_random_count, 00114 seqr.max_random_count, $bits(max_random_count), OVM_DEC); 00115 endfunction 00116 00117 function void ovm_sequencer_base::do_print (ovm_printer printer); 00118 super.do_print(printer); 00119 if(sequences.size() != 0) begin 00120 printer.print_string("default_sequence", default_sequence); 00121 printer.print_field("count", count, $bits(count), OVM_DEC); 00122 printer.print_field("max_random_count", max_random_count, 00123 $bits(max_random_count), OVM_DEC); 00124 printer.print_array_header("sequences", sequences.size()); 00125 for(int i=0; i<sequences.size(); ++i) 00126 printer.print_string($psprintf("[%0d]", i), sequences[i], "["); 00127 printer.print_array_footer(); 00128 end 00129 endfunction 00130 00131 function void ovm_sequencer_base::do_record (ovm_recorder recorder); 00132 super.do_record(recorder); 00133 recorder.record_string("default_sequence", default_sequence); 00134 for(int i=0; i<sequences.size(); ++i) 00135 recorder.record_string($psprintf("sequences[%0d]", i), sequences[i]); 00136 recorder.record_field("count", count, $bits(count), OVM_DEC); 00137 recorder.record_field("max_random_count", max_random_count, 00138 $bits(max_random_count), OVM_DEC); 00139 endfunction 00140 00141 00142 // add_sequence 00143 // ------------ 00144 00145 function void ovm_sequencer_base::add_sequence(string type_name); 00146 //assign typename key to an int based on size 00147 //used with get_seq_kind to return an int key to match a type name 00148 sequence_ids[type_name] = sequences.size(); 00149 //used w/ get_sequence to return a ovm_sequence factory object that 00150 //matches an int id 00151 sequences.push_back(type_name); 00152 endfunction 00153 00154 00155 // set_sequences_queue 00156 // ------------------- 00157 00158 function void ovm_sequencer_base::set_sequences_queue( 00159 ref string sequencer_sequence_lib[$]); 00160 for(int j=0; j < sequencer_sequence_lib.size(); j++) begin 00161 sequence_ids[sequencer_sequence_lib[j]] = sequences.size(); 00162 this.sequences.push_back(sequencer_sequence_lib[j]); 00163 end 00164 begin end 00165 endfunction 00166 00167 00168 // run phase 00169 // --- 00170 00171 task ovm_sequencer_base::run(); 00172 start_default_sequence(); 00173 endtask 00174 00175 00176 // start_default_sequence 00177 // ---------------------- 00178 00179 //Executed by run() 00180 task ovm_sequencer_base::start_default_sequence(); 00181 00182 ovm_sequence m_seq ; 00183 00184 if(sequences.size() != 0) begin 00185 00186 //get id of default sequence, even if type overrided by user 00187 //this provides a check that the default_sequence is in this sequencer's 00188 //library 00189 seq_kind = get_seq_kind(default_sequence); 00190 00191 //create the sequence object 00192 if (!$cast(m_seq, ovm_factory::create_object(default_sequence, 00193 get_full_name(), default_sequence))) 00194 begin 00195 ovm_report_fatal("FCTSEQ", 00196 $psprintf("Default sequence set to invalid value : %0s.", 00197 default_sequence)); 00198 end 00199 00200 m_seq.print_sequence_info = 1; 00201 m_seq.set_sequencer(this); 00202 assert(m_seq.randomize()); 00203 00204 if(count != 0) 00205 start_sequence(m_seq); 00206 00207 end 00208 00209 endtask 00210 00211 00212 // start_sequence 00213 // -------------- 00214 00215 task ovm_sequencer_base::start_sequence(ovm_sequence this_seq, 00216 ovm_sequencer_base this_seqr=null); 00217 //set parent_seq to null to start new sequence tree 00218 this_seq.set_parent_seq(null); 00219 if (this_seqr == null) 00220 this_seq.set_sequencer(this); 00221 else 00222 this_seq.set_sequencer(this_seqr); 00223 this_seq.depth = 1; 00224 fork 00225 begin 00226 if (this.recording_detail != OVM_NONE) 00227 this_seq.tr_handle = begin_tr(this_seq, this_seq.get_name()); 00228 ->this_seq.started; 00229 this_seq.pre_body(); 00230 this_seq.body(); 00231 this_seq.post_body(); 00232 ->this_seq.ended; 00233 if (this.recording_detail != OVM_NONE) 00234 end_tr(this_seq); 00235 end 00236 join_none 00237 endtask 00238 00239 00240 // get_seq_kind 00241 // ------------ 00242 00243 // Return a unique sequence id given the name of a sequence. 00244 // This id is expected to be used in inline constraints. 00245 function int ovm_sequencer_base::get_seq_kind(string type_name); 00246 00247 if (sequence_ids.exists(type_name)) 00248 return sequence_ids[type_name]; 00249 00250 ovm_report_fatal("SEQNF", 00251 $psprintf("Sequence type_name '%0s' not registered with this sequencer.", 00252 type_name)); 00253 00254 endfunction 00255 00256 00257 // get_sequence 00258 // ------------ 00259 00260 function ovm_sequence ovm_sequencer_base::get_sequence(int req_kind); 00261 00262 ovm_sequence m_seq ; 00263 string m_seq_type; 00264 00265 if (req_kind < 0 || req_kind >= sequences.size()) begin 00266 ovm_report_error("SEQRNG", 00267 $psprintf("Kind arg '%0d' out of range. Need 0-%0d", 00268 req_kind, sequences.size()-1)); 00269 end 00270 00271 m_seq_type = sequences[req_kind]; 00272 if (!$cast(m_seq, ovm_factory::create_object(m_seq_type, 00273 get_full_name(), 00274 m_seq_type))) 00275 begin 00276 ovm_report_fatal("FCTSEQ", 00277 $psprintf("Factory can not produce a sequence of type %0s.", 00278 m_seq_type)); 00279 end 00280 00281 m_seq.print_sequence_info = 1; 00282 m_seq.set_sequencer (this); 00283 return m_seq; 00284 00285 endfunction 00286 00287
![]() 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:20:12 2008 |