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_length_param.h -
23
24 Original Author: Martin Janssen, Synopsys, Inc., 2002-03-19
25
26 *****************************************************************************/
27
28 /*****************************************************************************
29
30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31 changes you are making here.
32
33 Name, Affiliation, Date:
34 Description of Modification:
35
36 *****************************************************************************/
37
38 // $Log: sc_length_param.h,v $
39 // Revision 1.3 2011/08/24 22:05:46 acg
40 // Torsten Maehne: initialization changes to remove warnings.
41 //
42 // Revision 1.2 2011/02/18 20:19:15 acg
43 // Andy Goodrich: updating Copyright notice.
44 //
45 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
46 // SystemC 2.3
47 //
48 // Revision 1.4 2006/05/08 17:50:01 acg
49 // Andy Goodrich: Added David Long's declarations for friend operators,
50 // functions, and methods, to keep the Microsoft compiler happy.
51 //
52 // Revision 1.3 2006/01/13 18:49:32 acg
53 // Added $Log command so that CVS check in comments are reproduced in the
54 // source.
55 //
56
57 #ifndef SC_LENGTH_PARAM_H
58 #define SC_LENGTH_PARAM_H
59
60
61 #include "sysc/datatypes/fx/sc_context.h"
62
63
64 namespace sc_dt
65 {
66
67 // classes defined in this module
68 class sc_length_param;
69
70 // friend operator declarations
71 SC_API bool operator == ( const sc_length_param&,
72 const sc_length_param& );
73 SC_API bool operator != ( const sc_length_param&,
74 const sc_length_param& );
75
76
77 // ----------------------------------------------------------------------------
78 // CLASS : sc_length_param
79 //
80 // Length parameter type.
81 // ----------------------------------------------------------------------------
82
83 class SC_API sc_length_param
84 {
85 public:
86
87 sc_length_param();
88 sc_length_param( int );
89 sc_length_param( const sc_length_param& );
90 explicit sc_length_param( sc_without_context );
91
92 sc_length_param& operator = ( const sc_length_param& );
93
94 friend SC_API bool operator == ( const sc_length_param&,
95 const sc_length_param& );
96 friend SC_API bool operator != ( const sc_length_param&,
97 const sc_length_param& );
98
99 int len() const;
100 void len( int );
101
102 const std::string to_string() const;
103
104 void print( ::std::ostream& = ::std::cout ) const;
105 void dump( ::std::ostream& = ::std::cout ) const;
106
107 private:
108
109 int m_len;
110 };
111
112 } // namespace sc_dt
113
114 // ----------------------------------------------------------------------------
115 // TYPEDEF : sc_length_context
116 //
117 // Context type for the length parameter type.
118 // ----------------------------------------------------------------------------
119
120 // extern template instantiations
121 namespace sc_core {
122 SC_API_TEMPLATE_DECL_ sc_phash<void*, const sc_dt::sc_length_param*>;
123 } // namespace sc_core
124
125 namespace sc_dt {
126
127 SC_API_TEMPLATE_DECL_ sc_global<sc_length_param>;
128 SC_API_TEMPLATE_DECL_ sc_context<sc_length_param>;
129 typedef sc_context<sc_length_param> sc_length_context;
130
131
132 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
133
134 inline
sc_length_param()135 sc_length_param::sc_length_param() : m_len()
136 {
137 *this = sc_length_context::default_value();
138 }
139
140 inline
sc_length_param(int len_)141 sc_length_param::sc_length_param( int len_ ) : m_len(len_)
142 {
143 SC_CHECK_WL_( len_ );
144 }
145
146 inline
sc_length_param(const sc_length_param & a)147 sc_length_param::sc_length_param( const sc_length_param& a )
148 : m_len( a.m_len )
149 {}
150
151 inline
sc_length_param(sc_without_context)152 sc_length_param::sc_length_param( sc_without_context )
153 : m_len( SC_DEFAULT_WL_ )
154 {}
155
156
157 inline
158 sc_length_param&
159 sc_length_param::operator = ( const sc_length_param& a )
160 {
161 if( &a != this )
162 {
163 m_len = a.m_len;
164 }
165 return *this;
166 }
167
168
169 inline
170 bool
171 operator == ( const sc_length_param& a, const sc_length_param& b )
172 {
173 return ( a.m_len == b.m_len );
174 }
175
176 inline
177 bool
178 operator != ( const sc_length_param& a, const sc_length_param& b )
179 {
180 return ( a.m_len != b.m_len );
181 }
182
183
184 inline
185 int
len()186 sc_length_param::len() const
187 {
188 return m_len;
189 }
190
191 inline
192 void
len(int len_)193 sc_length_param::len( int len_ )
194 {
195 SC_CHECK_WL_( len_ );
196 m_len = len_;
197 }
198
199
200 inline
201 ::std::ostream&
202 operator << ( ::std::ostream& os, const sc_length_param& a )
203 {
204 a.print( os );
205 return os;
206 }
207
208 } // namespace sc_dt
209
210
211 #endif
212
213 // Taf!
214