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