00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
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
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
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
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
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
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
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 }
00435
00436