scfx_params.hh revision 12853
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 __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
48#define __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
49
50#include "sc_fxcast_switch.hh"
51#include "sc_fxtype_params.hh"
52
53namespace sc_dt
54{
55
56// classes defined in this module
57class scfx_params;
58
59
60// ----------------------------------------------------------------------------
61//  CLASS : scfx_params
62//
63//  ...
64// ----------------------------------------------------------------------------
65
66class scfx_params
67{
68  public:
69    // constructor
70    scfx_params(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &);
71
72    // query functions
73    const sc_fxtype_params &type_params() const;
74    sc_enc enc() const;
75    const sc_fxcast_switch &cast_switch() const;
76
77    // shortcuts
78    int wl() const;
79    int iwl() const;
80    int fwl() const;
81    sc_q_mode q_mode() const;
82    sc_o_mode o_mode() const;
83    int n_bits() const;
84
85    // dump content
86    void dump(::std::ostream &) const;
87
88  private:
89    sc_fxtype_params m_type_params;
90    sc_enc m_enc;
91    sc_fxcast_switch m_cast_switch;
92};
93
94
95// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
96
97// constructor
98inline scfx_params::scfx_params(const sc_fxtype_params &type_params_,
99                                sc_enc enc_,
100                                const sc_fxcast_switch &cast_sw) :
101    m_type_params(type_params_), m_enc(enc_), m_cast_switch(cast_sw)
102{
103    if (m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM) {
104        SC_REPORT_ERROR("invalid overflow mode",
105                        "SC_WRAP_SM not defined for unsigned numbers");
106        // may continue, if suppressed
107    }
108}
109
110// query functions
111inline const sc_fxtype_params &
112scfx_params::type_params() const
113{
114    return m_type_params;
115}
116
117inline sc_enc
118scfx_params::enc() const
119{
120    return m_enc;
121}
122
123inline const sc_fxcast_switch &
124scfx_params::cast_switch() const
125{
126    return m_cast_switch;
127}
128
129// shortcuts
130inline int
131scfx_params::wl() const
132{
133    return m_type_params.wl();
134}
135
136inline int
137scfx_params::iwl() const
138{
139    return m_type_params.iwl();
140}
141
142inline int
143scfx_params::fwl() const
144{
145    return (m_type_params.wl() - m_type_params.iwl());
146}
147
148inline sc_q_mode
149scfx_params::q_mode() const
150{
151    return m_type_params.q_mode();
152}
153
154inline sc_o_mode
155scfx_params::o_mode() const
156{
157    return m_type_params.o_mode();
158}
159
160inline int
161scfx_params::n_bits() const
162{
163    return m_type_params.n_bits();
164}
165
166// dump content
167inline void
168scfx_params::dump(::std::ostream &os) const
169{
170    os << "scfx_params" << ::std::endl;
171    os << "(" << ::std::endl;
172    os << "type_params = ";
173    m_type_params.dump( os );
174    os << "enc         = " << m_enc << ::std::endl;
175    os << "cast_switch = ";
176    m_cast_switch.dump( os );
177    os << ")" << ::std::endl;
178}
179
180} // namespace sc_dt
181
182#endif // __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
183