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