1 /*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20 /*****************************************************************************
21
22 sc_simcontext.h -- Definition of the simulation context class.
23
24 Original Author: Stan Y. Liao, Synopsys, Inc.
25 Martin Janssen, Synopsys, Inc.
26
27 CHANGE LOG AT THE END OF THE FILE
28 *****************************************************************************/
29
30 #ifndef SC_SIMCONTEXT_H
31 #define SC_SIMCONTEXT_H
32
33 #include "sysc/kernel/sc_cmnhdr.h"
34 #include "sysc/kernel/sc_process.h"
35 #include "sysc/kernel/sc_status.h"
36 #include "sysc/kernel/sc_time.h"
37 #include "sysc/utils/sc_hash.h"
38 #include "sysc/utils/sc_pq.h"
39
40 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
41 #pragma warning(push)
42 #pragma warning(disable: 4251) // DLL import for std::vector
43 #endif
44
45 namespace sc_core {
46
47 // forward declarations
48
49 class sc_cor;
50 class sc_cor_pkg;
51 class sc_event;
52 class sc_event_timed;
53 class sc_export_registry;
54 class sc_module;
55 class sc_module_name;
56 class sc_module_registry;
57 class sc_name_gen;
58 class sc_object;
59 class sc_object_manager;
60 class sc_phase_callback_registry;
61 class sc_process_handle;
62 class sc_port_registry;
63 class sc_prim_channel_registry;
64 class sc_process_table;
65 class sc_signal_bool_deval;
66 class sc_trace_file;
67 class sc_runnable;
68 class sc_process_host;
69 class sc_method_process;
70 class sc_cthread_process;
71 class sc_thread_process;
72 class sc_reset_finder;
73
74
75 template< typename > class sc_plist;
76 typedef sc_plist< sc_process_b* > sc_process_list;
77
78 struct SC_API sc_curr_proc_info
79 {
80 sc_process_b* process_handle;
81 sc_curr_proc_kind kind;
sc_curr_proc_infosc_curr_proc_info82 sc_curr_proc_info() : process_handle( 0 ), kind( SC_NO_PROC_ ) {}
83 };
84
85 typedef const sc_curr_proc_info* sc_curr_proc_handle;
86
87 enum sc_stop_mode { // sc_stop modes:
88 SC_STOP_FINISH_DELTA,
89 SC_STOP_IMMEDIATE
90 };
91 extern SC_API void sc_set_stop_mode( sc_stop_mode mode );
92 extern SC_API sc_stop_mode sc_get_stop_mode();
93
94 enum sc_starvation_policy
95 {
96 SC_EXIT_ON_STARVATION,
97 SC_RUN_TO_TIME
98 };
99 extern SC_API void sc_start();
100 extern SC_API void sc_start( const sc_time& duration,
101 sc_starvation_policy p=SC_RUN_TO_TIME );
102 inline void sc_start( int duration, sc_time_unit unit,
103 sc_starvation_policy p=SC_RUN_TO_TIME )
104 {
105 sc_start( sc_time((double)duration,unit), p );
106 }
107
108 inline void sc_start( double duration, sc_time_unit unit,
109 sc_starvation_policy p=SC_RUN_TO_TIME )
110 {
111 sc_start( sc_time(duration,unit), p );
112 }
113
114 extern SC_API void sc_stop();
115
116 // friend function declarations
117
118 SC_API sc_dt::uint64 sc_delta_count();
119 SC_API sc_dt::uint64 sc_delta_count_at_current_time();
120 SC_API const std::vector<sc_event*>& sc_get_top_level_events(
121 const sc_simcontext* simc_p);
122 SC_API const std::vector<sc_object*>& sc_get_top_level_objects(
123 const sc_simcontext* simc_p);
124 SC_API bool sc_is_running( const sc_simcontext* simc_p );
125 SC_API void sc_pause();
126 SC_API bool sc_end_of_simulation_invoked();
127 SC_API void sc_start( const sc_time&, sc_starvation_policy );
128 SC_API bool sc_start_of_simulation_invoked();
129 SC_API void sc_set_time_resolution( double, sc_time_unit );
130 SC_API sc_time sc_get_time_resolution();
131 SC_API void sc_set_default_time_unit( double, sc_time_unit );
132 SC_API sc_time sc_get_default_time_unit();
133 SC_API bool sc_pending_activity_at_current_time( const sc_simcontext* );
134 SC_API bool sc_pending_activity_at_future_time( const sc_simcontext* );
135 SC_API sc_time sc_time_to_pending_activity( const sc_simcontext* );
136
137 struct sc_invoke_method;
138
139 // ----------------------------------------------------------------------------
140 // CLASS : sc_simcontext
141 //
142 // The simulation context.
143 // ----------------------------------------------------------------------------
144
145 class SC_API sc_simcontext
146 {
147 friend struct sc_invoke_method;
148 friend class sc_event;
149 friend class sc_module;
150 friend class sc_object;
151 friend class sc_time;
152 friend class sc_time_tuple;
153 friend class sc_clock;
154 friend class sc_method_process;
155 friend class sc_phase_callback_registry;
156 friend class sc_process_b;
157 friend class sc_process_handle;
158 friend class sc_prim_channel;
159 friend class sc_cthread_process;
160 friend class sc_thread_process;
161 friend SC_API sc_dt::uint64 sc_delta_count();
162 friend SC_API const std::vector<sc_event*>& sc_get_top_level_events(
163 const sc_simcontext* simc_p);
164 friend SC_API const std::vector<sc_object*>& sc_get_top_level_objects(
165 const sc_simcontext* simc_p);
166 friend SC_API bool sc_is_running( const sc_simcontext* simc_p );
167 friend SC_API void sc_pause();
168 friend SC_API bool sc_end_of_simulation_invoked();
169 friend SC_API void sc_start( const sc_time&, sc_starvation_policy );
170 friend SC_API bool sc_start_of_simulation_invoked();
171 friend void sc_thread_cor_fn(void*);
172 friend SC_API sc_time sc_time_to_pending_activity( const sc_simcontext* );
173 friend SC_API bool sc_pending_activity_at_current_time( const sc_simcontext* );
174 friend SC_API bool sc_pending_activity_at_future_time( const sc_simcontext* );
175
176 enum sc_signal_write_check
177 {
178 SC_SIGNAL_WRITE_CHECK_DISABLE_ = 0x0, // no multiple writer checks
179 SC_SIGNAL_WRITE_CHECK_DEFAULT_ = 0x1, // default IEEE-1666 writer checks
180 SC_SIGNAL_WRITE_CHECK_CONFLICT_ = 0x2 // only check for conflicting writes
181 };
182
183
184 void init();
185 void clean();
186
187 public:
188
189 sc_simcontext();
190 ~sc_simcontext();
191
192 void initialize( bool = false );
193 void cycle( const sc_time& );
194 void simulate( const sc_time& duration );
195 void stop();
196 void end();
197 void reset();
198
199 int sim_status() const;
200 bool elaboration_done() const;
201
202 std::vector<sc_thread_handle>& get_active_invokers();
203
204 sc_object_manager* get_object_manager();
205
206 inline sc_status get_status() const;
207
208 sc_object* active_object();
209
210 void hierarchy_push( sc_module* );
211 sc_module* hierarchy_pop();
212 sc_module* hierarchy_curr() const;
213 sc_object* first_object();
214 sc_object* next_object();
215 sc_object* find_object( const char* name );
216
217 sc_module_registry* get_module_registry();
218 sc_port_registry* get_port_registry();
219 sc_export_registry* get_export_registry();
220 sc_prim_channel_registry* get_prim_channel_registry();
221
222 std::string construct_hierarchical_name(const sc_object* parent,
223 const std::string& name);
224 bool register_hierarchical_name(const sc_object* parent,
225 const std::string& name);
226 bool unregister_hierarchical_name(const sc_object* parent,
227 const std::string& name);
228 bool hierarchical_name_exists(const sc_object* parent,
229 const std::string& name);
230 const char* get_hierarchical_name(const sc_object* parent,
231 const std::string& name);
232
233 // to generate unique names for objects in an MT-Safe way
234 const char* gen_unique_name( const char* basename_,
235 bool preserve_first = false
236 );
237
238 // process creation
239 sc_process_handle create_cthread_process(
240 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
241 sc_process_host* host_p, const sc_spawn_options* opt_p );
242
243 sc_process_handle create_method_process(
244 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
245 sc_process_host* host_p, const sc_spawn_options* opt_p );
246
247 sc_process_handle create_thread_process(
248 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
249 sc_process_host* host_p, const sc_spawn_options* opt_p );
250
251 sc_curr_proc_handle get_curr_proc_info();
252 sc_process_b* get_current_writer() const;
253 bool write_check() const;
254 bool write_check_conflicts_only() const;
255 void set_curr_proc( sc_process_b* );
256 void reset_curr_proc();
257
258 int next_proc_id();
259
260 void add_trace_file( sc_trace_file* );
261 void remove_trace_file( sc_trace_file* );
262
263 friend SC_API void sc_set_time_resolution( double, sc_time_unit );
264 friend SC_API sc_time sc_get_time_resolution();
265 friend SC_API void sc_set_default_time_unit( double, sc_time_unit );
266 friend SC_API sc_time sc_get_default_time_unit();
267
268 const sc_time& max_time() const;
269 const sc_time& time_stamp() const;
270
271 sc_dt::uint64 change_stamp() const;
272 sc_dt::uint64 delta_count() const;
273 sc_dt::uint64 delta_count_at_current_time() const;
274 bool event_occurred( sc_dt::uint64 last_change_count ) const;
275 bool evaluation_phase() const;
276 bool is_running() const;
277 bool update_phase() const;
278 bool notify_phase() const;
279 bool get_error();
280 void set_error( sc_report* );
281
cor_pkg()282 sc_cor_pkg* cor_pkg()
283 { return m_cor_pkg; }
284 sc_cor* next_cor();
285
286 void add_reset_finder( sc_reset_finder* );
287
288 const ::std::vector<sc_object*>& get_child_objects() const;
289
290 void elaborate();
291 void prepare_to_simulate();
292 inline void initial_crunch( bool no_crunch );
293 bool next_time( sc_time& t ) const;
294 bool pending_activity_at_current_time() const;
295
296 private:
297
298 void add_child_event( sc_event* );
299 void add_child_object( sc_object* );
300 void remove_child_event( sc_event* );
301 void remove_child_object( sc_object* );
302
303 void crunch( bool once=false );
304
305 int add_delta_event( sc_event* );
306 void remove_delta_event( sc_event* );
307 void add_timed_event( sc_event_timed* );
308
309 void trace_cycle( bool delta_cycle );
310
311 void execute_method_next( sc_method_handle );
312 void execute_thread_next( sc_thread_handle );
313
314 sc_method_handle pop_runnable_method();
315 sc_thread_handle pop_runnable_thread();
316
317 void preempt_with( sc_method_handle );
318 inline void preempt_with( sc_thread_handle );
319
320 void push_runnable_method( sc_method_handle );
321 void push_runnable_thread( sc_thread_handle );
322
323 void push_runnable_method_front( sc_method_handle );
324 void push_runnable_thread_front( sc_thread_handle );
325
326 void remove_runnable_method( sc_method_handle );
327 void remove_runnable_thread( sc_thread_handle );
328
329 void requeue_current_process();
330 void suspend_current_process();
331
332 void do_sc_stop_action();
333 void do_timestep( const sc_time& );
334 void mark_to_collect_process( sc_process_b* zombie_p );
335 void do_collect_processes();
336
337 sc_method_handle remove_process( sc_method_handle );
338 sc_thread_handle remove_process( sc_thread_handle );
339
340 private:
341
342 enum execution_phases {
343 phase_initialize = 0,
344 phase_evaluate,
345 phase_update,
346 phase_notify
347 };
348 sc_object_manager* m_object_manager;
349
350 sc_module_registry* m_module_registry;
351 sc_port_registry* m_port_registry;
352 sc_export_registry* m_export_registry;
353 sc_prim_channel_registry* m_prim_channel_registry;
354 sc_phase_callback_registry* m_phase_cb_registry;
355
356 sc_name_gen* m_name_gen;
357
358 sc_process_table* m_process_table;
359 sc_curr_proc_info m_curr_proc_info;
360 sc_process_b* m_current_writer;
361 sc_signal_write_check m_write_check;
362 int m_next_proc_id;
363
364 std::vector<sc_thread_handle> m_active_invokers;
365
366 std::vector<sc_event*> m_child_events;
367 std::vector<sc_object*> m_child_objects;
368
369 std::vector<sc_event*> m_delta_events;
370 sc_ppq<sc_event_timed*>* m_timed_events;
371
372 std::vector<sc_trace_file*> m_trace_files;
373 bool m_something_to_trace;
374
375 sc_runnable* m_runnable;
376 sc_process_list* m_collectable;
377
378 sc_time_params* m_time_params;
379 sc_time m_curr_time;
380 mutable sc_time m_max_time;
381
382 sc_invoke_method* m_method_invoker_p;
383 sc_dt::uint64 m_change_stamp; // "time" change occurred.
384 sc_dt::uint64 m_delta_count;
385 sc_dt::uint64 m_initial_delta_count_at_current_time;
386 bool m_forced_stop;
387 bool m_paused;
388 bool m_ready_to_simulate;
389 bool m_elaboration_done;
390 execution_phases m_execution_phase;
391 sc_report* m_error;
392 bool m_in_simulator_control;
393 bool m_end_of_simulation_called;
394 sc_status m_simulation_status;
395 bool m_start_of_simulation_called;
396
397 sc_cor_pkg* m_cor_pkg; // the simcontext's coroutine package
398 sc_cor* m_cor; // the simcontext's coroutine
399
400 sc_reset_finder* m_reset_finder_q; // Q of reset finders to reconcile.
401
402 private:
403
404 // disabled
405 sc_simcontext( const sc_simcontext& );
406 sc_simcontext& operator = ( const sc_simcontext& );
407 };
408
409 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
410
411 // Not MT safe.
412
413 #if 1
414 extern SC_API sc_simcontext* sc_curr_simcontext;
415 extern SC_API sc_simcontext* sc_default_global_context;
416
417 inline sc_simcontext*
sc_get_curr_simcontext()418 sc_get_curr_simcontext()
419 {
420 if( sc_curr_simcontext == 0 ) {
421 sc_default_global_context = new sc_simcontext;
422 sc_curr_simcontext = sc_default_global_context;
423 }
424 return sc_curr_simcontext;
425 }
426 #else
427 extern SC_API sc_simcontext* sc_get_curr_simcontext();
428 #endif // 0
sc_get_status()429 inline sc_status sc_get_status()
430 {
431 return sc_get_curr_simcontext()->get_status();
432 }
433
434
435 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
436
437 inline
438 bool
elaboration_done()439 sc_simcontext::elaboration_done() const
440 {
441 return m_elaboration_done;
442 }
443
444
get_status()445 inline sc_status sc_simcontext::get_status() const
446 {
447 return m_simulation_status != SC_RUNNING ?
448 m_simulation_status :
449 (m_in_simulator_control ? SC_RUNNING : SC_PAUSED);
450 }
451
452 inline
453 int
sim_status()454 sc_simcontext::sim_status() const
455 {
456 if( m_error ) {
457 return SC_SIM_ERROR;
458 }
459 if( m_forced_stop ) {
460 return SC_SIM_USER_STOP;
461 }
462 return SC_SIM_OK;
463 }
464
465
466 inline
467 sc_object_manager*
get_object_manager()468 sc_simcontext::get_object_manager()
469 {
470 return m_object_manager;
471 }
472
473 inline
474 sc_module_registry*
get_module_registry()475 sc_simcontext::get_module_registry()
476 {
477 return m_module_registry;
478 }
479
480 inline
481 sc_port_registry*
get_port_registry()482 sc_simcontext::get_port_registry()
483 {
484 return m_port_registry;
485 }
486
487 inline
488 sc_export_registry*
get_export_registry()489 sc_simcontext::get_export_registry()
490 {
491 return m_export_registry;
492 }
493
494 inline
495 sc_prim_channel_registry*
get_prim_channel_registry()496 sc_simcontext::get_prim_channel_registry()
497 {
498 return m_prim_channel_registry;
499 }
500
501
502 inline
503 sc_curr_proc_handle
get_curr_proc_info()504 sc_simcontext::get_curr_proc_info()
505 {
506 return &m_curr_proc_info;
507 }
508
509
510 inline
511 int
next_proc_id()512 sc_simcontext::next_proc_id()
513 {
514 return ( ++ m_next_proc_id );
515 }
516
517
518 inline
519 const sc_time&
max_time()520 sc_simcontext::max_time() const
521 {
522 if ( m_max_time == SC_ZERO_TIME )
523 {
524 m_max_time = sc_time::from_value( ~sc_dt::UINT64_ZERO );
525 }
526 return m_max_time;
527 }
528
529 inline
530 sc_dt::uint64
change_stamp()531 sc_simcontext::change_stamp() const
532 {
533 return m_change_stamp;
534 }
535
536 inline sc_dt::uint64
delta_count_at_current_time()537 sc_simcontext::delta_count_at_current_time() const
538 {
539 return m_delta_count - m_initial_delta_count_at_current_time;
540 }
541
542 inline
543 const sc_time&
time_stamp()544 sc_simcontext::time_stamp() const
545 {
546 return m_curr_time;
547 }
548
549
550 inline
551 bool
event_occurred(sc_dt::uint64 last_change_stamp)552 sc_simcontext::event_occurred(sc_dt::uint64 last_change_stamp) const
553 {
554 return m_change_stamp == last_change_stamp;
555 }
556
557 inline
558 bool
evaluation_phase()559 sc_simcontext::evaluation_phase() const
560 {
561 return (m_execution_phase == phase_evaluate) &&
562 m_ready_to_simulate;
563 }
564
565 inline
566 bool
update_phase()567 sc_simcontext::update_phase() const
568 {
569 return m_execution_phase == phase_update;
570 }
571
572 inline
573 bool
notify_phase()574 sc_simcontext::notify_phase() const
575 {
576 return m_execution_phase == phase_notify;
577 }
578
579 inline
580 void
set_error(sc_report * err)581 sc_simcontext::set_error( sc_report* err )
582 {
583 delete m_error;
584 m_error = err;
585 }
586
587
588 inline
589 bool
get_error()590 sc_simcontext::get_error()
591 {
592 return m_error != NULL;
593 }
594
595 inline
596 int
add_delta_event(sc_event * e)597 sc_simcontext::add_delta_event( sc_event* e )
598 {
599 m_delta_events.push_back( e );
600 return static_cast<int>( m_delta_events.size() - 1 );
601 }
602
603 inline
604 void
add_timed_event(sc_event_timed * et)605 sc_simcontext::add_timed_event( sc_event_timed* et )
606 {
607 m_timed_events->insert( et );
608 }
609
610 // ----------------------------------------------------------------------------
611
612 inline sc_process_b*
get_current_writer()613 sc_simcontext::get_current_writer() const
614 {
615 return m_current_writer;
616 }
617
618 inline bool
write_check()619 sc_simcontext::write_check() const
620 {
621 return m_write_check != SC_SIGNAL_WRITE_CHECK_DISABLE_;
622 }
623
624 // ----------------------------------------------------------------------------
625
626 class sc_process_handle;
627 SC_API sc_process_handle sc_get_current_process_handle();
628
629 // Get the current object hierarchy context
630 //
631 // Returns a pointer the the sc_object (module or process) that
632 // would become the parent object of a newly created element
633 // of the SystemC object hierarchy, or NULL.
634 //
635 inline sc_object*
sc_get_current_object()636 sc_get_current_object()
637 {
638 return sc_get_curr_simcontext()->active_object();
639 }
640
641 inline
642 sc_process_b*
sc_get_current_process_b()643 sc_get_current_process_b()
644 {
645 return sc_get_curr_simcontext()->get_curr_proc_info()->process_handle;
646 }
647
648 // THE FOLLOWING FUNCTION IS DEPRECATED IN 2.1
649 extern SC_API sc_process_b* sc_get_curr_process_handle();
650
651 inline
652 sc_curr_proc_kind
sc_get_curr_process_kind()653 sc_get_curr_process_kind()
654 {
655 return sc_get_curr_simcontext()->get_curr_proc_info()->kind;
656 }
657
658
sc_get_simulator_status()659 inline int sc_get_simulator_status()
660 {
661 return sc_get_curr_simcontext()->sim_status();
662 }
663
664
665 // Generates unique names within each module.
666 extern SC_API
667 const char*
668 sc_gen_unique_name( const char* basename_, bool preserve_first = false );
669
670
671 // Set the random seed for controlled randomization -- not yet implemented
672 extern SC_API
673 void
674 sc_set_random_seed( unsigned int seed_ );
675
676
677 extern SC_API void sc_initialize();
678
679 extern SC_API const sc_time& sc_max_time(); // Get maximum time value.
680 extern SC_API const sc_time& sc_time_stamp(); // Current simulation time.
681 extern SC_API double sc_simulation_time(); // Current time in default time units.
682
683 inline
684 const std::vector<sc_event*>& sc_get_top_level_events(
685 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
686 {
687 return simc_p->m_child_events;
688 }
689
690 inline
691 const std::vector<sc_object*>& sc_get_top_level_objects(
692 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
693 {
694 return simc_p->m_child_objects;
695 }
696
697 extern SC_API sc_event* sc_find_event( const char* name );
698
699 extern SC_API sc_object* sc_find_object( const char* name );
700
701 inline
sc_delta_count()702 sc_dt::uint64 sc_delta_count()
703 {
704 return sc_get_curr_simcontext()->m_delta_count;
705 }
706
707 inline
sc_delta_count_at_current_time()708 sc_dt::uint64 sc_delta_count_at_current_time()
709 {
710 return sc_get_curr_simcontext()->delta_count_at_current_time();
711 }
712
713 inline
714 bool sc_is_running( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
715 {
716 return simc_p->m_ready_to_simulate;
717 }
718
719 SC_API bool sc_is_unwinding();
720
sc_pause()721 inline void sc_pause()
722 {
723 sc_get_curr_simcontext()->m_paused = true;
724 }
725
726 // Return indication if there are more processes to execute in this delta phase
727
728 inline bool sc_pending_activity_at_current_time
729 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
730 {
731 return simc_p->pending_activity_at_current_time();
732 }
733
734 // Return indication if there are timed notifications in the future
735
736 inline bool sc_pending_activity_at_future_time
737 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
738 {
739 sc_time ignored;
740 return simc_p->next_time( ignored );
741 }
742
743 // Return indication if there are processes to run,
744 // or notifications in the future
745
746 inline bool sc_pending_activity
747 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
748 {
749 return sc_pending_activity_at_current_time( simc_p )
750 || sc_pending_activity_at_future_time( simc_p );
751 }
752
753 SC_API sc_time
754 sc_time_to_pending_activity
755 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() );
756
757
758 inline
759 bool
sc_end_of_simulation_invoked()760 sc_end_of_simulation_invoked()
761 {
762 return sc_get_curr_simcontext()->m_end_of_simulation_called;
763 }
764
765 inline
766 bool
sc_hierarchical_name_exists(const char * name)767 sc_hierarchical_name_exists( const char* name )
768 {
769 return sc_get_curr_simcontext()->hierarchical_name_exists(NULL, name);
770 }
771
772 inline
773 bool
sc_hierarchical_name_exists(const sc_object * parent,const char * name)774 sc_hierarchical_name_exists( const sc_object* parent,
775 const char* name )
776 {
777 return sc_get_curr_simcontext()->hierarchical_name_exists(parent, name);
778 }
779
780 inline
781 const char*
sc_get_hierarchical_name(const char * name)782 sc_get_hierarchical_name(const char* name)
783 {
784 return sc_get_curr_simcontext()->get_hierarchical_name(NULL, name);
785 }
786
787 inline
788 const char*
sc_get_hierarchical_name(const sc_object * parent,const char * name)789 sc_get_hierarchical_name(const sc_object* parent, const char* name)
790 {
791 return sc_get_curr_simcontext()->get_hierarchical_name(parent, name);
792 }
793
794 inline
795 bool
sc_register_hierarchical_name(const char * name)796 sc_register_hierarchical_name(const char* name)
797 {
798 return sc_get_curr_simcontext()->register_hierarchical_name(NULL, name);
799 }
800
801 inline
802 bool
sc_register_hierarchical_name(const sc_object * parent,const char * name)803 sc_register_hierarchical_name(const sc_object* parent, const char* name)
804 {
805 return sc_get_curr_simcontext()->register_hierarchical_name(parent, name);
806 }
807
808 inline
809 bool
sc_unregister_hierarchical_name(const char * name)810 sc_unregister_hierarchical_name(const char* name)
811 {
812 return sc_get_curr_simcontext()->unregister_hierarchical_name(NULL, name);
813 }
814
815 inline
816 bool
sc_unregister_hierarchical_name(const sc_object * parent,const char * name)817 sc_unregister_hierarchical_name(const sc_object* parent, const char* name)
818 {
819 return sc_get_curr_simcontext()->unregister_hierarchical_name(parent, name);
820 }
821
822 inline
823 bool
sc_start_of_simulation_invoked()824 sc_start_of_simulation_invoked()
825 {
826 return sc_get_curr_simcontext()->m_start_of_simulation_called;
827 }
828
829 // The following variable controls whether process control corners should
830 // be considered errors or not. See sc_simcontext.cpp for details on what
831 // happens if this value is set to true.
832
833 extern SC_API bool sc_allow_process_control_corners;
834
835 } // namespace sc_core
836
837 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
838 #pragma warning(pop)
839 #endif
840
841 /*****************************************************************************
842
843 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
844 changes you are making here.
845
846 Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 20 May 2003
847 Description of Modification: - phase callbacks
848 - sc_stop mode
849
850 Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
851 25 August, 2003
852 Description of Modification: - support for dynamic process
853 - support for sc export registry
854 - new member methods elaborate(),
855 prepare_to_simulate(), and initial_crunch()
856 that are invoked by initialize() in that order
857 - add sc_get_last_created_process_handle() for
858 use before simulation starts
859
860 Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
861 3 March, 2004
862 Description of Modification: add sc_get_curr_process_kind()
863
864 Name, Affiliation, Date:
865 Description of Modification:
866
867 *****************************************************************************/
868 // $Log: sc_simcontext.h,v $
869 // Revision 1.26 2011/09/05 21:20:22 acg
870 // Andy Goodrich: result of automake invocation.
871 //
872 // Revision 1.25 2011/09/01 15:28:10 acg
873 // Andy Goodrich: the aftermath of automake.
874 //
875 // Revision 1.24 2011/08/29 18:04:32 acg
876 // Philipp A. Hartmann: miscellaneous clean ups.
877 //
878 // Revision 1.23 2011/08/26 20:46:10 acg
879 // Andy Goodrich: moved the modification log to the end of the file to
880 // eliminate source line number skew when check-ins are done.
881 //
882 // Revision 1.22 2011/08/24 22:05:51 acg
883 // Torsten Maehne: initialization changes to remove warnings.
884 //
885 // Revision 1.21 2011/05/09 04:07:49 acg
886 // Philipp A. Hartmann:
887 // (1) Restore hierarchy in all phase callbacks.
888 // (2) Ensure calls to before_end_of_elaboration.
889 //
890 // Revision 1.20 2011/04/08 18:26:07 acg
891 // Andy Goodrich: added execute_method_next() to handle method dispatch
892 // for asynchronous notifications that occur outside the evaluation phase.
893 //
894 // Revision 1.19 2011/04/05 20:50:57 acg
895 // Andy Goodrich:
896 // (1) changes to make sure that event(), posedge() and negedge() only
897 // return true if the clock has not moved.
898 // (2) fixes for method self-resumes.
899 // (3) added SC_PRERELEASE_VERSION
900 // (4) removed kernel events from the object hierarchy, added
901 // sc_hierarchical_name_exists().
902 //
903 // Revision 1.18 2011/03/20 13:43:23 acg
904 // Andy Goodrich: added async_signal_is() plus suspend() as a corner case.
905 //
906 // Revision 1.17 2011/03/07 18:25:19 acg
907 // Andy Goodrich: tightening of check for resume on a disabled process to
908 // only produce an error if it is ready to run.
909 //
910 // Revision 1.16 2011/03/06 15:58:50 acg
911 // Andy Goodrich: added escape to turn off process control corner case
912 // checks.
913 //
914 // Revision 1.15 2011/03/05 04:45:16 acg
915 // Andy Goodrich: moved active process calculation to the sc_simcontext class.
916 //
917 // Revision 1.14 2011/03/05 01:39:21 acg
918 // Andy Goodrich: changes for named events.
919 //
920 // Revision 1.13 2011/02/18 20:27:14 acg
921 // Andy Goodrich: Updated Copyrights.
922 //
923 // Revision 1.12 2011/02/13 21:47:38 acg
924 // Andy Goodrich: update copyright notice.
925 //
926 // Revision 1.11 2011/02/13 21:34:35 acg
927 // Andy Goodrich: added SC_UNITIALIZED enum value to process status so
928 // its possible to detect throws before initialization.
929 //
930 // Revision 1.10 2011/02/11 13:25:24 acg
931 // Andy Goodrich: Philipp A. Hartmann's changes:
932 // (1) Removal of SC_CTHREAD method overloads.
933 // (2) New exception processing code.
934 //
935 // Revision 1.9 2011/02/01 21:18:56 acg
936 // Andy Goodrich: addition of new preempt_with() method used to immediately
937 // throw exceptions from threads.
938 //
939 // Revision 1.8 2011/01/25 20:50:37 acg
940 // Andy Goodrich: changes for IEEE 1666 2011.
941 //
942 // Revision 1.7 2011/01/19 23:21:50 acg
943 // Andy Goodrich: changes for IEEE 1666 2011
944 //
945 // Revision 1.6 2011/01/18 20:10:45 acg
946 // Andy Goodrich: changes for IEEE1666_2011 semantics.
947 //
948 // Revision 1.5 2010/07/22 20:02:33 acg
949 // Andy Goodrich: bug fixes.
950 //
951 // Revision 1.4 2009/05/22 16:06:29 acg
952 // Andy Goodrich: process control updates.
953 //
954 // Revision 1.3 2008/05/22 17:06:26 acg
955 // Andy Goodrich: updated copyright notice to include 2008.
956 //
957 // Revision 1.2 2007/09/20 20:32:35 acg
958 // Andy Goodrich: changes to the semantics of throw_it() to match the
959 // specification. A call to throw_it() will immediately suspend the calling
960 // thread until all the throwees have executed. At that point the calling
961 // thread will be restarted before the execution of any other threads.
962 //
963 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
964 // SystemC 2.3
965 //
966 // Revision 1.13 2006/05/08 18:00:06 acg
967 // Andy Goodrich: added David Long's forward declarations for friend
968 // functions, methods, and operators to keep the Microsoft compiler happy.
969 //
970 // Revision 1.11 2006/04/11 23:13:21 acg
971 // Andy Goodrich: Changes for reduced reset support that only includes
972 // sc_cthread, but has preliminary hooks for expanding to method and thread
973 // processes also.
974 //
975 // Revision 1.10 2006/03/21 00:00:34 acg
976 // Andy Goodrich: changed name of sc_get_current_process_base() to be
977 // sc_get_current_process_b() since its returning an sc_process_b instance.
978 //
979 // Revision 1.9 2006/01/26 21:04:54 acg
980 // Andy Goodrich: deprecation message changes and additional messages.
981 //
982 // Revision 1.8 2006/01/24 20:49:05 acg
983 // Andy Goodrich: changes to remove the use of deprecated features within the
984 // simulator, and to issue warning messages when deprecated features are used.
985 //
986 // Revision 1.7 2006/01/19 00:29:52 acg
987 // Andy Goodrich: Yet another implementation for signal write checking. This
988 // one uses an environment variable SC_SIGNAL_WRITE_CHECK, that when set to
989 // DISABLE will disable write checking on signals.
990 //
991 // Revision 1.6 2006/01/18 21:42:37 acg
992 // Andy Goodrich: Changes for check writer support.
993 //
994 // Revision 1.5 2006/01/13 18:44:30 acg
995 // Added $Log to record CVS changes into the source.
996 //
997 // Revision 1.4 2006/01/03 23:18:44 acg
998 // Changed copyright to include 2006.
999 //
1000 // Revision 1.3 2005/12/20 22:11:10 acg
1001 // Fixed $Log lines.
1002 //
1003 // Revision 1.2 2005/12/20 22:02:30 acg
1004 // Changed where delta cycles are incremented to match IEEE 1666. Added the
1005 // event_occurred() method to hide how delta cycle comparisions are done within
1006 // sc_simcontext. Changed the boolean update_phase to an enum that shows all
1007 // the phases.
1008
1009 #endif
1010