sc_fxcast_switch.h revision 12027
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_fxcast_switch.h -
23
24  Original Author: Martin Janssen, Synopsys, Inc.
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_fxcast_switch.h,v $
39// Revision 1.2  2011/08/24 22:05:43  acg
40//  Torsten Maehne: initialization changes to remove warnings.
41//
42// Revision 1.1.1.1  2006/12/15 20:20:04  acg
43// SystemC 2.3
44//
45// Revision 1.3  2006/01/13 18:53:57  acg
46// Andy Goodrich: added $Log command so that CVS comments are reproduced in
47// the source.
48//
49
50#ifndef SC_FXCAST_SWITCH_H
51#define SC_FXCAST_SWITCH_H
52
53
54#include "sysc/datatypes/fx/sc_context.h"
55
56
57namespace sc_dt
58{
59
60// classes defined in this module
61class sc_fxcast_switch;
62
63
64// ----------------------------------------------------------------------------
65//  CLASS : sc_fxcast_switch
66//
67//  Fixed-point cast switch class.
68// ----------------------------------------------------------------------------
69
70class sc_fxcast_switch
71{
72
73public:
74
75             sc_fxcast_switch();
76             sc_fxcast_switch( sc_switch );
77             sc_fxcast_switch( const sc_fxcast_switch& );
78    explicit sc_fxcast_switch( sc_without_context );
79
80    sc_fxcast_switch& operator = ( const sc_fxcast_switch& );
81
82    friend bool operator == ( const sc_fxcast_switch&,
83			      const sc_fxcast_switch& );
84    friend bool operator != ( const sc_fxcast_switch&,
85			      const sc_fxcast_switch& );
86
87    const std::string to_string() const;
88
89    void print( ::std::ostream& = ::std::cout ) const;
90    void dump( ::std::ostream& = ::std::cout ) const;
91
92private:
93
94    sc_switch m_sw;
95
96};
97
98
99// ----------------------------------------------------------------------------
100//  TYPEDEF : sc_fxcast_context
101//
102//  Context type for the fixed-point cast switch parameter.
103// ----------------------------------------------------------------------------
104
105typedef sc_context<sc_fxcast_switch> sc_fxcast_context;
106
107
108// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
109
110inline
111sc_fxcast_switch::sc_fxcast_switch()
112: m_sw()
113{
114    *this = sc_fxcast_context::default_value();
115}
116
117inline
118sc_fxcast_switch::sc_fxcast_switch( sc_switch sw_ )
119: m_sw( sw_ )
120{}
121
122inline
123sc_fxcast_switch::sc_fxcast_switch( const sc_fxcast_switch& a )
124: m_sw( a.m_sw )
125{}
126
127inline
128sc_fxcast_switch::sc_fxcast_switch( sc_without_context )
129: m_sw( SC_DEFAULT_CAST_SWITCH_ )
130{}
131
132
133inline
134sc_fxcast_switch&
135sc_fxcast_switch::operator = ( const sc_fxcast_switch& a )
136{
137    if( &a != this )
138    {
139        m_sw = a.m_sw;
140    }
141    return *this;
142}
143
144
145inline
146bool
147operator == ( const sc_fxcast_switch& a, const sc_fxcast_switch& b )
148{
149    return ( a.m_sw == b.m_sw );
150}
151
152
153inline
154bool
155operator != ( const sc_fxcast_switch& a, const sc_fxcast_switch& b )
156{
157    return ( a.m_sw != b.m_sw );
158}
159
160
161inline
162::std::ostream&
163operator << ( ::std::ostream& os, const sc_fxcast_switch& a )
164{
165    a.print( os );
166    return os;
167}
168
169} // namespace sc_dt
170
171
172#endif
173
174// Taf!
175