00001 // $Id: ovm__scenario__driver_8svh-source.html,v 1.1 2008/10/07 21:54:55 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 typedef class ovm_scenario_driver_base; 00024 typedef class ovm_scenario_controller_base; 00025 typedef class ovm_scenario_base; 00026 00027 class ovm_scenario_driver_base extends ovm_threaded_component; 00028 00029 protected ovm_scenario_controller_base m_scenario_controller_ptr; 00030 protected ovm_scenario_base scenario_base_ptr; 00031 00032 function new (string name, ovm_component parent); 00033 super.new(name, parent); 00034 endfunction // new 00035 00036 function void set_scenario_controller(ovm_scenario_controller_base scenario_controller_ptr); 00037 m_scenario_controller_ptr = scenario_controller_ptr; 00038 endfunction 00039 00040 task run(); 00041 return; 00042 endtask // run 00043 00044 endclass 00045 00047 // 00048 // Use the ovm_scenario_driver class if the driver only needs 00049 // to pass a single ovm_transaction back and forth 00050 // for each operation. 00052 00053 class tlm_scenario_fifo #(type T = int) extends tlm_fifo #(T); 00054 00055 //-------------------------------------------------------------------- 00056 // constructor (new) 00057 //-------------------------------------------------------------------- 00058 function new(string name, ovm_component parent = null, int size = 1); 00059 super.new(name, parent); 00060 endfunction // new 00061 00062 task wait_for_pending_get(); 00063 wait(m_pending_blocked_gets > 0); 00064 endtask // wait_for_pending_get 00065 00066 function bit pending_get_in_progress(); 00067 return (m_pending_blocked_gets > 0); 00068 endfunction // bit 00069 00070 endclass 00071 00072 class tlm_scenario_req_rsp_channel #( type REQ = int , type RSP = int ) 00073 extends tlm_req_rsp_channel #(REQ, RSP); 00074 00075 tlm_scenario_fifo #( REQ ) m_scenario_request_fifo; 00076 00077 function new( string name , ovm_component parent = null , 00078 int request_fifo_size = 1 , 00079 int response_fifo_size = 1 ); 00080 super.new(name, parent, request_fifo_size, response_fifo_size); 00081 m_scenario_request_fifo = new("scenario_request_fifo", this, request_fifo_size); 00082 m_request_fifo = m_scenario_request_fifo; 00083 00084 endfunction // new 00085 00086 function bit pending_get_in_progress(); 00087 return (m_scenario_request_fifo.pending_get_in_progress()); 00088 endfunction // bit 00089 00090 task wait_for_pending_get(); 00091 m_scenario_request_fifo.wait_for_pending_get(); 00092 endtask // wait_for_pending_get 00093 00094 endclass 00095 00096 virtual class ovm_scenario_driver #(type REQ = ovm_transaction, type RSP = ovm_transaction) 00097 extends ovm_scenario_driver_base; 00098 00099 typedef ovm_scenario_driver #(REQ, RSP) p_drv; 00100 00101 tlm_scenario_req_rsp_channel #(REQ, RSP) req_rsp; 00102 ovm_blocking_get_export #(REQ) get_req_export; 00103 ovm_blocking_put_export #(RSP) put_rsp_export; 00104 ovm_blocking_get_export #(REQ) get_req; 00105 ovm_blocking_put_export #(REQ) put_req; 00106 ovm_blocking_put_export #(RSP) put_rsp; 00107 ovm_blocking_get_export #(RSP) get_rsp; 00108 00109 00110 00111 00112 function new (string name, ovm_component parent); 00113 super.new(name, parent); 00114 req_rsp = new("sqrdrv_req_rsp", this); 00115 put_req = new("sqrdrv_put_req", this); 00116 get_rsp = new("sqrdrv_get_rsp", this); 00117 put_rsp = new("sqrdrv_put_rsp", this); 00118 get_req = new("sqrdrv_get_req", this); 00119 get_req_export = new("sqrdrv_get_req_export", this); 00120 put_rsp_export = new("sqrdrv_put_rsp_export", this); 00121 00122 get_req.connect(req_rsp.blocking_get_request_export); 00123 put_req.connect(req_rsp.blocking_put_request_export); 00124 get_rsp.connect(req_rsp.blocking_get_response_export); 00125 put_rsp.connect(req_rsp.blocking_put_response_export); 00126 get_req_export.connect(req_rsp.blocking_get_request_export); 00127 put_rsp_export.connect(req_rsp.blocking_put_response_export); 00128 00129 endfunction // new 00130 00132 // 00133 // get_next_item 00134 // Called by the driver to issue a request from 00135 // the scenario_controller and return the next scenario item 00137 00138 virtual task get_next_item(output REQ req_item, input bit non_blocking = 0); 00139 00140 if (m_scenario_controller_ptr == null) begin 00141 req_item = null; 00142 return; 00143 end 00144 m_scenario_controller_ptr.driver_request(this, scenario_base_ptr, non_blocking); 00145 if (scenario_base_ptr == null) begin 00146 req_item = null; 00147 return; 00148 end 00149 get_req.get(req_item); 00150 return; 00151 endtask 00152 00153 virtual task run(); 00154 endtask // run 00155 00156 endclass 00157 00159 // 00160 // Use the ovm_scenario_driver_noparam class for drivers 00161 // that need arbitrary ports and communication with 00162 // the sequenc 00164 00165 virtual class ovm_scenario_driver_noparam extends ovm_scenario_driver_base; 00166 00167 typedef ovm_scenario_driver_noparam p_drv; 00168 00169 function new (string name, ovm_component parent); 00170 super.new(name, parent); 00171 endfunction // new 00172 00173 virtual task run(); 00174 endtask // run 00175 00176 endclass 00177 00178 class request_driver #(type REQ = ovm_transaction, 00179 type RSP = ovm_transaction) extends ovm_scenario_driver #(REQ, RSP); 00180 00181 REQ req; 00182 RSP rsp; 00183 00184 //tlm_blocking_peek_if #(REQ), get_peek; 00185 00186 function new (string name, ovm_component parent); 00187 super.new(name, parent); 00188 // get_peek.new("nb_get_peek", this); 00189 endfunction // new 00190 00191 task run(); 00192 // Somehow, wait for driver to have done a try_get() 00193 // wait (can_put() == 1); 00194 forever begin 00195 // Wait for driver to issue get() 00196 req_rsp.wait_for_pending_get(); 00197 if (m_scenario_controller_ptr == null) begin 00198 ovm_report_fatal(get_full_name(), "request_driver has Null scenario_controller"); 00199 end 00200 00201 m_scenario_controller_ptr.driver_request(this, scenario_base_ptr); 00202 end // forever begin 00203 endtask // run 00204 00205 endclass 00206
![]() 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 |