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