SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_cor.h
Go to the documentation of this file.
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_cor.h -- Coroutine abstract base classes.
23 */
34 #ifndef SC_COR_H
35 #define SC_COR_H
36 
37 #include <cassert> // use plain assert, sc_report may not be available, yet
38 #include <cstdlib>
39 #include "sysc/kernel/sc_cmnhdr.h"
40 
41 namespace sc_core {
42 
43 class sc_simcontext;
44 
45 
52 typedef void (sc_cor_fn)( void* );
53 
54 
62 {
63 protected:
64 
65  // constructor
66  sc_cor() {}
67 
68 public:
69 
70  // destructor
71  virtual ~sc_cor() {}
72 
73  // switch stack protection on/off
74  virtual void stack_protect( bool /* enable */ ) {}
75 
76 private:
77 
78  // disabled
79  sc_cor( const sc_cor& );
80  sc_cor& operator = ( const sc_cor& );
81 };
82 
83 
91 {
92 public:
93 
94  // constructor
96  : m_simc( simc ) { assert( simc != 0 ); }
97 
98  // destructor
99  virtual ~sc_cor_pkg() {}
100 
101  // create a new coroutine
102  virtual sc_cor* create(
103  std::size_t stack_size, sc_cor_fn* fn, void* arg ) = 0;
104 
105  // yield to the next coroutine
106  virtual void yield( sc_cor* next_cor ) = 0;
107 
108  // abort the current coroutine (and resume the next coroutine)
109  virtual void abort( sc_cor* next_cor ) = 0;
110 
111  // get the main coroutine
112  virtual sc_cor* get_main() = 0;
113 
114  // get the simulation context
116  { return m_simc; }
117 
118 private:
119 
120  sc_simcontext* m_simc;
121 
122 private:
123 
124  // disabled
125  sc_cor_pkg();
126  sc_cor_pkg( const sc_cor_pkg& );
127  sc_cor_pkg& operator = ( const sc_cor_pkg& );
128 };
129 
130 } // namespace sc_core
131 
132 // $Log: sc_cor.h,v $
133 // Revision 1.7 2011/08/26 20:46:09 acg
134 // Andy Goodrich: moved the modification log to the end of the file to
135 // eliminate source line number skew when check-ins are done.
136 //
137 // Revision 1.6 2011/08/15 16:43:24 acg
138 // Torsten Maehne: changes to remove unused argument warnings.
139 //
140 // Revision 1.5 2011/02/18 20:27:14 acg
141 // Andy Goodrich: Updated Copyrights.
142 //
143 // Revision 1.4 2011/02/13 21:47:37 acg
144 // Andy Goodrich: update copyright notice.
145 //
146 // Revision 1.3 2011/01/19 23:21:49 acg
147 // Andy Goodrich: changes for IEEE 1666 2011
148 //
149 // Revision 1.2 2008/05/22 17:06:24 acg
150 // Andy Goodrich: updated copyright notice to include 2008.
151 //
152 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
153 // SystemC 2.3
154 //
155 // Revision 1.3 2006/01/13 18:44:29 acg
156 // Added $Log to record CVS changes into the source.
157 //
158 
159 #endif
160 
161 // Taf!
sc_cor_pkg(sc_simcontext *simc)
Definition: sc_cor.h:95
sc_simcontext * simcontext()
Definition: sc_cor.h:115
virtual ~sc_cor_pkg()
Definition: sc_cor.h:99
virtual void stack_protect(bool)
Definition: sc_cor.h:74
Coroutine abstract base class.
Definition: sc_cor.h:61
virtual ~sc_cor()
Definition: sc_cor.h:71
The simulation context.
Coroutine package abstract base class.
Definition: sc_cor.h:90
void() sc_cor_fn(void *)
Function type for creating coroutines.
Definition: sc_cor.h:52
class SC_API sc_simcontext
Definition: sc_object.h:51
#define SC_API
Definition: sc_cmnhdr.h:168