SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_cor_qt.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_qt.h -- Coroutine implementation with QuickThreads.
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_QT_H
31#define SC_COR_QT_H
32
33
34#if !defined(_WIN32) && !defined(WIN32) && !defined(WIN64) && !defined(SC_USE_PTHREADS)
35
36#include "sysc/kernel/sc_cor.h"
37#include "sysc/packages/qt/qt.h"
38
39namespace sc_core {
40
41class sc_cor_pkg_qt;
43
44// ----------------------------------------------------------------------------
45// CLASS : sc_cor_qt
46//
47// Coroutine class implemented with QuickThreads.
48// ----------------------------------------------------------------------------
49
51 : public sc_cor
52{
53public:
54
55 // constructor
57 : m_stack_size( 0 ), m_stack( 0 ), m_sp( 0 ), m_pkg( 0 )
58 {}
59
60 // destructor
61 virtual ~sc_cor_qt();
62
63 // switch stack protection on/off
64 virtual void stack_protect( bool enable );
65
66public:
67 std::size_t m_stack_size; // stack size
68 void* m_stack; // stack
69 qt_t* m_sp; // stack pointer
70
71 sc_cor_pkg_qt* m_pkg; // the creating coroutine package
72
73private:
74 // disabled
75 sc_cor_qt( const sc_cor_qt& );
76 sc_cor_qt& operator = ( const sc_cor_qt& );
77};
78
79
80// ----------------------------------------------------------------------------
81// CLASS : sc_cor_pkg_qt
82//
83// Coroutine package class implemented with QuickThreads.
84// ----------------------------------------------------------------------------
85
87 : public sc_cor_pkg
88{
89public:
90
91 // constructor
92 explicit sc_cor_pkg_qt( sc_simcontext* simc );
93
94 // destructor
95 virtual ~sc_cor_pkg_qt();
96
97 // create a new coroutine
98 virtual sc_cor* create( std::size_t stack_size, sc_cor_fn* fn, void* arg );
99
100 // yield to the next coroutine
101 virtual void yield( sc_cor* next_cor );
102
103 // abort the current coroutine (and resume the next coroutine)
104 virtual void abort( sc_cor* next_cor );
105
106 // get the main coroutine
107 virtual sc_cor* get_main();
108
109 // set the current coroutine (internal helper)
111
112private:
113 sc_cor_qt m_main_cor; // main coroutine
114 sc_cor_qt* m_curr_cor; // current coroutine
115
116private:
117 // disabled
120 sc_cor_pkg_qt& operator = ( const sc_cor_pkg_qt& );
121};
122
123} // namespace sc_core
124
125#endif
126
127// $Log: sc_cor_qt.h,v $
128// Revision 1.6 2011/08/29 18:04:32 acg
129// Philipp A. Hartmann: miscellaneous clean ups.
130//
131// Revision 1.5 2011/08/26 20:46:09 acg
132// Andy Goodrich: moved the modification log to the end of the file to
133// eliminate source line number skew when check-ins are done.
134//
135// Revision 1.4 2011/02/18 20:27:14 acg
136// Andy Goodrich: Updated Copyrights.
137//
138// Revision 1.3 2011/02/13 21:47:37 acg
139// Andy Goodrich: update copyright notice.
140//
141// Revision 1.2 2008/05/22 17:06:25 acg
142// Andy Goodrich: updated copyright notice to include 2008.
143//
144// Revision 1.1.1.1 2006/12/15 20:20:05 acg
145// SystemC 2.3
146//
147// Revision 1.3 2006/01/13 18:44:29 acg
148// Added $Log to record CVS changes into the source.
149//
150
151#endif
152
153// Taf!
sc_cor_pkg_qt sc_cor_pkg_t
Definition: sc_cor_qt.h:42
void() sc_cor_fn(void *)
Definition: sc_cor.h:48
sc_cor_pkg_qt * m_pkg
Definition: sc_cor_qt.h:71
virtual ~sc_cor_qt()
std::size_t m_stack_size
Definition: sc_cor_qt.h:67
virtual void stack_protect(bool enable)
sc_cor_qt * set_current(sc_cor_qt *)
virtual void yield(sc_cor *next_cor)
virtual sc_cor * get_main()
virtual sc_cor * create(std::size_t stack_size, sc_cor_fn *fn, void *arg)
virtual void abort(sc_cor *next_cor)
sc_cor_pkg_qt(sc_simcontext *simc)