SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_join.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_join.h -- Join Process Synchronization Definition
21 
22  Original Author: Andy Goodrich, Forte Design Systems, 5 May 2003
23 
24  CHANGE LOG AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 // $Log: sc_join.h,v $
28 // Revision 1.8 2011/08/26 21:45:00 acg
29 // Andy Goodrich: fix internal event naming.
30 //
31 // Revision 1.7 2011/08/26 20:46:09 acg
32 // Andy Goodrich: moved the modification log to the end of the file to
33 // eliminate source line number skew when check-ins are done.
34 //
35 
36 #ifndef SC_JOIN_H
37 #define SC_JOIN_H
38 
39 #include "sysc/kernel/sc_process.h"
40 #include "sysc/kernel/sc_wait.h"
41 
42 namespace sc_core {
43 
44 //==============================================================================
45 // CLASS sc_join
46 //
47 // This class provides a way of waiting for a set of threads to complete their
48 // execution. The threads whose completion is to be monitored are registered,
49 // and upon their completion an event notification will occur.
50 //==============================================================================
51 class sc_join : public sc_process_monitor {
52  friend class sc_process_b;
53  friend class sc_process_handle;
54  public:
55  sc_join();
56  void add_process( sc_process_handle process_h );
57  inline int process_count();
58  virtual void signal(sc_thread_handle thread_p, int type);
59 
64  // 08/19/2015 GL: modified for the OoO simulation
65  inline void wait( int seg_id );
66 
71  // 08/19/2015 GL: modified for the OoO simulation
72  inline void wait_clocked( int seg_id );
73 
74  protected:
75  void add_process( sc_process_b* process_p );
76 
77  protected:
78  sc_event m_join_event; // Event to notify when all threads have reported.
79  int m_threads_n; // # of threads still need to wait for.
80 };
81 
83 
84 // 08/19/2015 GL: modified for the OoO simulation
85 
86 // suspend a thread that does not have a sensitivity list:
87 
88 inline void sc_join::wait( int seg_id )
89 { ::sc_core::wait(m_join_event, seg_id); }
90 
91 // suspend a thread that has a sensitivity list:
92 
93 inline void sc_join::wait_clocked( int seg_id )
94 {
95  do { ::sc_core::wait( seg_id ); } while (m_threads_n != 0);
96 }
97 
98 #define SC_CJOIN \
99  }; \
100  sc_core::sc_join join; \
101  for ( unsigned int i = 0; \
102  i < sizeof(forkees)/sizeof(sc_core::sc_process_handle); \
103  i++ ) \
104  join.add_process(forkees[i]); \
105  join.wait_clocked(); \
106 }
107 
108 #define SC_FORK \
109 { \
110  sc_core::sc_process_handle forkees[] = {
111 
112 #define SC_JOIN \
113  }; \
114  sc_core::sc_join join; \
115  for ( unsigned int i = 0; \
116  i < sizeof(forkees)/sizeof(sc_core::sc_process_handle); \
117  i++ ) \
118  join.add_process(forkees[i]); \
119  join.wait(); \
120 }
121 
122 } // namespace sc_core
123 
124 // Revision 1.6 2011/08/24 22:05:50 acg
125 // Torsten Maehne: initialization changes to remove warnings.
126 //
127 // Revision 1.5 2011/02/18 20:27:14 acg
128 // Andy Goodrich: Updated Copyrights.
129 //
130 // Revision 1.4 2011/02/13 21:47:37 acg
131 // Andy Goodrich: update copyright notice.
132 //
133 // Revision 1.3 2009/07/28 01:10:53 acg
134 // Andy Goodrich: updates for 2.3 release candidate.
135 //
136 // Revision 1.2 2008/05/22 17:06:25 acg
137 // Andy Goodrich: updated copyright notice to include 2008.
138 //
139 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
140 // SystemC 2.3
141 //
142 // Revision 1.5 2006/04/28 21:38:27 acg
143 // Andy Goodrich: fixed loop constraint that was using sizeof(sc_thread_handle)
144 // rather than sizeof(sc_process_handle).
145 //
146 // Revision 1.4 2006/01/13 18:44:29 acg
147 // Added $Log to record CVS changes into the source.
148 
149 #endif // SC_JOIN_H
This class provides access to an sc_process_b object instance in a manner which allows some persisten...
int process_count()
Definition: sc_join.h:82
void wait(int seg_id)
A new parameter segment ID is added for the out-of-order simulation.
Definition: sc_join.h:88
void wait(int, sc_simcontext *)
User initiated dynamic process support.
Definition: sc_process.h:558
sc_event m_join_event
Definition: sc_join.h:78
class sc_thread_process * sc_thread_handle
Definition: sc_process.h:121
The event class.
Definition: sc_event.h:260
void wait_clocked(int seg_id)
A new parameter segment ID is added for the out-of-order simulation.
Definition: sc_join.h:93
virtual void signal(sc_thread_handle thread_p, int type)
void add_process(sc_process_handle process_h)