scfx_params.h revision 12027:1eb7dc7aa10b
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  scfx_params.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: scfx_params.h,v $
39// Revision 1.1.1.1  2006/12/15 20:20:04  acg
40// SystemC 2.3
41//
42// Revision 1.3  2006/01/13 18:53:58  acg
43// Andy Goodrich: added $Log command so that CVS comments are reproduced in
44// the source.
45//
46
47#ifndef SCFX_PARAMS_H
48#define SCFX_PARAMS_H
49
50
51#include "sysc/datatypes/fx/sc_fx_ids.h"
52#include "sysc/datatypes/fx/sc_fxcast_switch.h"
53#include "sysc/datatypes/fx/sc_fxtype_params.h"
54
55
56namespace sc_dt
57{
58
59// classes defined in this module
60class scfx_params;
61
62
63// ----------------------------------------------------------------------------
64//  CLASS : scfx_params
65//
66//  ...
67// ----------------------------------------------------------------------------
68
69class scfx_params
70{
71
72public:
73
74    // constructor
75
76    scfx_params( const sc_fxtype_params&,
77		 sc_enc,
78		 const sc_fxcast_switch& );
79
80
81    // query functions
82
83    const sc_fxtype_params& type_params() const;
84    sc_enc enc() const;
85    const sc_fxcast_switch& cast_switch() const;
86
87
88    // shortcuts
89
90    int wl() const;
91    int iwl() const;
92    int fwl() const;
93    sc_q_mode q_mode() const;
94    sc_o_mode o_mode() const;
95    int n_bits() const;
96
97
98    // dump content
99
100    void dump( ::std::ostream& ) const;
101
102private:
103
104    sc_fxtype_params m_type_params;
105    sc_enc           m_enc;
106    sc_fxcast_switch m_cast_switch;
107
108};
109
110
111// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
112
113// constructor
114
115inline
116scfx_params::scfx_params( const sc_fxtype_params& type_params_,
117			  sc_enc enc_,
118			  const sc_fxcast_switch& cast_sw )
119: m_type_params( type_params_ ),
120  m_enc( enc_ ),
121  m_cast_switch( cast_sw )
122{
123    if( m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM )
124    {
125	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_O_MODE_,
126			 "SC_WRAP_SM not defined for unsigned numbers" );
127    }
128
129}
130
131
132// query functions
133
134inline
135const sc_fxtype_params&
136scfx_params::type_params() const
137{
138    return m_type_params;
139}
140
141inline
142sc_enc
143scfx_params::enc() const
144{
145    return m_enc;
146}
147
148inline
149const sc_fxcast_switch&
150scfx_params::cast_switch() const
151{
152    return m_cast_switch;
153}
154
155
156// shortcuts
157
158inline
159int
160scfx_params::wl() const
161{
162    return m_type_params.wl();
163}
164
165inline
166int
167scfx_params::iwl() const
168{
169    return m_type_params.iwl();
170}
171
172inline
173int
174scfx_params::fwl() const
175{
176    return ( m_type_params.wl() - m_type_params.iwl() );
177}
178
179inline
180sc_q_mode
181scfx_params::q_mode() const
182{
183    return m_type_params.q_mode();
184}
185
186inline
187sc_o_mode
188scfx_params::o_mode() const
189{
190    return m_type_params.o_mode();
191}
192
193inline
194int
195scfx_params::n_bits() const
196{
197    return m_type_params.n_bits();
198}
199
200
201// dump content
202
203inline
204void
205scfx_params::dump( ::std::ostream& os ) const
206{
207    os << "scfx_params" << ::std::endl;
208    os << "(" << ::std::endl;
209    os << "type_params = ";
210    m_type_params.dump( os );
211    os << "enc         = " << m_enc << ::std::endl;
212    os << "cast_switch = ";
213    m_cast_switch.dump( os );
214    os << ")" << ::std::endl;
215}
216
217} // namespace sc_dt
218
219
220#endif
221
222// Taf!
223