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_fxtype_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: sc_fxtype_params.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:58 acg 46// Andy Goodrich: added $Log command so that CVS comments are reproduced in 47// the source. 48// 49 50#ifndef __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAMS_HH__ 51#define __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAMS_HH__ 52 53#include <iostream> 54 55#include "sc_context.hh" 56#include "sc_fxdefs.hh" 57 58namespace sc_dt 59{ 60 61// classes defined in this module 62class sc_fxtype_params; 63 64// ---------------------------------------------------------------------------- 65// CLASS : sc_fxtype_params 66// 67// Fixed-point type parameters class. 68// ---------------------------------------------------------------------------- 69 70class sc_fxtype_params 71{ 72 public: 73 sc_fxtype_params(); 74 sc_fxtype_params(int, int); 75 sc_fxtype_params(sc_q_mode, sc_o_mode, int=0); 76 sc_fxtype_params(int, int, sc_q_mode, sc_o_mode, int=0); 77 sc_fxtype_params(const sc_fxtype_params &); 78 sc_fxtype_params(const sc_fxtype_params &, int, int); 79 sc_fxtype_params(const sc_fxtype_params&, sc_q_mode, sc_o_mode, int=0); 80 explicit sc_fxtype_params(sc_without_context); 81 82 sc_fxtype_params &operator = (const sc_fxtype_params &); 83 84 friend bool operator == (const sc_fxtype_params &, 85 const sc_fxtype_params &); 86 friend bool operator != (const sc_fxtype_params &, 87 const sc_fxtype_params &); 88 89 int wl() const; 90 void wl(int); 91 92 int iwl() const; 93 void iwl(int); 94 95 sc_q_mode q_mode() const; 96 void q_mode(sc_q_mode); 97 98 sc_o_mode o_mode() const; 99 void o_mode(sc_o_mode); 100 101 int n_bits() const; 102 void n_bits(int); 103 104 const std::string to_string() const; 105 106 void print(::std::ostream & =::std::cout) const; 107 void dump(::std::ostream & =::std::cout) const; 108 109 private: 110 int m_wl; 111 int m_iwl; 112 sc_q_mode m_q_mode; 113 sc_o_mode m_o_mode; 114 int m_n_bits; 115}; 116 117} // namespace sc_dt 118 119// ---------------------------------------------------------------------------- 120// TYPEDEF : sc_fxtype_context 121// 122// Context type for the fixed-point type parameters. 123// ---------------------------------------------------------------------------- 124 125// extern template instantiations 126namespace sc_dt 127{ 128 129extern template class sc_global<sc_fxtype_params>; 130extern template class sc_context<sc_fxtype_params>; 131typedef sc_context<sc_fxtype_params> sc_fxtype_context; 132 133 134// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 135 136inline sc_fxtype_params::sc_fxtype_params() : 137 m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits() 138{ 139 *this = sc_fxtype_context::default_value(); 140} 141 142inline sc_fxtype_params::sc_fxtype_params(int wl_, int iwl_) : 143 m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits() 144{ 145 *this = sc_fxtype_context::default_value(); 146 147 SC_CHECK_WL_(wl_); 148 m_wl = wl_; 149 m_iwl = iwl_; 150} 151 152inline sc_fxtype_params::sc_fxtype_params( 153 sc_q_mode q_mode_, sc_o_mode o_mode_, int n_bits_) : 154 m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits() 155{ 156 *this = sc_fxtype_context::default_value(); 157 158 SC_CHECK_N_BITS_(n_bits_); 159 m_q_mode = q_mode_; 160 m_o_mode = o_mode_; 161 m_n_bits = n_bits_; 162} 163 164inline sc_fxtype_params::sc_fxtype_params( 165 int wl_, int iwl_, sc_q_mode q_mode_, sc_o_mode o_mode_, int n_bits_) : 166 m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits() 167{ 168 SC_CHECK_WL_(wl_); 169 SC_CHECK_N_BITS_(n_bits_); 170 m_wl = wl_; 171 m_iwl = iwl_; 172 m_q_mode = q_mode_; 173 m_o_mode = o_mode_; 174 m_n_bits = n_bits_; 175} 176 177inline sc_fxtype_params::sc_fxtype_params(const sc_fxtype_params &a) : 178 m_wl(a.m_wl), m_iwl(a.m_iwl), m_q_mode(a.m_q_mode), 179 m_o_mode(a.m_o_mode), m_n_bits(a.m_n_bits) 180{} 181 182inline sc_fxtype_params::sc_fxtype_params( 183 const sc_fxtype_params &a, int wl_, int iwl_) : 184 m_wl(wl_), m_iwl(iwl_), m_q_mode(a.m_q_mode), m_o_mode(a.m_o_mode), 185 m_n_bits(a.m_n_bits) 186{} 187 188inline sc_fxtype_params::sc_fxtype_params( 189 const sc_fxtype_params &a, sc_q_mode q_mode_, sc_o_mode o_mode_, 190 int n_bits_) : 191 m_wl(a.m_wl), m_iwl(a.m_iwl), m_q_mode(q_mode_), m_o_mode(o_mode_), 192 m_n_bits(n_bits_) 193{} 194 195inline sc_fxtype_params::sc_fxtype_params(sc_without_context) : 196 m_wl(SC_DEFAULT_WL_), m_iwl(SC_DEFAULT_IWL_), 197 m_q_mode(SC_DEFAULT_Q_MODE_), m_o_mode(SC_DEFAULT_O_MODE_), 198 m_n_bits(SC_DEFAULT_N_BITS_) 199{} 200 201inline sc_fxtype_params & 202sc_fxtype_params::operator = (const sc_fxtype_params &a) 203{ 204 if (&a != this) { 205 m_wl = a.m_wl; 206 m_iwl = a.m_iwl; 207 m_q_mode = a.m_q_mode; 208 m_o_mode = a.m_o_mode; 209 m_n_bits = a.m_n_bits; 210 } 211 return *this; 212} 213 214inline bool 215operator == (const sc_fxtype_params &a, const sc_fxtype_params &b) 216{ 217 return (a.m_wl == b.m_wl && a.m_iwl == b.m_iwl && 218 a.m_q_mode == b.m_q_mode && a.m_o_mode == b.m_o_mode && 219 a.m_n_bits == b.m_n_bits); 220} 221 222inline bool 223operator != (const sc_fxtype_params &a, const sc_fxtype_params &b) 224{ 225 return (a.m_wl != b.m_wl || a.m_iwl != b.m_iwl || 226 a.m_q_mode != b.m_q_mode || a.m_o_mode != b.m_o_mode || 227 a.m_n_bits != b.m_n_bits ); 228} 229 230inline int sc_fxtype_params::wl() const { return m_wl; } 231inline void 232sc_fxtype_params::wl(int wl_) 233{ 234 SC_CHECK_WL_(wl_); 235 m_wl = wl_; 236} 237 238inline int sc_fxtype_params::iwl() const { return m_iwl; } 239inline void sc_fxtype_params::iwl(int iwl_) { m_iwl = iwl_; } 240 241 242inline sc_q_mode sc_fxtype_params::q_mode() const { return m_q_mode; } 243inline void sc_fxtype_params::q_mode(sc_q_mode q_mode_) { m_q_mode = q_mode_; } 244 245inline sc_o_mode sc_fxtype_params::o_mode() const { return m_o_mode; } 246inline void sc_fxtype_params::o_mode(sc_o_mode o_mode_) { m_o_mode = o_mode_; } 247 248inline int sc_fxtype_params::n_bits() const { return m_n_bits; } 249inline void 250sc_fxtype_params::n_bits(int n_bits_) 251{ 252 SC_CHECK_N_BITS_(n_bits_); 253 m_n_bits = n_bits_; 254} 255 256inline ::std::ostream & 257operator << (::std::ostream &os, const sc_fxtype_params &a) 258{ 259 a.print(os); 260 return os; 261} 262 263} // namespace sc_dt 264 265#endif // __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAM_HH__ 266