SystemC
2.3.1
Accellera SystemC proof-of-concept library
Main Page
Namespaces
Classes
Files
File List
File Members
sysc
kernel
sc_module_name.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_module_name.h -- An object used to help manage object names
21
and hierarchy.
22
23
Original Author: Stan Y. Liao, Synopsys, Inc.
24
25
CHANGE LOG AT THE END OF THE FILE
26
*****************************************************************************/
27
28
// $Log: sc_module_name.h,v $
29
// Revision 1.5 2011/08/26 20:46:10 acg
30
// Andy Goodrich: moved the modification log to the end of the file to
31
// eliminate source line number skew when check-ins are done.
32
//
33
34
#ifndef SC_MODULE_NAME_H
35
#define SC_MODULE_NAME_H
36
37
38
namespace
sc_core {
39
40
class
sc_module;
41
class
sc_simcontext;
42
43
44
// ----------------------------------------------------------------------------
45
// CLASS : sc_module_name
46
//
47
// Module name class.
48
// ----------------------------------------------------------------------------
49
50
class
sc_module_name
51
{
52
friend
class
sc_module
;
53
friend
class
sc_object_manager
;
54
55
public
:
56
57
sc_module_name
(
const
char
* );
58
sc_module_name
(
const
sc_module_name
& );
59
60
~sc_module_name
();
61
62
operator
const
char
*()
const
;
63
64
protected
:
65
inline
void
clear_module
(
sc_module
* module_p );
66
inline
void
set_module
(
sc_module
* module_p );
67
68
private
:
69
70
const
char
* m_name;
71
sc_module
* m_module_p;
72
sc_module_name
* m_next;
73
sc_simcontext
* m_simc;
74
bool
m_pushed;
75
76
private
:
77
78
// disabled
79
sc_module_name
();
80
sc_module_name
& operator = (
const
sc_module_name
& );
81
};
82
83
inline
void
sc_module_name::clear_module
(
sc_module
* module_p )
84
{
85
assert( m_module_p == module_p );
86
m_module_p = 0;
87
}
88
89
inline
void
sc_module_name::set_module
(
sc_module
* module_p )
90
{
91
m_module_p = module_p;
92
}
93
94
}
// namespace sc_core
95
96
// Revision 1.4 2011/02/18 20:27:14 acg
97
// Andy Goodrich: Updated Copyrights.
98
//
99
// Revision 1.3 2011/02/13 21:47:37 acg
100
// Andy Goodrich: update copyright notice.
101
//
102
// Revision 1.2 2008/05/22 17:06:26 acg
103
// Andy Goodrich: updated copyright notice to include 2008.
104
//
105
// Revision 1.1.1.1 2006/12/15 20:20:05 acg
106
// SystemC 2.3
107
//
108
// Revision 1.4 2006/03/14 23:56:58 acg
109
// Andy Goodrich: This fixes a bug when an exception is thrown in
110
// sc_module::sc_module() for a dynamically allocated sc_module
111
// object. We are calling sc_module::end_module() on a module that has
112
// already been deleted. The scenario runs like this:
113
//
114
// a) the sc_module constructor is entered
115
// b) the exception is thrown
116
// c) the exception processor deletes the storage for the sc_module
117
// d) the stack is unrolled causing the sc_module_name instance to be deleted
118
// e) ~sc_module_name() calls end_module() with its pointer to the sc_module
119
// f) because the sc_module has been deleted its storage is corrupted,
120
// either by linking it to a free space chain, or by reuse of some sort
121
// g) the m_simc field is garbage
122
// h) the m_object_manager field is also garbage
123
// i) an exception occurs
124
//
125
// This does not happen for automatic sc_module instances since the
126
// storage for the module is not reclaimed its just part of the stack.
127
//
128
// I am fixing this by having the destructor for sc_module clear the
129
// module pointer in its sc_module_name instance. That cuts things at
130
// step (e) above, since the pointer will be null if the module has
131
// already been deleted. To make sure the module stack is okay, I call
132
// end-module() in ~sc_module in the case where there is an
133
// sc_module_name pointer lying around.
134
//
135
// Revision 1.3 2006/01/13 18:44:30 acg
136
// Added $Log to record CVS changes into the source.
137
138
#endif
sc_core::sc_simcontext
Definition:
sc_simcontext.h:135
sc_core::sc_module_name
Definition:
sc_module_name.h:50
sc_core::sc_module_name::clear_module
void clear_module(sc_module *module_p)
Definition:
sc_module_name.h:83
sc_core::sc_object_manager
Definition:
sc_object_manager.h:47
sc_core::sc_module
Definition:
sc_module.h:77
sc_core::sc_module_name::set_module
void set_module(sc_module *module_p)
Definition:
sc_module_name.h:89
sc_core::sc_module_name::~sc_module_name
~sc_module_name()
Generated on Thu Jun 19 2014 07:41:23 for SystemC by
1.8.6