sc_wait.cpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_wait.cpp -- Wait() and related functions.
00021 
00022   Original Author: Stan Y. Liao, Synopsys, Inc.
00023                    Martin Janssen, Synopsys, Inc.
00024 
00025  *****************************************************************************/
00026 
00027 /*****************************************************************************
00028 
00029   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00030   changes you are making here.
00031 
00032       Name, Affiliation, Date:
00033   Description of Modification:
00034 
00035  *****************************************************************************/
00036 
00037 /* 
00038 $Log: sc_wait.cpp,v $
00039 Revision 1.1.1.1  2006/12/15 20:31:37  acg
00040 SystemC 2.2
00041 
00042 Revision 1.7  2006/02/02 20:20:39  acg
00043  Andy Goodrich: warnings for SC_THREAD waits.
00044 
00045 Revision 1.6  2006/02/01 01:36:54  acg
00046  Andy Goodrich: addition of deprecation comments for SC_CTHREAD waits other
00047  than wait() and wait(N).
00048 
00049 Revision 1.5  2006/01/31 22:17:40  acg
00050  Andy Goodrich: added deprecation warnings for SC_CTHREAD waits other than
00051  wait() and wait(N).
00052 
00053 Revision 1.4  2006/01/25 00:31:20  acg
00054  Andy Goodrich: Changed over to use a standard message id of
00055  SC_ID_IEEE_1666_DEPRECATION for all deprecation messages.
00056 
00057 Revision 1.3  2006/01/24 20:49:05  acg
00058 Andy Goodrich: changes to remove the use of deprecated features within the
00059 simulator, and to issue warning messages when deprecated features are used.
00060 
00061 Revision 1.2  2006/01/03 23:18:45  acg
00062 Changed copyright to include 2006.
00063 
00064 Revision 1.1.1.1  2005/12/19 23:16:44  acg
00065 First check in of SystemC 2.1 into its own archive.
00066 
00067 Revision 1.10  2005/09/02 19:03:30  acg
00068 Changes for dynamic processes. Removal of lambda support.
00069 
00070 Revision 1.9  2005/07/30 03:45:05  acg
00071 Changes from 2.1, including changes for sc_process_handle.
00072 
00073 Revision 1.8  2005/04/04 00:16:07  acg
00074 Changes for directory name change to sys from systemc.
00075 Changes for sc_string going to std::string.
00076 Changes for sc_pvector going to std::vector.
00077 Changes for reference pools for bit and part selections.
00078 Changes for const sc_concatref support.
00079 
00080 Revision 1.5  2004/09/27 20:49:10  acg
00081 Andy Goodrich, Forte Design Systems, Inc.
00082    - Added a $Log comment so that CVS checkin comments appear in the
00083      checkout source.
00084 
00085 */
00086 
00087 #include "sysc/kernel/sc_except.h"
00088 #include "sysc/kernel/sc_kernel_ids.h"
00089 #include "sysc/kernel/sc_cthread_process.h"
00090 #include "sysc/kernel/sc_thread_process.h"
00091 #include "sysc/kernel/sc_simcontext_int.h"
00092 #include "sysc/kernel/sc_wait.h"
00093 #include "sysc/utils/sc_utils_ids.h"
00094 
00095 namespace sc_core {
00096 
00097 // static sensitivity for SC_THREADs and SC_CTHREADs
00098 
00099 void warn_cthread_wait()
00100 {
00101     static bool warn_wait = true;
00102     if ( warn_wait )
00103     {
00104         warn_wait = false;
00105         SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,
00106         "all waits except wait() and wait(N)\n" \
00107         "             are deprecated for SC_CTHREAD, " \
00108         "use an SC_THREAD instead");
00109     }
00110 }
00111 
00112 void
00113 wait( sc_simcontext* simc )
00114 {
00115     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00116     switch( cpi->kind ) {
00117     case SC_THREAD_PROC_: 
00118     case SC_CTHREAD_PROC_: {
00119     RCAST<sc_cthread_handle>( cpi->process_handle )->wait_cycles();
00120         break;
00121     }
00122     default:
00123     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00124              "in SC_METHODs use next_trigger() instead" );
00125         break;
00126     }
00127 }
00128 
00129 // dynamic sensitivity for SC_THREADs and SC_CTHREADs
00130 
00131 void
00132 wait( const sc_event& e, sc_simcontext* simc )
00133 {
00134     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00135     switch( cpi->kind ) {
00136     case SC_THREAD_PROC_: {
00137     RCAST<sc_thread_handle>( cpi->process_handle )->wait( e );
00138     break;
00139     }
00140     case SC_CTHREAD_PROC_: {
00141         warn_cthread_wait();
00142     sc_cthread_handle cthread_h =
00143             RCAST<sc_cthread_handle>( cpi->process_handle );
00144     cthread_h->wait( e );
00145     cthread_h->wait_cycles();
00146     break;
00147     }
00148     default:
00149     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00150              "in SC_METHODs use next_trigger() instead" );
00151         break;
00152     }
00153 }
00154 
00155 void
00156 wait( sc_event_or_list& el, sc_simcontext* simc )
00157 {
00158     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00159     switch( cpi->kind ) {
00160     case SC_THREAD_PROC_: {
00161     RCAST<sc_thread_handle>( cpi->process_handle )->wait( el );
00162     break;
00163     }
00164     case SC_CTHREAD_PROC_: {
00165         warn_cthread_wait();
00166         SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,
00167         "wait(event_list) is deprecated for SC_CTHREAD, use SC_THREAD");
00168     sc_cthread_handle cthread_h =
00169             RCAST<sc_cthread_handle>( cpi->process_handle );
00170     cthread_h->wait( el );
00171     cthread_h->wait_cycles();
00172     break;
00173     }
00174     default:
00175     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00176              "in SC_METHODs use next_trigger() instead" );
00177         break;
00178     }
00179 }
00180 
00181 void
00182 wait( sc_event_and_list& el, sc_simcontext* simc )
00183 {
00184     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00185     switch( cpi->kind ) {
00186     case SC_THREAD_PROC_: {
00187     RCAST<sc_thread_handle>( cpi->process_handle )->wait( el );
00188     break;
00189     }
00190     case SC_CTHREAD_PROC_: {
00191         warn_cthread_wait();
00192     sc_cthread_handle cthread_h =
00193             RCAST<sc_cthread_handle>( cpi->process_handle );
00194     cthread_h->wait( el );
00195     cthread_h->wait_cycles();
00196     break;
00197     }
00198     default:
00199     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00200              "in SC_METHODs use next_trigger() instead" );
00201         break;
00202     }
00203 }
00204 
00205 void
00206 wait( const sc_time& t, sc_simcontext* simc )
00207 {
00208     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00209     switch( cpi->kind ) {
00210     case SC_THREAD_PROC_: {
00211     RCAST<sc_thread_handle>( cpi->process_handle )->wait( t );
00212     break;
00213     }
00214     case SC_CTHREAD_PROC_: {
00215         warn_cthread_wait();
00216     sc_cthread_handle cthread_h =
00217             RCAST<sc_cthread_handle>( cpi->process_handle );
00218     cthread_h->wait( t );
00219     cthread_h->wait_cycles();
00220     break;
00221     }
00222     default:
00223     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00224              "in SC_METHODs use next_trigger() instead" );
00225         break;
00226     }
00227 }
00228 
00229 void
00230 wait( const sc_time& t, const sc_event& e, sc_simcontext* simc )
00231 {
00232     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00233     switch( cpi->kind ) {
00234     case SC_THREAD_PROC_: {
00235     RCAST<sc_thread_handle>( cpi->process_handle )->wait( t, e );
00236     break;
00237     }
00238     case SC_CTHREAD_PROC_: {
00239         warn_cthread_wait();
00240     sc_cthread_handle cthread_h =
00241             RCAST<sc_cthread_handle>( cpi->process_handle );
00242     cthread_h->wait( t, e );
00243     cthread_h->wait_cycles();
00244     break;
00245     }
00246     default:
00247     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00248              "in SC_METHODs use next_trigger() instead" );
00249         break;
00250     }
00251 }
00252 
00253 void
00254 wait( const sc_time& t, sc_event_or_list& el, sc_simcontext* simc )
00255 {
00256     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00257     switch( cpi->kind ) {
00258     case SC_THREAD_PROC_: {
00259     RCAST<sc_thread_handle>( cpi->process_handle )->wait( t, el );
00260     break;
00261     }
00262     case SC_CTHREAD_PROC_: {
00263         warn_cthread_wait();
00264     sc_cthread_handle cthread_h =
00265             RCAST<sc_cthread_handle>( cpi->process_handle );
00266     cthread_h->wait( t, el );
00267     cthread_h->wait_cycles();
00268     break;
00269     }
00270     default:
00271     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00272              "in SC_METHODs use next_trigger() instead" );
00273         break;
00274     }
00275 }
00276 
00277 void
00278 wait( const sc_time& t, sc_event_and_list& el, sc_simcontext* simc )
00279 {
00280     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00281     switch( cpi->kind ) {
00282     case SC_THREAD_PROC_: {
00283     RCAST<sc_thread_handle>( cpi->process_handle )->wait( t, el );
00284     break;
00285     }
00286     case SC_CTHREAD_PROC_: {
00287         warn_cthread_wait();
00288     sc_cthread_handle cthread_h =
00289             RCAST<sc_cthread_handle>( cpi->process_handle );
00290     cthread_h->wait( t, el );
00291     cthread_h->wait_cycles();
00292     break;
00293     }
00294     default:
00295     SC_REPORT_ERROR( SC_ID_WAIT_NOT_ALLOWED_, "\n        "
00296              "in SC_METHODs use next_trigger() instead" );
00297         break;
00298     }
00299 }
00300 
00301 
00302 // static sensitivity for SC_METHODs
00303 
00304 void
00305 next_trigger( sc_simcontext* simc )
00306 {
00307     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00308     if( cpi->kind == SC_METHOD_PROC_ ) {
00309     RCAST<sc_method_handle>( cpi->process_handle )->clear_trigger();
00310     } else {
00311     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00312              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00313     }
00314 }
00315 
00316 
00317 // dynamic sensitivity for SC_METHODs
00318 
00319 void
00320 next_trigger( const sc_event& e, sc_simcontext* simc )
00321 {
00322     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00323     if( cpi->kind == SC_METHOD_PROC_ ) {
00324     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( e );
00325     } else {
00326     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00327              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00328     }
00329 }
00330 
00331 void
00332 next_trigger( sc_event_or_list& el, sc_simcontext* simc )
00333 {
00334     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00335     if( cpi->kind == SC_METHOD_PROC_ ) {
00336     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( el );
00337     } else {
00338     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00339              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00340     }
00341 }
00342 
00343 void
00344 next_trigger( sc_event_and_list& el, sc_simcontext* simc )
00345 {
00346     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00347     if( cpi->kind == SC_METHOD_PROC_ ) {
00348     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( el );
00349     } else {
00350     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00351              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00352     }
00353 }
00354 
00355 void
00356 next_trigger( const sc_time& t, sc_simcontext* simc )
00357 {
00358     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00359     if( cpi->kind == SC_METHOD_PROC_ ) {
00360     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( t );
00361     } else {
00362     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00363              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00364     }
00365 }
00366 
00367 void
00368 next_trigger( const sc_time& t, const sc_event& e, sc_simcontext* simc )
00369 {
00370     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00371     if( cpi->kind == SC_METHOD_PROC_ ) {
00372     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( t, e );
00373     } else {
00374     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00375              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00376     }
00377 }
00378 
00379 void
00380 next_trigger( const sc_time& t, sc_event_or_list& el, sc_simcontext* simc )
00381 {
00382     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00383     if( cpi->kind == SC_METHOD_PROC_ ) {
00384     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( t, el );
00385     } else {
00386     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00387              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00388     }
00389 }
00390 
00391 void
00392 next_trigger( const sc_time& t, sc_event_and_list& el, sc_simcontext* simc )
00393 {
00394     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00395     if( cpi->kind == SC_METHOD_PROC_ ) {
00396     RCAST<sc_method_handle>( cpi->process_handle )->next_trigger( t, el );
00397     } else {
00398     SC_REPORT_ERROR( SC_ID_NEXT_TRIGGER_NOT_ALLOWED_, "\n        "
00399              "in SC_THREADs and SC_CTHREADs use wait() instead" );
00400     }
00401 }
00402 
00403 
00404 // for SC_METHODs and SC_THREADs and SC_CTHREADs
00405 
00406 bool
00407 timed_out( sc_simcontext* simc )
00408 {
00409     static bool warn_timed_out=true; 
00410     if ( warn_timed_out )
00411     {
00412         warn_timed_out = false;
00413         SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,
00414         "timed_out() function is deprecated" );
00415     }
00416 
00417     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00418     return cpi->process_handle->timed_out();
00419 }
00420 
00421 
00422 
00423 // misc.
00424 
00425 void
00426 sc_set_location( const char* file, int lineno, sc_simcontext* simc )
00427 {
00428     sc_curr_proc_handle cpi = simc->get_curr_proc_info();
00429     sc_process_b* handle = cpi->process_handle;
00430     handle->file = file;
00431     handle->lineno = lineno;
00432 }
00433 
00434 } // namespace sc_core
00435 
00436 // Taf!

Generated on Wed Jan 21 15:32:09 2009 for SystemC by  doxygen 1.5.5