scfx_other_defs.hh revision 12853
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" 5412853Sgabeblack@google.com 5512853Sgabeblack@google.comnamespace sc_dt 5612853Sgabeblack@google.com{ 5712853Sgabeblack@google.com 5812853Sgabeblack@google.com// ---------------------------------------------------------------------------- 5912853Sgabeblack@google.com// CLASS : sc_signed 6012853Sgabeblack@google.com// ---------------------------------------------------------------------------- 6112853Sgabeblack@google.com 6212853Sgabeblack@google.com// assignment operators 6312853Sgabeblack@google.cominline const sc_signed & 6412853Sgabeblack@google.comsc_signed::operator = (const sc_fxval &v) 6512853Sgabeblack@google.com{ 6612853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 6712853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 6812853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxval& )"); 6912853Sgabeblack@google.com return *this; 7012853Sgabeblack@google.com } 7112853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 7212853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 7312853Sgabeblack@google.com 7412853Sgabeblack@google.com return *this; 7512853Sgabeblack@google.com} 7612853Sgabeblack@google.com 7712853Sgabeblack@google.cominline const sc_signed & 7812853Sgabeblack@google.comsc_signed::operator = (const sc_fxval_fast &v) 7912853Sgabeblack@google.com{ 8012853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 8112853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 8212853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxval_fast& )"); 8312853Sgabeblack@google.com return *this; 8412853Sgabeblack@google.com } 8512853Sgabeblack@google.com 8612853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 8712853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 8812853Sgabeblack@google.com 8912853Sgabeblack@google.com return *this; 9012853Sgabeblack@google.com} 9112853Sgabeblack@google.com 9212853Sgabeblack@google.cominline const sc_signed & 9312853Sgabeblack@google.comsc_signed::operator = (const sc_fxnum &v) 9412853Sgabeblack@google.com{ 9512853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 9612853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 9712853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxnum& )"); 9812853Sgabeblack@google.com return *this; 9912853Sgabeblack@google.com } 10012853Sgabeblack@google.com 10112853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 10212853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 10312853Sgabeblack@google.com 10412853Sgabeblack@google.com return *this; 10512853Sgabeblack@google.com} 10612853Sgabeblack@google.com 10712853Sgabeblack@google.cominline const sc_signed & 10812853Sgabeblack@google.comsc_signed::operator = (const sc_fxnum_fast &v) 10912853Sgabeblack@google.com{ 11012853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 11112853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 11212853Sgabeblack@google.com "sc_signed::operator = ( const sc_fxnum_fast& )"); 11312853Sgabeblack@google.com return *this; 11412853Sgabeblack@google.com } 11512853Sgabeblack@google.com 11612853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 11712853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 11812853Sgabeblack@google.com 11912853Sgabeblack@google.com return *this; 12012853Sgabeblack@google.com} 12112853Sgabeblack@google.com 12212853Sgabeblack@google.com 12312853Sgabeblack@google.com// ---------------------------------------------------------------------------- 12412853Sgabeblack@google.com// CLASS : sc_unsigned 12512853Sgabeblack@google.com// ---------------------------------------------------------------------------- 12612853Sgabeblack@google.com 12712853Sgabeblack@google.com// assignment operators 12812853Sgabeblack@google.com 12912853Sgabeblack@google.cominline const sc_unsigned & 13012853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxval &v) 13112853Sgabeblack@google.com{ 13212853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 13312853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 13412853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxval& )"); 13512853Sgabeblack@google.com return *this; 13612853Sgabeblack@google.com } 13712853Sgabeblack@google.com 13812853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 13912853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 14012853Sgabeblack@google.com 14112853Sgabeblack@google.com return *this; 14212853Sgabeblack@google.com} 14312853Sgabeblack@google.com 14412853Sgabeblack@google.cominline const sc_unsigned & 14512853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxval_fast &v) 14612853Sgabeblack@google.com{ 14712853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 14812853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 14912853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxval_fast& )"); 15012853Sgabeblack@google.com return *this; 15112853Sgabeblack@google.com } 15212853Sgabeblack@google.com 15312853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 15412853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 15512853Sgabeblack@google.com 15612853Sgabeblack@google.com return *this; 15712853Sgabeblack@google.com} 15812853Sgabeblack@google.com 15912853Sgabeblack@google.cominline const sc_unsigned & 16012853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxnum &v) 16112853Sgabeblack@google.com{ 16212853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 16312853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 16412853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxnum& )" ); 16512853Sgabeblack@google.com return *this; 16612853Sgabeblack@google.com } 16712853Sgabeblack@google.com 16812853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 16912853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 17012853Sgabeblack@google.com 17112853Sgabeblack@google.com return *this; 17212853Sgabeblack@google.com} 17312853Sgabeblack@google.com 17412853Sgabeblack@google.cominline const sc_unsigned & 17512853Sgabeblack@google.comsc_unsigned::operator = (const sc_fxnum_fast &v) 17612853Sgabeblack@google.com{ 17712853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 17812853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 17912853Sgabeblack@google.com "sc_unsigned::operator = ( const sc_fxnum_fast& )" ); 18012853Sgabeblack@google.com return *this; 18112853Sgabeblack@google.com } 18212853Sgabeblack@google.com 18312853Sgabeblack@google.com for (int i = 0; i < length(); ++i) 18412853Sgabeblack@google.com (*this)[i] = v.get_bit(i); 18512853Sgabeblack@google.com 18612853Sgabeblack@google.com return *this; 18712853Sgabeblack@google.com} 18812853Sgabeblack@google.com 18912853Sgabeblack@google.com 19012853Sgabeblack@google.com// ---------------------------------------------------------------------------- 19112853Sgabeblack@google.com// CLASS : sc_int_base 19212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 19312853Sgabeblack@google.com 19412853Sgabeblack@google.com// assignment operators 19512853Sgabeblack@google.com 19612853Sgabeblack@google.cominline sc_int_base & 19712853Sgabeblack@google.comsc_int_base::operator = (const sc_fxval &v) 19812853Sgabeblack@google.com{ 19912853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 20012853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 20112853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxval& )"); 20212853Sgabeblack@google.com return *this; 20312853Sgabeblack@google.com } 20412853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 20512853Sgabeblack@google.com set(i, v.get_bit(i)); 20612853Sgabeblack@google.com } 20712853Sgabeblack@google.com extend_sign(); 20812853Sgabeblack@google.com return *this; 20912853Sgabeblack@google.com} 21012853Sgabeblack@google.com 21112853Sgabeblack@google.cominline sc_int_base & 21212853Sgabeblack@google.comsc_int_base::operator = (const sc_fxval_fast &v) 21312853Sgabeblack@google.com{ 21412853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 21512853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 21612853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxval_fast& )"); 21712853Sgabeblack@google.com return *this; 21812853Sgabeblack@google.com } 21912853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 22012853Sgabeblack@google.com set(i, v.get_bit(i)); 22112853Sgabeblack@google.com } 22212853Sgabeblack@google.com extend_sign(); 22312853Sgabeblack@google.com return *this; 22412853Sgabeblack@google.com} 22512853Sgabeblack@google.com 22612853Sgabeblack@google.cominline sc_int_base & 22712853Sgabeblack@google.comsc_int_base::operator = (const sc_fxnum &v) 22812853Sgabeblack@google.com{ 22912853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 23012853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 23112853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxnum& )"); 23212853Sgabeblack@google.com return *this; 23312853Sgabeblack@google.com } 23412853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 23512853Sgabeblack@google.com set(i, v.get_bit(i)); 23612853Sgabeblack@google.com } 23712853Sgabeblack@google.com extend_sign(); 23812853Sgabeblack@google.com return *this; 23912853Sgabeblack@google.com} 24012853Sgabeblack@google.com 24112853Sgabeblack@google.cominline sc_int_base & 24212853Sgabeblack@google.comsc_int_base::operator = (const sc_fxnum_fast &v) 24312853Sgabeblack@google.com{ 24412853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 24512853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 24612853Sgabeblack@google.com "sc_int_base::operator = ( const sc_fxnum_fast& )"); 24712853Sgabeblack@google.com return *this; 24812853Sgabeblack@google.com } 24912853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 25012853Sgabeblack@google.com set (i, v.get_bit(i)); 25112853Sgabeblack@google.com } 25212853Sgabeblack@google.com extend_sign(); 25312853Sgabeblack@google.com return *this; 25412853Sgabeblack@google.com} 25512853Sgabeblack@google.com 25612853Sgabeblack@google.com 25712853Sgabeblack@google.com// ---------------------------------------------------------------------------- 25812853Sgabeblack@google.com// CLASS : sc_uint_base 25912853Sgabeblack@google.com// ---------------------------------------------------------------------------- 26012853Sgabeblack@google.com 26112853Sgabeblack@google.com// assignment operators 26212853Sgabeblack@google.cominline sc_uint_base & 26312853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxval &v) 26412853Sgabeblack@google.com{ 26512853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 26612853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 26712853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxval& )"); 26812853Sgabeblack@google.com return *this; 26912853Sgabeblack@google.com } 27012853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 27112853Sgabeblack@google.com set(i, v.get_bit(i)); 27212853Sgabeblack@google.com } 27312853Sgabeblack@google.com extend_sign(); 27412853Sgabeblack@google.com return *this; 27512853Sgabeblack@google.com} 27612853Sgabeblack@google.com 27712853Sgabeblack@google.cominline sc_uint_base & 27812853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxval_fast &v) 27912853Sgabeblack@google.com{ 28012853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 28112853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 28212853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxval_fast& )"); 28312853Sgabeblack@google.com return *this; 28412853Sgabeblack@google.com } 28512853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 28612853Sgabeblack@google.com set(i, v.get_bit(i)); 28712853Sgabeblack@google.com } 28812853Sgabeblack@google.com extend_sign(); 28912853Sgabeblack@google.com return *this; 29012853Sgabeblack@google.com} 29112853Sgabeblack@google.com 29212853Sgabeblack@google.cominline sc_uint_base & 29312853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxnum &v) 29412853Sgabeblack@google.com{ 29512853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 29612853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 29712853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxnum& )"); 29812853Sgabeblack@google.com return *this; 29912853Sgabeblack@google.com } 30012853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 30112853Sgabeblack@google.com set(i, v.get_bit(i)); 30212853Sgabeblack@google.com } 30312853Sgabeblack@google.com extend_sign(); 30412853Sgabeblack@google.com return *this; 30512853Sgabeblack@google.com} 30612853Sgabeblack@google.com 30712853Sgabeblack@google.cominline sc_uint_base & 30812853Sgabeblack@google.comsc_uint_base::operator = (const sc_fxnum_fast &v) 30912853Sgabeblack@google.com{ 31012853Sgabeblack@google.com if (!v.is_normal()) { /* also triggers OBSERVER_READ call */ 31112853Sgabeblack@google.com SC_REPORT_ERROR("invalid fixed-point value", 31212853Sgabeblack@google.com "sc_uint_base::operator = ( const sc_fxnum_fast& )"); 31312853Sgabeblack@google.com return *this; 31412853Sgabeblack@google.com } 31512853Sgabeblack@google.com for (int i = 0; i < m_len; ++i) { 31612853Sgabeblack@google.com set(i, v.get_bit(i)); 31712853Sgabeblack@google.com } 31812853Sgabeblack@google.com extend_sign(); 31912853Sgabeblack@google.com return *this; 32012853Sgabeblack@google.com} 32112853Sgabeblack@google.com 32212853Sgabeblack@google.com} // namespace sc_dt 32312853Sgabeblack@google.com 32412853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__ 325