ovm_threaded_component.svh

Go to the documentation of this file.
00001 // $Id: ovm__threaded__component_8svh-source.html,v 1.1 2008/10/07 21:54:41 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 // 
00024 // CLASS: ovm_threaded_component
00025 //
00026 //------------------------------------------------------------------------------
00027 
00028 virtual class ovm_threaded_component extends ovm_component;
00029     
00030   extern function new( string name , ovm_component parent );
00031 
00032   extern virtual  task                   run     ();
00033 
00034   // process control for task-based phases, e.g. 'run'
00035   extern virtual  task                   suspend ();
00036   extern virtual  task                   resume  ();
00037   extern virtual  task                   restart ();
00038   extern virtual  function void          kill    ();
00039   extern function string                 status  ();
00040 
00041   extern virtual  function void  do_kill_all ();
00042 
00043   // method called to execute a task-based phase (e.g. 'run').
00044   // Overrides can do pre- and post-phase activities;
00045   // should call super.do_task_phase.
00046   extern virtual task do_task_phase (ovm_phase phase);
00047 
00048   `ifndef INCA
00049   protected process m_phase_process;
00050   `endif
00051   protected event m_kill_request;
00052 
00053   // prevents unnecessary phase insertion
00054   local static bit m_phases_loaded=0;
00055 
00056 endclass : ovm_threaded_component 
00057 
00058 
00059 
00060 //-----------------------------------------------------------------------------
00061 //
00062 // IMPLEMENTATION
00063 //
00064 //-----------------------------------------------------------------------------
00065 
00066 `ovm_phase_task_decl(run,0)
00067 run_phase #(ovm_threaded_component) run_ph = new();
00068 
00069 
00070 // new
00071 // ---
00072 
00073 function ovm_threaded_component::new (string name, ovm_component parent);
00074   super.new(name, parent);
00075   if (!(parent==null && name == "__top__")) begin
00076     if (!ovm_threaded_component::m_phases_loaded) begin
00077       ovm_threaded_component::m_phases_loaded=1;
00078       ovm_top.insert_phase(run_ph, pre_run_ph);
00079     end
00080   end
00081 endfunction
00082 
00083 
00084 // do_task_phase
00085 // -------------
00086 
00087 task ovm_threaded_component::do_task_phase (ovm_phase phase);
00088 
00089   m_curr_phase = phase;
00090   // QUESTA
00091   `ifndef INCA  
00092 
00093     fork
00094       begin
00095         m_phase_process = process::self();
00096         phase.call_task(this);
00097         @m_kill_request;
00098       end
00099     join
00100 
00101   `else
00102   // INCISIVE
00103    fork begin // isolate inner fork so can safely kill via disable fork
00104      fork : task_phase
00105        // process 1 - call task; if returns, keep alive until kill request
00106        begin
00107          phase.call_task(this);
00108          @m_kill_request;
00109        end
00110        // process 2 - any kill request will preempt process 1
00111        @m_kill_request;
00112      join_any
00113      disable fork;
00114    end
00115    join
00116   `endif
00117 
00118 endtask
00119 
00120 
00121 // do_kill_all
00122 // -----------
00123 
00124 function void ovm_threaded_component::do_kill_all();
00125   super.do_kill_all();
00126   kill();
00127 endfunction
00128 
00129 
00130 // kill
00131 // ----
00132 
00133 function void ovm_threaded_component::kill();
00134   `ifndef INCA
00135     if (m_phase_process != null) begin
00136       m_phase_process.kill;
00137       m_phase_process = null;
00138     end
00139   `else
00140      ->m_kill_request;
00141   `endif
00142 endfunction
00143 
00144 
00145 // suspend
00146 // -------
00147 
00148 task ovm_threaded_component::suspend();
00149   `ifndef INCA
00150   if(m_phase_process != null)
00151     m_phase_process.suspend;
00152   `else
00153   ovm_report_error("UNIMP", "suspend not implemented in IUS");
00154   `endif
00155 endtask
00156 
00157 
00158 // resume
00159 // ------
00160 
00161 task ovm_threaded_component::resume();
00162   `ifndef INCA
00163   if(m_phase_process!=null) 
00164     m_phase_process.resume;
00165   `else
00166    ovm_report_error("UNIMP", "resume not implemented in IUS");
00167   `endif
00168 endtask
00169 
00170 
00171 // restart
00172 // -------
00173 
00174 task ovm_threaded_component::restart();
00175   ovm_report_warning("UNIMP",
00176       $psprintf("%0s: restart not implemented",this.get_name()));
00177 endtask
00178 
00179 
00180 // status
00181 //-------
00182 
00183 function string ovm_threaded_component::status();
00184 
00185   `ifndef INCA
00186   process::state ps;
00187 
00188   if(m_phase_process == null)
00189     return "<unknown>";
00190 
00191   ps = m_phase_process.status();
00192 
00193   return ps.name();
00194   `else
00195    ovm_report_error("UNIMP", "status not implemented in IUS");
00196   `endif
00197 
00198 endfunction
00199 
00200 
00201 // run
00202 // ---
00203 
00204 task ovm_threaded_component::run();
00205   return;
00206 endtask
00207 

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