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