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 00022 typedef class ovm_sequence_base; 00023 00024 class ovm_sequencer_param_base #(type REQ = ovm_sequence_item, 00025 type RSP = REQ) extends ovm_sequencer_base; 00026 00027 typedef ovm_sequencer_param_base #( REQ , RSP) this_type; 00028 00029 // static bit sequences[string] = '{default:0}; 00030 00031 REQ m_last_req_buffer[$]; 00032 RSP m_last_rsp_buffer[$]; 00033 00034 protected int m_num_last_reqs = 1; 00035 protected int num_last_items = m_num_last_reqs; 00036 protected int m_num_last_rsps = 1; 00037 protected int m_num_reqs_sent = 0; 00038 protected int m_num_rsps_received = 0; 00039 00040 // Response Analysis Fifo 00041 ovm_analysis_export #(RSP) rsp_export; 00042 sequencer_analysis_fifo #(RSP) sqr_rsp_analysis_fifo; 00043 00044 // Fifo for handing reqests between scenario and driver 00045 tlm_fifo #(REQ) m_req_fifo; 00046 00047 function new (string name, ovm_component parent); 00048 super.new(name, parent); 00049 00050 rsp_export = new("rsp_export", this); 00051 sqr_rsp_analysis_fifo = new("sqr_rsp_analysis_fifo", this); 00052 sqr_rsp_analysis_fifo.print_enabled = 0; 00053 m_req_fifo = new("req_fifo", this); 00054 m_req_fifo.print_enabled = 0; 00055 endfunction // new 00056 00057 function void do_print (ovm_printer printer); 00058 super.do_print(printer); 00059 printer.print_field("num_last_reqs", m_num_last_reqs, $bits(m_num_last_reqs), OVM_DEC); 00060 printer.print_field("num_last_rsps", m_num_last_rsps, $bits(m_num_last_rsps), OVM_DEC); 00061 endfunction 00062 00063 function void connect(); 00064 rsp_export.connect(sqr_rsp_analysis_fifo.analysis_export); 00065 endfunction // void 00066 00067 virtual function void build(); 00068 super.build(); 00069 sqr_rsp_analysis_fifo.sequencer_ptr = this; 00070 endfunction // function 00071 00073 // 00074 // Local functions 00075 // 00077 00078 00080 // 00081 // Methods available to Sequencers 00082 // 00084 00085 virtual function void send_request(ovm_sequence_base sequence_ptr, ovm_sequence_item t, bit rerandomize = 0); 00086 REQ param_t; 00087 00088 assert($cast(param_t, t)); 00089 m_last_req_push_front(param_t); 00090 00091 param_t.set_sequence_id(sequence_ptr.m_get_sqr_sequence_id(m_sequencer_id, 1)); 00092 t.set_sequencer(this); 00093 if (m_req_fifo.try_put(param_t) != 1) begin 00094 ovm_report_fatal(get_full_name(), 00095 $psprintf("Sequencer send_request not able to put to fifo, depth; %0d", m_req_fifo.size())); 00096 end 00097 00098 m_num_reqs_sent++; 00099 // Grant any locks as soon as possible 00100 grant_queued_locks(); 00101 endfunction 00102 00103 function REQ get_current_item(); 00104 REQ t; 00105 00106 if (m_req_fifo.try_peek(t) == 0) begin 00107 return (null); 00108 end 00109 return(t); 00110 endfunction // REQ 00111 00112 function void put_response (RSP t); 00113 ovm_sequence_base sequence_ptr; 00114 00115 m_last_rsp_push_front(t); 00116 m_num_rsps_received++; 00117 00118 sequence_ptr = find_sequence(t.get_sequence_id()); 00119 00120 if (sequence_ptr != null) begin 00121 // If the response_handler is enabled for this sequence, then call the response handler 00122 if (sequence_ptr.get_use_response_handler() == 1) begin 00123 sequence_ptr.response_handler(t); 00124 return; 00125 end 00126 00127 sequence_ptr.put_response(t); 00128 end 00129 else begin 00130 ovm_report_info("Sequencer", $psprintf("Dropping response for sequence %0d, sequence not found", t.get_sequence_id())); 00131 end 00132 endfunction // void 00133 00134 virtual function void analysis_write(ovm_sequence_item t); 00135 RSP response; 00136 00137 assert($cast(response, t)); 00138 put_response(response); 00139 endfunction 00140 00141 // start_default_sequence 00142 // ---------------------- 00143 00144 task start_default_sequence(); 00145 ovm_sequence_base m_seq ; 00146 00147 if(sequences.size() != 0) begin 00148 00149 //create the sequence object 00150 if (!$cast(m_seq, ovm_factory::create_object(default_sequence, 00151 get_full_name(), default_sequence))) 00152 begin 00153 ovm_report_fatal("FCTSEQ", 00154 $psprintf("Default sequence set to invalid value : %0s.", 00155 default_sequence)); 00156 end 00157 00158 assert(m_seq != null); 00159 m_seq.print_sequence_info = 1; 00160 assert(m_seq.randomize()); 00161 00162 if(count != 0) 00163 m_seq.start(this); 00164 end 00165 endtask 00166 00167 task run(); 00168 start_default_sequence(); 00169 endtask // run 00170 00171 // get_num_reqs_sent 00172 // ----------------- 00173 00174 function int get_num_reqs_sent(); 00175 return m_num_reqs_sent; 00176 endfunction 00177 00178 // get_num_rsps_sent 00179 // ----------------- 00180 00181 function int get_num_rsps_received(); 00182 return m_num_rsps_received; 00183 endfunction 00184 00185 // set_num_last_reqs 00186 // ----------------- 00187 00188 function void set_num_last_reqs(int unsigned max); 00189 if(max > 1024) begin 00190 ovm_report_warning("HSTOB", 00191 $psprintf("Invalid last size; 1024 is the maximum and will be used", max)); 00192 max = 1024; 00193 end 00194 00195 //shrink the buffer 00196 while((m_last_req_buffer.size() != 0) && (m_last_req_buffer.size() > max)) begin 00197 void'(m_last_req_buffer.pop_back()); 00198 end 00199 00200 m_num_last_reqs = max; 00201 num_last_items = max; 00202 00203 endfunction 00204 00205 // get_num_last_reqs 00206 // ----------------- 00207 00208 function int unsigned get_num_last_reqs(); 00209 return m_num_last_reqs; 00210 endfunction 00211 00212 // last_req 00213 // -------- 00214 00215 function REQ last_req(int unsigned n = 0); 00216 if(n > m_num_last_reqs) begin 00217 ovm_report_warning("HSTOB", 00218 $psprintf("Invalid last access (%0d), the max history is %0d", n, 00219 m_num_last_reqs)); 00220 return null; 00221 end 00222 if(n == m_last_req_buffer.size()) 00223 return null; 00224 00225 return m_last_req_buffer[n]; 00226 endfunction 00227 00228 // m_last_req_push_front 00229 // -------------- 00230 00231 function void m_last_req_push_front(REQ item); 00232 if(!m_num_last_reqs) 00233 return; 00234 00235 if(m_last_req_buffer.size() == m_num_last_reqs) 00236 void'(m_last_req_buffer.pop_back()); 00237 00238 this.m_last_req_buffer.push_front(item); 00239 endfunction 00240 00241 // set_num_last_rsps 00242 // ----------------- 00243 00244 function void set_num_last_rsps(int unsigned max); 00245 if(max > 1024) begin 00246 ovm_report_warning("HSTOB", 00247 $psprintf("Invalid last size; 1024 is the maximum and will be used", max)); 00248 max = 1024; 00249 end 00250 00251 //shrink the buffer 00252 while((m_last_rsp_buffer.size() != 0) && (m_last_rsp_buffer.size() > max)) begin 00253 void'(m_last_rsp_buffer.pop_back()); 00254 end 00255 00256 m_num_last_rsps = max; 00257 00258 endfunction 00259 00260 // get_num_last_rsps 00261 // ----------------- 00262 00263 function int unsigned get_num_last_rsps(); 00264 return m_num_last_rsps; 00265 endfunction 00266 00267 // last_rsp 00268 // -------- 00269 00270 function RSP last_rsp(int unsigned n = 0); 00271 if(n > m_num_last_rsps) begin 00272 ovm_report_warning("HSTOB", 00273 $psprintf("Invalid last access (%0d), the max history is %0d", n, 00274 m_num_last_rsps)); 00275 return null; 00276 end 00277 if(n == m_last_rsp_buffer.size()) 00278 return null; 00279 00280 return m_last_rsp_buffer[n]; 00281 endfunction 00282 00283 // m_last_rsp_push_front 00284 // -------------- 00285 00286 function void m_last_rsp_push_front(RSP item); 00287 if(!m_num_last_rsps) 00288 return; 00289 00290 if(m_last_rsp_buffer.size() == m_num_last_rsps) 00291 void'(m_last_rsp_buffer.pop_back()); 00292 00293 this.m_last_rsp_buffer.push_front(item); 00294 endfunction 00295 00296 virtual task execute_item(ovm_sequence_item item); 00297 ovm_sequence_base temp_seq; 00298 00299 temp_seq = new(); 00300 item.set_sequencer(this); 00301 item.set_parent_sequence(temp_seq); 00302 temp_seq.set_sequencer(this); 00303 temp_seq.start_item(item); 00304 temp_seq.finish_item(item); 00305 endtask // execute_item 00306 00308 // 00309 // Backwards Compat 00310 // 00312 00313 // set_num_last_items 00314 // ---------------- 00315 00316 function void set_num_last_items(int unsigned max); 00317 set_num_last_reqs(max); 00318 endfunction 00319 00320 // last 00321 // ---- 00322 00323 function ovm_sequence_item last(int unsigned n); 00324 return last_req(n); 00325 endfunction 00326 00327 endclass 00328 00329 00330
![]() 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 |