scfx_other_defs.hh revision 13325
112853Sgabeblack@google.com/***************************************************************************** 212853Sgabeblack@google.com 312853Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412853Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512853Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612853Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712853Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812853Sgabeblack@google.com License. You may obtain a copy of the License at 912853Sgabeblack@google.com 1012853Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112853Sgabeblack@google.com 1212853Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312853Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412853Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512853Sgabeblack@google.com implied. See the License for the specific language governing 1612853Sgabeblack@google.com permissions and limitations under the License. 1712853Sgabeblack@google.com 1812853Sgabeblack@google.com *****************************************************************************/ 1912853Sgabeblack@google.com 2012853Sgabeblack@google.com/***************************************************************************** 2112853Sgabeblack@google.com 2212853Sgabeblack@google.com scfx_other_defs.h - 2312853Sgabeblack@google.com 2412853Sgabeblack@google.com Original Author: Martin Janssen, Synopsys, Inc. 2512853Sgabeblack@google.com 2612853Sgabeblack@google.com *****************************************************************************/ 2712853Sgabeblack@google.com 2812853Sgabeblack@google.com/***************************************************************************** 2912853Sgabeblack@google.com 3012853Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112853Sgabeblack@google.com changes you are making here. 3212853Sgabeblack@google.com 3312853Sgabeblack@google.com Name, Affiliation, Date: 3412853Sgabeblack@google.com Description of Modification: 3512853Sgabeblack@google.com 3612853Sgabeblack@google.com *****************************************************************************/ 3712853Sgabeblack@google.com 3812853Sgabeblack@google.com// $Log: scfx_other_defs.h,v $ 3912853Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:20:04 acg 4012853Sgabeblack@google.com// SystemC 2.3 4112853Sgabeblack@google.com// 4212853Sgabeblack@google.com// Revision 1.3 2006/01/13 18:53:58 acg 4312853Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in 4412853Sgabeblack@google.com// the source. 4512853Sgabeblack@google.com// 4612853Sgabeblack@google.com 4712853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__ 4812853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__ 4912853Sgabeblack@google.com 5012853Sgabeblack@google.com#include "../int/sc_int_base.hh" 5112853Sgabeblack@google.com#include "../int/sc_signed.hh" 5212853Sgabeblack@google.com#include "../int/sc_uint_base.hh" 5312853Sgabeblack@google.com#include "../int/sc_unsigned.hh" 5413325Sgabeblack@google.com#include "messages.hh" 5512853Sgabeblack@google.com 5612853Sgabeblack@google.comnamespace sc_dt 5712853Sgabeblack@google.com{ 5812853Sgabeblack@google.com 5912853Sgabeblack@google.com// ---------------------------------------------------------------------------- 6012853Sgabeblack@google.com// CLASS : sc_signed 6112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 6212853Sgabeblack@google.com 6312853Sgabeblack@google.com// assignment operators 6412853Sgabeblack@google.cominline const sc_signed & 6512853Sgabeblack@google.comsc_signed::operator = (const sc_fxval &v) 6612853Sgabeblack@google.com{ 6712853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 6813325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 6912853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxval& )"); 7012853Sgabeblack@google.com return *this; 7112853Sgabeblack@google.com } 7212853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 7312853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 7412853Sgabeblack@google.com 7512853Sgabeblack@google.com return *this; 7612853Sgabeblack@google.com} 7712853Sgabeblack@google.com 7812853Sgabeblack@google.cominline const sc_signed & 7912853Sgabeblack@google.comsc_signed::operator = (const sc_fxval_fast &v) 8012853Sgabeblack@google.com{ 8112853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 8213325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 8312853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxval_fast& )"); 8412853Sgabeblack@google.com return *this; 8512853Sgabeblack@google.com } 8612853Sgabeblack@google.com 8712853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 8812853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 8912853Sgabeblack@google.com 9012853Sgabeblack@google.com return *this; 9112853Sgabeblack@google.com} 9212853Sgabeblack@google.com 9312853Sgabeblack@google.cominline const sc_signed & 9412853Sgabeblack@google.comsc_signed::operator = (const sc_fxnum &v) 9512853Sgabeblack@google.com{ 9612853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 9713325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 9812853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxnum& )"); 9912853Sgabeblack@google.com return *this; 10012853Sgabeblack@google.com } 10112853Sgabeblack@google.com 10212853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 10312853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 10412853Sgabeblack@google.com 10512853Sgabeblack@google.com return *this; 10612853Sgabeblack@google.com} 10712853Sgabeblack@google.com 10812853Sgabeblack@google.cominline const sc_signed & 10912853Sgabeblack@google.comsc_signed::operator = (const sc_fxnum_fast &v) 11012853Sgabeblack@google.com{ 11112853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 11213325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 11312853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxnum_fast& )"); 11412853Sgabeblack@google.com return *this; 11512853Sgabeblack@google.com } 11612853Sgabeblack@google.com 11712853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 11812853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 11912853Sgabeblack@google.com 12012853Sgabeblack@google.com return *this; 12112853Sgabeblack@google.com} 12212853Sgabeblack@google.com 12312853Sgabeblack@google.com 12412853Sgabeblack@google.com// ---------------------------------------------------------------------------- 12512853Sgabeblack@google.com// CLASS : sc_unsigned 12612853Sgabeblack@google.com// ---------------------------------------------------------------------------- 12712853Sgabeblack@google.com 12812853Sgabeblack@google.com// assignment operators 12912853Sgabeblack@google.com 13012853Sgabeblack@google.cominline const sc_unsigned & 13112853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxval &v) 13212853Sgabeblack@google.com{ 13312853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 13413325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 13512853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxval& )"); 13612853Sgabeblack@google.com return *this; 13712853Sgabeblack@google.com } 13812853Sgabeblack@google.com 13912853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 14012853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 14112853Sgabeblack@google.com 14212853Sgabeblack@google.com return *this; 14312853Sgabeblack@google.com} 14412853Sgabeblack@google.com 14512853Sgabeblack@google.cominline const sc_unsigned & 14612853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxval_fast &v) 14712853Sgabeblack@google.com{ 14812853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 14913325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 15012853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxval_fast& )"); 15112853Sgabeblack@google.com return *this; 15212853Sgabeblack@google.com } 15312853Sgabeblack@google.com 15412853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 15512853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 15612853Sgabeblack@google.com 15712853Sgabeblack@google.com return *this; 15812853Sgabeblack@google.com} 15912853Sgabeblack@google.com 16012853Sgabeblack@google.cominline const sc_unsigned & 16112853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxnum &v) 16212853Sgabeblack@google.com{ 16312853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 16413325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 16512853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxnum& )" ); 16612853Sgabeblack@google.com return *this; 16712853Sgabeblack@google.com } 16812853Sgabeblack@google.com 16912853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 17012853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 17112853Sgabeblack@google.com 17212853Sgabeblack@google.com return *this; 17312853Sgabeblack@google.com} 17412853Sgabeblack@google.com 17512853Sgabeblack@google.cominline const sc_unsigned & 17612853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxnum_fast &v) 17712853Sgabeblack@google.com{ 17812853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 17913325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 18012853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxnum_fast& )" ); 18112853Sgabeblack@google.com return *this; 18212853Sgabeblack@google.com } 18312853Sgabeblack@google.com 18412853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 18512853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 18612853Sgabeblack@google.com 18712853Sgabeblack@google.com return *this; 18812853Sgabeblack@google.com} 18912853Sgabeblack@google.com 19012853Sgabeblack@google.com 19112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 19212853Sgabeblack@google.com// CLASS : sc_int_base 19312853Sgabeblack@google.com// ---------------------------------------------------------------------------- 19412853Sgabeblack@google.com 19512853Sgabeblack@google.com// assignment operators 19612853Sgabeblack@google.com 19712853Sgabeblack@google.cominline sc_int_base & 19812853Sgabeblack@google.comsc_int_base::operator = (const sc_fxval &v) 19912853Sgabeblack@google.com{ 20012853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 20113325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 20212853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxval& )"); 20312853Sgabeblack@google.com return *this; 20412853Sgabeblack@google.com } 20512853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 20612853Sgabeblack@google.com set(i, v.get_bit(i)); 20712853Sgabeblack@google.com } 20812853Sgabeblack@google.com extend_sign(); 20912853Sgabeblack@google.com return *this; 21012853Sgabeblack@google.com} 21112853Sgabeblack@google.com 21212853Sgabeblack@google.cominline sc_int_base & 21312853Sgabeblack@google.comsc_int_base::operator = (const sc_fxval_fast &v) 21412853Sgabeblack@google.com{ 21512853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 21613325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 21712853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxval_fast& )"); 21812853Sgabeblack@google.com return *this; 21912853Sgabeblack@google.com } 22012853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 22112853Sgabeblack@google.com set(i, v.get_bit(i)); 22212853Sgabeblack@google.com } 22312853Sgabeblack@google.com extend_sign(); 22412853Sgabeblack@google.com return *this; 22512853Sgabeblack@google.com} 22612853Sgabeblack@google.com 22712853Sgabeblack@google.cominline sc_int_base & 22812853Sgabeblack@google.comsc_int_base::operator = (const sc_fxnum &v) 22912853Sgabeblack@google.com{ 23012853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 23113325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 23212853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxnum& )"); 23312853Sgabeblack@google.com return *this; 23412853Sgabeblack@google.com } 23512853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 23612853Sgabeblack@google.com set(i, v.get_bit(i)); 23712853Sgabeblack@google.com } 23812853Sgabeblack@google.com extend_sign(); 23912853Sgabeblack@google.com return *this; 24012853Sgabeblack@google.com} 24112853Sgabeblack@google.com 24212853Sgabeblack@google.cominline sc_int_base & 24312853Sgabeblack@google.comsc_int_base::operator = (const sc_fxnum_fast &v) 24412853Sgabeblack@google.com{ 24512853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 24613325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 24712853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxnum_fast& )"); 24812853Sgabeblack@google.com return *this; 24912853Sgabeblack@google.com } 25012853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 25112853Sgabeblack@google.com set (i, v.get_bit(i)); 25212853Sgabeblack@google.com } 25312853Sgabeblack@google.com extend_sign(); 25412853Sgabeblack@google.com return *this; 25512853Sgabeblack@google.com} 25612853Sgabeblack@google.com 25712853Sgabeblack@google.com 25812853Sgabeblack@google.com// ---------------------------------------------------------------------------- 25912853Sgabeblack@google.com// CLASS : sc_uint_base 26012853Sgabeblack@google.com// ---------------------------------------------------------------------------- 26112853Sgabeblack@google.com 26212853Sgabeblack@google.com// assignment operators 26312853Sgabeblack@google.cominline sc_uint_base & 26412853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxval &v) 26512853Sgabeblack@google.com{ 26612853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 26713325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 26812853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxval& )"); 26912853Sgabeblack@google.com return *this; 27012853Sgabeblack@google.com } 27112853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 27212853Sgabeblack@google.com set(i, v.get_bit(i)); 27312853Sgabeblack@google.com } 27412853Sgabeblack@google.com extend_sign(); 27512853Sgabeblack@google.com return *this; 27612853Sgabeblack@google.com} 27712853Sgabeblack@google.com 27812853Sgabeblack@google.cominline sc_uint_base & 27912853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxval_fast &v) 28012853Sgabeblack@google.com{ 28112853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 28213325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 28312853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxval_fast& )"); 28412853Sgabeblack@google.com return *this; 28512853Sgabeblack@google.com } 28612853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 28712853Sgabeblack@google.com set(i, v.get_bit(i)); 28812853Sgabeblack@google.com } 28912853Sgabeblack@google.com extend_sign(); 29012853Sgabeblack@google.com return *this; 29112853Sgabeblack@google.com} 29212853Sgabeblack@google.com 29312853Sgabeblack@google.cominline sc_uint_base & 29412853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxnum &v) 29512853Sgabeblack@google.com{ 29612853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 29713325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 29812853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxnum& )"); 29912853Sgabeblack@google.com return *this; 30012853Sgabeblack@google.com } 30112853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 30212853Sgabeblack@google.com set(i, v.get_bit(i)); 30312853Sgabeblack@google.com } 30412853Sgabeblack@google.com extend_sign(); 30512853Sgabeblack@google.com return *this; 30612853Sgabeblack@google.com} 30712853Sgabeblack@google.com 30812853Sgabeblack@google.cominline sc_uint_base & 30912853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxnum_fast &v) 31012853Sgabeblack@google.com{ 31112853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 31213325Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_, 31312853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxnum_fast& )"); 31412853Sgabeblack@google.com return *this; 31512853Sgabeblack@google.com } 31612853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 31712853Sgabeblack@google.com set(i, v.get_bit(i)); 31812853Sgabeblack@google.com } 31912853Sgabeblack@google.com extend_sign(); 32012853Sgabeblack@google.com return *this; 32112853Sgabeblack@google.com} 32212853Sgabeblack@google.com 32312853Sgabeblack@google.com} // namespace sc_dt 32412853Sgabeblack@google.com 32512853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__ 326