scfx_other_defs.hh revision 12853:e23d6f09069a
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_other_defs.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_other_defs.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_OTHER_DEFS_HH__ 48#define __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__ 49 50#include "../int/sc_int_base.hh" 51#include "../int/sc_signed.hh" 52#include "../int/sc_uint_base.hh" 53#include "../int/sc_unsigned.hh" 54 55namespace sc_dt 56{ 57 58// ---------------------------------------------------------------------------- 59// CLASS : sc_signed 60// ---------------------------------------------------------------------------- 61 62// assignment operators 63inline const sc_signed & 64sc_signed::operator = (const sc_fxval &v) 65{ 66 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 67 SC_REPORT_ERROR("invalid fixed-point value", 68 "sc_signed::operator = ( const sc_fxval& )"); 69 return *this; 70 } 71 for (int i = 0; i < length(); ++i) 72 (*this)[i] = v.get_bit(i); 73 74 return *this; 75} 76 77inline const sc_signed & 78sc_signed::operator = (const sc_fxval_fast &v) 79{ 80 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 81 SC_REPORT_ERROR("invalid fixed-point value", 82 "sc_signed::operator = ( const sc_fxval_fast& )"); 83 return *this; 84 } 85 86 for (int i = 0; i < length(); ++i) 87 (*this)[i] = v.get_bit(i); 88 89 return *this; 90} 91 92inline const sc_signed & 93sc_signed::operator = (const sc_fxnum &v) 94{ 95 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 96 SC_REPORT_ERROR("invalid fixed-point value", 97 "sc_signed::operator = ( const sc_fxnum& )"); 98 return *this; 99 } 100 101 for (int i = 0; i < length(); ++i) 102 (*this)[i] = v.get_bit(i); 103 104 return *this; 105} 106 107inline const sc_signed & 108sc_signed::operator = (const sc_fxnum_fast &v) 109{ 110 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 111 SC_REPORT_ERROR("invalid fixed-point value", 112 "sc_signed::operator = ( const sc_fxnum_fast& )"); 113 return *this; 114 } 115 116 for (int i = 0; i < length(); ++i) 117 (*this)[i] = v.get_bit(i); 118 119 return *this; 120} 121 122 123// ---------------------------------------------------------------------------- 124// CLASS : sc_unsigned 125// ---------------------------------------------------------------------------- 126 127// assignment operators 128 129inline const sc_unsigned & 130sc_unsigned::operator = (const sc_fxval &v) 131{ 132 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 133 SC_REPORT_ERROR("invalid fixed-point value", 134 "sc_unsigned::operator = ( const sc_fxval& )"); 135 return *this; 136 } 137 138 for (int i = 0; i < length(); ++i) 139 (*this)[i] = v.get_bit(i); 140 141 return *this; 142} 143 144inline const sc_unsigned & 145sc_unsigned::operator = (const sc_fxval_fast &v) 146{ 147 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 148 SC_REPORT_ERROR("invalid fixed-point value", 149 "sc_unsigned::operator = ( const sc_fxval_fast& )"); 150 return *this; 151 } 152 153 for (int i = 0; i < length(); ++i) 154 (*this)[i] = v.get_bit(i); 155 156 return *this; 157} 158 159inline const sc_unsigned & 160sc_unsigned::operator = (const sc_fxnum &v) 161{ 162 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 163 SC_REPORT_ERROR("invalid fixed-point value", 164 "sc_unsigned::operator = ( const sc_fxnum& )" ); 165 return *this; 166 } 167 168 for (int i = 0; i < length(); ++i) 169 (*this)[i] = v.get_bit(i); 170 171 return *this; 172} 173 174inline const sc_unsigned & 175sc_unsigned::operator = (const sc_fxnum_fast &v) 176{ 177 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 178 SC_REPORT_ERROR("invalid fixed-point value", 179 "sc_unsigned::operator = ( const sc_fxnum_fast& )" ); 180 return *this; 181 } 182 183 for (int i = 0; i < length(); ++i) 184 (*this)[i] = v.get_bit(i); 185 186 return *this; 187} 188 189 190// ---------------------------------------------------------------------------- 191// CLASS : sc_int_base 192// ---------------------------------------------------------------------------- 193 194// assignment operators 195 196inline sc_int_base & 197sc_int_base::operator = (const sc_fxval &v) 198{ 199 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 200 SC_REPORT_ERROR("invalid fixed-point value", 201 "sc_int_base::operator = ( const sc_fxval& )"); 202 return *this; 203 } 204 for (int i = 0; i < m_len; ++i) { 205 set(i, v.get_bit(i)); 206 } 207 extend_sign(); 208 return *this; 209} 210 211inline sc_int_base & 212sc_int_base::operator = (const sc_fxval_fast &v) 213{ 214 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 215 SC_REPORT_ERROR("invalid fixed-point value", 216 "sc_int_base::operator = ( const sc_fxval_fast& )"); 217 return *this; 218 } 219 for (int i = 0; i < m_len; ++i) { 220 set(i, v.get_bit(i)); 221 } 222 extend_sign(); 223 return *this; 224} 225 226inline sc_int_base & 227sc_int_base::operator = (const sc_fxnum &v) 228{ 229 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 230 SC_REPORT_ERROR("invalid fixed-point value", 231 "sc_int_base::operator = ( const sc_fxnum& )"); 232 return *this; 233 } 234 for (int i = 0; i < m_len; ++i) { 235 set(i, v.get_bit(i)); 236 } 237 extend_sign(); 238 return *this; 239} 240 241inline sc_int_base & 242sc_int_base::operator = (const sc_fxnum_fast &v) 243{ 244 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 245 SC_REPORT_ERROR("invalid fixed-point value", 246 "sc_int_base::operator = ( const sc_fxnum_fast& )"); 247 return *this; 248 } 249 for (int i = 0; i < m_len; ++i) { 250 set (i, v.get_bit(i)); 251 } 252 extend_sign(); 253 return *this; 254} 255 256 257// ---------------------------------------------------------------------------- 258// CLASS : sc_uint_base 259// ---------------------------------------------------------------------------- 260 261// assignment operators 262inline sc_uint_base & 263sc_uint_base::operator = (const sc_fxval &v) 264{ 265 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 266 SC_REPORT_ERROR("invalid fixed-point value", 267 "sc_uint_base::operator = ( const sc_fxval& )"); 268 return *this; 269 } 270 for (int i = 0; i < m_len; ++i) { 271 set(i, v.get_bit(i)); 272 } 273 extend_sign(); 274 return *this; 275} 276 277inline sc_uint_base & 278sc_uint_base::operator = (const sc_fxval_fast &v) 279{ 280 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 281 SC_REPORT_ERROR("invalid fixed-point value", 282 "sc_uint_base::operator = ( const sc_fxval_fast& )"); 283 return *this; 284 } 285 for (int i = 0; i < m_len; ++i) { 286 set(i, v.get_bit(i)); 287 } 288 extend_sign(); 289 return *this; 290} 291 292inline sc_uint_base & 293sc_uint_base::operator = (const sc_fxnum &v) 294{ 295 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 296 SC_REPORT_ERROR("invalid fixed-point value", 297 "sc_uint_base::operator = ( const sc_fxnum& )"); 298 return *this; 299 } 300 for (int i = 0; i < m_len; ++i) { 301 set(i, v.get_bit(i)); 302 } 303 extend_sign(); 304 return *this; 305} 306 307inline sc_uint_base & 308sc_uint_base::operator = (const sc_fxnum_fast &v) 309{ 310 if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 311 SC_REPORT_ERROR("invalid fixed-point value", 312 "sc_uint_base::operator = ( const sc_fxnum_fast& )"); 313 return *this; 314 } 315 for (int i = 0; i < m_len; ++i) { 316 set(i, v.get_bit(i)); 317 } 318 extend_sign(); 319 return *this; 320} 321 322} // namespace sc_dt 323 324#endif // __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__ 325