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 __SYSTEMC_EXT_DT_FX_SC_FXCAST_SWITCH_HH__ 51#define __SYSTEMC_EXT_DT_FX_SC_FXCAST_SWITCH_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_fxcast_switch; 63 64 65// ---------------------------------------------------------------------------- 66// CLASS : sc_fxcast_switch 67// 68// Fixed-point cast switch class. 69// ---------------------------------------------------------------------------- 70 71class sc_fxcast_switch 72{ 73 public: 74 sc_fxcast_switch(); 75 sc_fxcast_switch(sc_switch); 76 sc_fxcast_switch(const sc_fxcast_switch &); 77 explicit sc_fxcast_switch(sc_without_context); 78 79 sc_fxcast_switch &operator = (const sc_fxcast_switch &); 80 81 friend bool operator == (const sc_fxcast_switch &, 82 const sc_fxcast_switch &); 83 friend bool operator != (const sc_fxcast_switch &, 84 const sc_fxcast_switch &); 85 86 const std::string to_string() const; 87 88 void print(::std::ostream & =::std::cout) const; 89 void dump(::std::ostream & =::std::cout) const; 90 91 private: 92 sc_switch m_sw; 93}; 94 95} // namespace sc_dt 96 97// ---------------------------------------------------------------------------- 98// TYPEDEF : sc_fxcast_context 99// 100// Context type for the fixed-point cast switch parameter. 101// ---------------------------------------------------------------------------- 102 103namespace sc_dt 104{ 105 106extern template class sc_global<sc_fxcast_switch>; 107extern template class sc_context<sc_fxcast_switch>; 108 109typedef sc_context<sc_fxcast_switch> sc_fxcast_context; 110 111 112// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 113 114inline sc_fxcast_switch::sc_fxcast_switch() : m_sw() 115{ 116 *this = sc_fxcast_context::default_value(); 117} 118 119inline sc_fxcast_switch::sc_fxcast_switch(sc_switch sw_) : m_sw( sw_ ) {} 120 121inline sc_fxcast_switch::sc_fxcast_switch(const sc_fxcast_switch &a) : 122 m_sw(a.m_sw) 123{} 124 125inline sc_fxcast_switch::sc_fxcast_switch(sc_without_context) : 126 m_sw(SC_DEFAULT_CAST_SWITCH_) 127{} 128 129inline sc_fxcast_switch & 130sc_fxcast_switch::operator = (const sc_fxcast_switch &a) 131{ 132 if (&a != this) { 133 m_sw = a.m_sw; 134 } 135 return *this; 136} 137 138inline bool 139operator == (const sc_fxcast_switch &a, const sc_fxcast_switch &b) 140{ 141 return (a.m_sw == b.m_sw); 142} 143 144inline bool 145operator != (const sc_fxcast_switch &a, const sc_fxcast_switch &b) 146{ 147 return (a.m_sw != b.m_sw); 148} 149 150inline ::std::ostream & 151operator << (::std::ostream &os, const sc_fxcast_switch &a) 152{ 153 a.print(os); 154 return os; 155} 156 157} // namespace sc_dt 158 159#endif // __SYSTEMC_EXT_DT_FX_SC_FXCAST_SWITCH_HH__ 160