112027Sjungma@eit.uni-kl.de/***************************************************************************** 212027Sjungma@eit.uni-kl.de 312027Sjungma@eit.uni-kl.de Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412027Sjungma@eit.uni-kl.de more contributor license agreements. See the NOTICE file distributed 512027Sjungma@eit.uni-kl.de with this work for additional information regarding copyright ownership. 612027Sjungma@eit.uni-kl.de Accellera licenses this file to you under the Apache License, Version 2.0 712027Sjungma@eit.uni-kl.de (the "License"); you may not use this file except in compliance with the 812027Sjungma@eit.uni-kl.de License. You may obtain a copy of the License at 912027Sjungma@eit.uni-kl.de 1012027Sjungma@eit.uni-kl.de http://www.apache.org/licenses/LICENSE-2.0 1112027Sjungma@eit.uni-kl.de 1212027Sjungma@eit.uni-kl.de Unless required by applicable law or agreed to in writing, software 1312027Sjungma@eit.uni-kl.de distributed under the License is distributed on an "AS IS" BASIS, 1412027Sjungma@eit.uni-kl.de WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512027Sjungma@eit.uni-kl.de implied. See the License for the specific language governing 1612027Sjungma@eit.uni-kl.de permissions and limitations under the License. 1712027Sjungma@eit.uni-kl.de 1812027Sjungma@eit.uni-kl.de *****************************************************************************/ 1912027Sjungma@eit.uni-kl.de 2012027Sjungma@eit.uni-kl.de/***************************************************************************** 2112027Sjungma@eit.uni-kl.de 2212027Sjungma@eit.uni-kl.de sc_concatref.h -- Concatenation support. 2312027Sjungma@eit.uni-kl.de 2412027Sjungma@eit.uni-kl.de Original Author: Andy Goodrich, Forte Design, Inc. 2512027Sjungma@eit.uni-kl.de 2612027Sjungma@eit.uni-kl.de *****************************************************************************/ 2712027Sjungma@eit.uni-kl.de 2812027Sjungma@eit.uni-kl.de/***************************************************************************** 2912027Sjungma@eit.uni-kl.de 3012027Sjungma@eit.uni-kl.de MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112027Sjungma@eit.uni-kl.de changes you are making here. 3212027Sjungma@eit.uni-kl.de 3312027Sjungma@eit.uni-kl.de Name, Affiliation, Date: 3412027Sjungma@eit.uni-kl.de Description of Modification: 3512027Sjungma@eit.uni-kl.de 3612027Sjungma@eit.uni-kl.de Andy Goodrich, Forte Design Systems, 17 Nov 2002 3712027Sjungma@eit.uni-kl.de Creation of sc_concatref class by merging the capabilities of 3812027Sjungma@eit.uni-kl.de sc_int_concref, sc_int_concref, sc_uint_concref, sc_uint_concref, 3912027Sjungma@eit.uni-kl.de and implementing the capabilities of sc_signed_concref, sc_signed_concref, 4012027Sjungma@eit.uni-kl.de sc_unsigned_concref, and sc_unsigned_concref. The resultant class allows 4112027Sjungma@eit.uni-kl.de mixed mode concatenations on the left and right sides of an assignment. 4212027Sjungma@eit.uni-kl.de 4312027Sjungma@eit.uni-kl.de *****************************************************************************/ 4412027Sjungma@eit.uni-kl.de 4512027Sjungma@eit.uni-kl.de// $Log: sc_concatref.h,v $ 4612027Sjungma@eit.uni-kl.de// Revision 1.6 2011/08/24 22:05:48 acg 4712027Sjungma@eit.uni-kl.de// Torsten Maehne: initialization changes to remove warnings. 4812027Sjungma@eit.uni-kl.de// 4912027Sjungma@eit.uni-kl.de// Revision 1.5 2009/11/17 19:58:15 acg 5012027Sjungma@eit.uni-kl.de// Andy Goodrich: fix of shift rhs possibilities to include "int". 5112027Sjungma@eit.uni-kl.de// 5212027Sjungma@eit.uni-kl.de// Revision 1.4 2009/02/28 00:26:29 acg 5312027Sjungma@eit.uni-kl.de// Andy Goodrich: bug fixes. 5412027Sjungma@eit.uni-kl.de// 5512027Sjungma@eit.uni-kl.de// Revision 1.3 2008/04/29 20:23:55 acg 5612027Sjungma@eit.uni-kl.de// Andy Goodrich: fixed the code that assigns the value of a string to 5712027Sjungma@eit.uni-kl.de// an sc_concatref instance. 5812027Sjungma@eit.uni-kl.de// 5912027Sjungma@eit.uni-kl.de// Revision 1.2 2008/02/14 20:57:26 acg 6012027Sjungma@eit.uni-kl.de// Andy Goodrich: added casts to ~0 instances to keep MSVC compiler happy. 6112027Sjungma@eit.uni-kl.de// 6212027Sjungma@eit.uni-kl.de// Revision 1.1.1.1 2006/12/15 20:20:05 acg 6312027Sjungma@eit.uni-kl.de// SystemC 2.3 6412027Sjungma@eit.uni-kl.de// 6512027Sjungma@eit.uni-kl.de// Revision 1.4 2006/10/23 19:36:59 acg 6612027Sjungma@eit.uni-kl.de// Andy Goodrich: changed casts for operations on concatenation values to 6712027Sjungma@eit.uni-kl.de// mirror those of sc_unsigned. For instance, an sc_unsigned minus a value 6812027Sjungma@eit.uni-kl.de// returns an sc_signed result, whereas an sc_concatref minus a value was 6912027Sjungma@eit.uni-kl.de// returning an sc_unsigned result. Now both sc_unsigned and sc_concatref 7012027Sjungma@eit.uni-kl.de// minus a value return an sc_signed result. 7112027Sjungma@eit.uni-kl.de// 7212027Sjungma@eit.uni-kl.de// Revision 1.3 2006/01/13 18:54:01 acg 7312027Sjungma@eit.uni-kl.de// Andy Goodrich: added $Log command so that CVS comments are reproduced in 7412027Sjungma@eit.uni-kl.de// the source. 7512027Sjungma@eit.uni-kl.de// 7612027Sjungma@eit.uni-kl.de 7712027Sjungma@eit.uni-kl.de#ifndef SC_CONCATREF_H 7812027Sjungma@eit.uni-kl.de#define SC_CONCATREF_H 7912027Sjungma@eit.uni-kl.de 8012027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_object.h" 8112027Sjungma@eit.uni-kl.de#include "sysc/datatypes/misc/sc_value_base.h" 8212027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_temporary.h" 8312027Sjungma@eit.uni-kl.de#include "sysc/datatypes/bit/sc_bv.h" 8412027Sjungma@eit.uni-kl.de#include "sysc/datatypes/bit/sc_lv.h" 8512027Sjungma@eit.uni-kl.de#include "sysc/datatypes/int/sc_int_base.h" 8612027Sjungma@eit.uni-kl.de#include "sysc/datatypes/int/sc_uint_base.h" 8712027Sjungma@eit.uni-kl.de#include "sysc/datatypes/int/sc_signed.h" 8812027Sjungma@eit.uni-kl.de#include "sysc/datatypes/int/sc_unsigned.h" 8912027Sjungma@eit.uni-kl.de 9012027Sjungma@eit.uni-kl.denamespace sc_core { 9112027Sjungma@eit.uni-kl.de extern sc_byte_heap sc_temp_heap; // Temporary storage. 9212027Sjungma@eit.uni-kl.de} // namespace sc_core 9312027Sjungma@eit.uni-kl.de 9412027Sjungma@eit.uni-kl.denamespace sc_dt 9512027Sjungma@eit.uni-kl.de{ 9612027Sjungma@eit.uni-kl.de 9712027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 9812027Sjungma@eit.uni-kl.de// CLASS TEMPLATE : sc_concatref 9912027Sjungma@eit.uni-kl.de// 10012027Sjungma@eit.uni-kl.de// Proxy class for sized bit concatenation. 10112027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 10212027Sjungma@eit.uni-kl.de 10312027Sjungma@eit.uni-kl.declass sc_concatref : public sc_generic_base<sc_concatref>, public sc_value_base 10412027Sjungma@eit.uni-kl.de{ 10512027Sjungma@eit.uni-kl.depublic: 10612027Sjungma@eit.uni-kl.de friend class sc_core::sc_vpool<sc_concatref>; 10712027Sjungma@eit.uni-kl.de 10812027Sjungma@eit.uni-kl.de inline void initialize( 10912027Sjungma@eit.uni-kl.de sc_value_base& left, sc_value_base& right ) 11012027Sjungma@eit.uni-kl.de { 11112027Sjungma@eit.uni-kl.de bool left_xz; // True if x's and/or z's found in left. 11212027Sjungma@eit.uni-kl.de bool right_xz; // True if x's and/or z's found in right. 11312027Sjungma@eit.uni-kl.de 11412027Sjungma@eit.uni-kl.de m_left_p = (sc_value_base*)&left; 11512027Sjungma@eit.uni-kl.de m_right_p = (sc_value_base*)&right; 11612027Sjungma@eit.uni-kl.de m_len_r = right.concat_length(&right_xz); 11712027Sjungma@eit.uni-kl.de m_len = left.concat_length(&left_xz) + m_len_r; 11812027Sjungma@eit.uni-kl.de m_flags = ( left_xz || right_xz ) ? cf_xz_present : cf_none; 11912027Sjungma@eit.uni-kl.de } 12012027Sjungma@eit.uni-kl.de 12112027Sjungma@eit.uni-kl.de 12212027Sjungma@eit.uni-kl.de inline void initialize( 12312027Sjungma@eit.uni-kl.de const sc_value_base& left, const sc_value_base& right ) 12412027Sjungma@eit.uni-kl.de { 12512027Sjungma@eit.uni-kl.de bool left_xz; // True if x's and/or z's found in left. 12612027Sjungma@eit.uni-kl.de bool right_xz; // True if x's and/or z's found in right. 12712027Sjungma@eit.uni-kl.de 12812027Sjungma@eit.uni-kl.de m_left_p = (sc_value_base*)&left; 12912027Sjungma@eit.uni-kl.de m_right_p = (sc_value_base*)&right; 13012027Sjungma@eit.uni-kl.de m_len_r = right.concat_length(&right_xz); 13112027Sjungma@eit.uni-kl.de m_len = left.concat_length(&left_xz) + m_len_r; 13212027Sjungma@eit.uni-kl.de m_flags = ( left_xz || right_xz ) ? cf_xz_present : cf_none; 13312027Sjungma@eit.uni-kl.de } 13412027Sjungma@eit.uni-kl.de 13512027Sjungma@eit.uni-kl.de // destructor 13612027Sjungma@eit.uni-kl.de 13712027Sjungma@eit.uni-kl.de virtual ~sc_concatref() 13812027Sjungma@eit.uni-kl.de {} 13912027Sjungma@eit.uni-kl.de 14012027Sjungma@eit.uni-kl.de 14112027Sjungma@eit.uni-kl.de // capacity 14212027Sjungma@eit.uni-kl.de 14312027Sjungma@eit.uni-kl.de unsigned int length() const 14412027Sjungma@eit.uni-kl.de { return m_len; } 14512027Sjungma@eit.uni-kl.de 14612027Sjungma@eit.uni-kl.de#ifdef SC_DT_DEPRECATED 14712027Sjungma@eit.uni-kl.de int bitwidth() const 14812027Sjungma@eit.uni-kl.de { return length(); } 14912027Sjungma@eit.uni-kl.de#endif 15012027Sjungma@eit.uni-kl.de 15112027Sjungma@eit.uni-kl.de // concatenation 15212027Sjungma@eit.uni-kl.de 15312027Sjungma@eit.uni-kl.de virtual int concat_length( bool* xz_present_p ) const 15412027Sjungma@eit.uni-kl.de { 15512027Sjungma@eit.uni-kl.de if ( xz_present_p ) 15612027Sjungma@eit.uni-kl.de *xz_present_p = m_flags & cf_xz_present ? true : false; 15712027Sjungma@eit.uni-kl.de return m_len; 15812027Sjungma@eit.uni-kl.de } 15912027Sjungma@eit.uni-kl.de 16012027Sjungma@eit.uni-kl.de virtual void concat_clear_data( bool to_ones ) 16112027Sjungma@eit.uni-kl.de { 16212027Sjungma@eit.uni-kl.de m_left_p->concat_clear_data(to_ones); 16312027Sjungma@eit.uni-kl.de m_right_p->concat_clear_data(to_ones); 16412027Sjungma@eit.uni-kl.de } 16512027Sjungma@eit.uni-kl.de 16612027Sjungma@eit.uni-kl.de virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const 16712027Sjungma@eit.uni-kl.de { 16812027Sjungma@eit.uni-kl.de bool rnz = m_right_p->concat_get_ctrl( dst_p, low_i ); 16912027Sjungma@eit.uni-kl.de bool lnz = m_left_p->concat_get_ctrl( dst_p, low_i+m_len_r ); 17012027Sjungma@eit.uni-kl.de return rnz || lnz; 17112027Sjungma@eit.uni-kl.de } 17212027Sjungma@eit.uni-kl.de 17312027Sjungma@eit.uni-kl.de virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const 17412027Sjungma@eit.uni-kl.de { 17512027Sjungma@eit.uni-kl.de bool rnz = m_right_p->concat_get_data( dst_p, low_i ); 17612027Sjungma@eit.uni-kl.de bool lnz = m_left_p->concat_get_data( dst_p, low_i+m_len_r ); 17712027Sjungma@eit.uni-kl.de return rnz || lnz; 17812027Sjungma@eit.uni-kl.de } 17912027Sjungma@eit.uni-kl.de 18012027Sjungma@eit.uni-kl.de virtual uint64 concat_get_uint64() const 18112027Sjungma@eit.uni-kl.de { 18212027Sjungma@eit.uni-kl.de if ( m_len_r >= 64 ) 18312027Sjungma@eit.uni-kl.de return m_right_p->concat_get_uint64(); 18412027Sjungma@eit.uni-kl.de else 18512027Sjungma@eit.uni-kl.de { 18612027Sjungma@eit.uni-kl.de return (m_left_p->concat_get_uint64() << m_len_r) | 18712027Sjungma@eit.uni-kl.de m_right_p->concat_get_uint64(); 18812027Sjungma@eit.uni-kl.de } 18912027Sjungma@eit.uni-kl.de } 19012027Sjungma@eit.uni-kl.de 19112027Sjungma@eit.uni-kl.de virtual void concat_set( int64 src, int low_i ) 19212027Sjungma@eit.uni-kl.de { 19312027Sjungma@eit.uni-kl.de m_right_p->concat_set( src, low_i ); 19412027Sjungma@eit.uni-kl.de m_left_p->concat_set( src, low_i+m_len_r); 19512027Sjungma@eit.uni-kl.de } 19612027Sjungma@eit.uni-kl.de 19712027Sjungma@eit.uni-kl.de virtual void concat_set( const sc_signed& src, int low_i ) 19812027Sjungma@eit.uni-kl.de { 19912027Sjungma@eit.uni-kl.de m_right_p->concat_set( src, low_i ); 20012027Sjungma@eit.uni-kl.de m_left_p->concat_set( src, low_i+m_len_r); 20112027Sjungma@eit.uni-kl.de } 20212027Sjungma@eit.uni-kl.de 20312027Sjungma@eit.uni-kl.de virtual void concat_set( const sc_unsigned& src, int low_i ) 20412027Sjungma@eit.uni-kl.de { 20512027Sjungma@eit.uni-kl.de m_right_p->concat_set( src, low_i ); 20612027Sjungma@eit.uni-kl.de m_left_p->concat_set( src, low_i+m_len_r); 20712027Sjungma@eit.uni-kl.de } 20812027Sjungma@eit.uni-kl.de 20912027Sjungma@eit.uni-kl.de virtual void concat_set( uint64 src, int low_i ) 21012027Sjungma@eit.uni-kl.de { 21112027Sjungma@eit.uni-kl.de m_right_p->concat_set( src, low_i ); 21212027Sjungma@eit.uni-kl.de m_left_p->concat_set( src, low_i+m_len_r); 21312027Sjungma@eit.uni-kl.de } 21412027Sjungma@eit.uni-kl.de 21512027Sjungma@eit.uni-kl.de 21612027Sjungma@eit.uni-kl.de // explicit conversions 21712027Sjungma@eit.uni-kl.de 21812027Sjungma@eit.uni-kl.de uint64 to_uint64() const 21912027Sjungma@eit.uni-kl.de { 22012027Sjungma@eit.uni-kl.de uint64 mask; 22112027Sjungma@eit.uni-kl.de uint64 result; 22212027Sjungma@eit.uni-kl.de 22312027Sjungma@eit.uni-kl.de result = m_right_p->concat_get_uint64(); 22412027Sjungma@eit.uni-kl.de if ( m_len_r < 64 ) 22512027Sjungma@eit.uni-kl.de { 22612027Sjungma@eit.uni-kl.de mask = (uint64)~0; 22712027Sjungma@eit.uni-kl.de result = (m_left_p->concat_get_uint64() << m_len_r) | 22812027Sjungma@eit.uni-kl.de (result & ~(mask << m_len_r)); 22912027Sjungma@eit.uni-kl.de } 23012027Sjungma@eit.uni-kl.de if ( m_len < 64 ) 23112027Sjungma@eit.uni-kl.de { 23212027Sjungma@eit.uni-kl.de mask = (uint64)~0; 23312027Sjungma@eit.uni-kl.de result = result & ~(mask << m_len); 23412027Sjungma@eit.uni-kl.de } 23512027Sjungma@eit.uni-kl.de return result; 23612027Sjungma@eit.uni-kl.de } 23712027Sjungma@eit.uni-kl.de 23812027Sjungma@eit.uni-kl.de const sc_unsigned& value() const 23912027Sjungma@eit.uni-kl.de { 24012027Sjungma@eit.uni-kl.de bool left_non_zero; 24112027Sjungma@eit.uni-kl.de sc_unsigned* result_p = sc_unsigned::m_pool.allocate(); 24212027Sjungma@eit.uni-kl.de bool right_non_zero; 24312027Sjungma@eit.uni-kl.de 24412027Sjungma@eit.uni-kl.de result_p->nbits = result_p->num_bits(m_len); 24512027Sjungma@eit.uni-kl.de result_p->ndigits = DIV_CEIL(result_p->nbits); 24612027Sjungma@eit.uni-kl.de result_p->digit = (sc_digit*)sc_core::sc_temp_heap.allocate( 24712027Sjungma@eit.uni-kl.de sizeof(sc_digit)*result_p->ndigits ); 24812027Sjungma@eit.uni-kl.de#if defined(_MSC_VER) 24912027Sjungma@eit.uni-kl.de // workaround spurious initialisation issue on MS Visual C++ 25012027Sjungma@eit.uni-kl.de memset( result_p->digit, 0, sizeof(sc_digit)*result_p->ndigits ); 25112027Sjungma@eit.uni-kl.de#else 25212027Sjungma@eit.uni-kl.de result_p->digit[result_p->ndigits-1] = 0; 25312027Sjungma@eit.uni-kl.de#endif 25412027Sjungma@eit.uni-kl.de right_non_zero = m_right_p->concat_get_data( result_p->digit, 0 ); 25512027Sjungma@eit.uni-kl.de left_non_zero = m_left_p->concat_get_data(result_p->digit, m_len_r); 25612027Sjungma@eit.uni-kl.de if ( left_non_zero || right_non_zero ) 25712027Sjungma@eit.uni-kl.de result_p->sgn = SC_POS; 25812027Sjungma@eit.uni-kl.de else 25912027Sjungma@eit.uni-kl.de result_p->sgn = SC_ZERO; 26012027Sjungma@eit.uni-kl.de return *result_p; 26112027Sjungma@eit.uni-kl.de } 26212027Sjungma@eit.uni-kl.de 26312027Sjungma@eit.uni-kl.de int64 to_int64() const 26412027Sjungma@eit.uni-kl.de { 26512027Sjungma@eit.uni-kl.de return (int64)to_uint64(); 26612027Sjungma@eit.uni-kl.de } 26712027Sjungma@eit.uni-kl.de int to_int() const 26812027Sjungma@eit.uni-kl.de { return (int)to_int64(); } 26912027Sjungma@eit.uni-kl.de unsigned int to_uint() const 27012027Sjungma@eit.uni-kl.de { return (unsigned int)to_uint64(); } 27112027Sjungma@eit.uni-kl.de long to_long() const 27212027Sjungma@eit.uni-kl.de { return (long)to_int64(); } 27312027Sjungma@eit.uni-kl.de unsigned long to_ulong() const 27412027Sjungma@eit.uni-kl.de { return (unsigned long)to_uint64(); } 27512027Sjungma@eit.uni-kl.de double to_double() const 27612027Sjungma@eit.uni-kl.de { return value().to_double(); } 27712027Sjungma@eit.uni-kl.de 27812027Sjungma@eit.uni-kl.de void to_sc_signed( sc_signed& target ) const 27912027Sjungma@eit.uni-kl.de { target = value(); } 28012027Sjungma@eit.uni-kl.de 28112027Sjungma@eit.uni-kl.de void to_sc_unsigned( sc_unsigned& target ) const 28212027Sjungma@eit.uni-kl.de { target = value(); } 28312027Sjungma@eit.uni-kl.de 28412027Sjungma@eit.uni-kl.de // implicit conversions: 28512027Sjungma@eit.uni-kl.de 28612027Sjungma@eit.uni-kl.de operator uint64 () const 28712027Sjungma@eit.uni-kl.de { return to_uint64(); } 28812027Sjungma@eit.uni-kl.de 28912027Sjungma@eit.uni-kl.de operator const sc_unsigned& () const 29012027Sjungma@eit.uni-kl.de { return value(); } 29112027Sjungma@eit.uni-kl.de 29212027Sjungma@eit.uni-kl.de // unary operators: 29312027Sjungma@eit.uni-kl.de 29412027Sjungma@eit.uni-kl.de sc_unsigned operator + () const 29512027Sjungma@eit.uni-kl.de { return value(); } 29612027Sjungma@eit.uni-kl.de 29712027Sjungma@eit.uni-kl.de sc_signed operator - () const 29812027Sjungma@eit.uni-kl.de { return -value(); } 29912027Sjungma@eit.uni-kl.de 30012027Sjungma@eit.uni-kl.de sc_unsigned operator ~ () const 30112027Sjungma@eit.uni-kl.de { return ~value(); } 30212027Sjungma@eit.uni-kl.de 30312027Sjungma@eit.uni-kl.de // explicit conversion to character string 30412027Sjungma@eit.uni-kl.de 30512027Sjungma@eit.uni-kl.de const std::string to_string( sc_numrep numrep = SC_DEC ) const 30612027Sjungma@eit.uni-kl.de { return value().to_string(numrep); } 30712027Sjungma@eit.uni-kl.de 30812027Sjungma@eit.uni-kl.de const std::string to_string( sc_numrep numrep, bool w_prefix ) const 30912027Sjungma@eit.uni-kl.de { return value().to_string(numrep,w_prefix); } 31012027Sjungma@eit.uni-kl.de 31112027Sjungma@eit.uni-kl.de 31212027Sjungma@eit.uni-kl.de 31312027Sjungma@eit.uni-kl.de // assignments 31412027Sjungma@eit.uni-kl.de 31512027Sjungma@eit.uni-kl.de inline const sc_concatref& operator = ( int v ) 31612027Sjungma@eit.uni-kl.de { 31712027Sjungma@eit.uni-kl.de m_right_p->concat_set((int64)v, 0); 31812027Sjungma@eit.uni-kl.de m_left_p->concat_set((int64)v, m_len_r); 31912027Sjungma@eit.uni-kl.de return *this; 32012027Sjungma@eit.uni-kl.de } 32112027Sjungma@eit.uni-kl.de 32212027Sjungma@eit.uni-kl.de inline const sc_concatref& operator = ( long v ) 32312027Sjungma@eit.uni-kl.de { 32412027Sjungma@eit.uni-kl.de m_right_p->concat_set((int64)v, 0); 32512027Sjungma@eit.uni-kl.de m_left_p->concat_set((int64)v, m_len_r); 32612027Sjungma@eit.uni-kl.de return *this; 32712027Sjungma@eit.uni-kl.de } 32812027Sjungma@eit.uni-kl.de 32912027Sjungma@eit.uni-kl.de inline const sc_concatref& operator = ( int64 v ) 33012027Sjungma@eit.uni-kl.de { 33112027Sjungma@eit.uni-kl.de m_right_p->concat_set(v, 0); 33212027Sjungma@eit.uni-kl.de m_left_p->concat_set(v, m_len_r); 33312027Sjungma@eit.uni-kl.de return *this; 33412027Sjungma@eit.uni-kl.de } 33512027Sjungma@eit.uni-kl.de 33612027Sjungma@eit.uni-kl.de inline const sc_concatref& operator = ( unsigned int v ) 33712027Sjungma@eit.uni-kl.de { 33812027Sjungma@eit.uni-kl.de m_right_p->concat_set((uint64)v, 0); 33912027Sjungma@eit.uni-kl.de m_left_p->concat_set((uint64)v, m_len_r); 34012027Sjungma@eit.uni-kl.de return *this; 34112027Sjungma@eit.uni-kl.de } 34212027Sjungma@eit.uni-kl.de 34312027Sjungma@eit.uni-kl.de inline const sc_concatref& operator = ( unsigned long v ) 34412027Sjungma@eit.uni-kl.de { 34512027Sjungma@eit.uni-kl.de m_right_p->concat_set((uint64)v, 0); 34612027Sjungma@eit.uni-kl.de m_left_p->concat_set((uint64)v, m_len_r); 34712027Sjungma@eit.uni-kl.de return *this; 34812027Sjungma@eit.uni-kl.de } 34912027Sjungma@eit.uni-kl.de 35012027Sjungma@eit.uni-kl.de inline const sc_concatref& operator = ( uint64 v ) 35112027Sjungma@eit.uni-kl.de { 35212027Sjungma@eit.uni-kl.de m_right_p->concat_set(v, 0); 35312027Sjungma@eit.uni-kl.de m_left_p->concat_set(v, m_len_r); 35412027Sjungma@eit.uni-kl.de return *this; 35512027Sjungma@eit.uni-kl.de } 35612027Sjungma@eit.uni-kl.de 35712027Sjungma@eit.uni-kl.de const sc_concatref& operator = ( const sc_concatref& v ) 35812027Sjungma@eit.uni-kl.de { 35912027Sjungma@eit.uni-kl.de sc_unsigned temp(v.length()); 36012027Sjungma@eit.uni-kl.de temp = v.value(); 36112027Sjungma@eit.uni-kl.de m_right_p->concat_set(temp, 0); 36212027Sjungma@eit.uni-kl.de m_left_p->concat_set(temp, m_len_r); 36312027Sjungma@eit.uni-kl.de return *this; 36412027Sjungma@eit.uni-kl.de } 36512027Sjungma@eit.uni-kl.de 36612027Sjungma@eit.uni-kl.de const sc_concatref& operator = ( const sc_signed& v ) 36712027Sjungma@eit.uni-kl.de { 36812027Sjungma@eit.uni-kl.de m_right_p->concat_set(v, 0); 36912027Sjungma@eit.uni-kl.de m_left_p->concat_set(v, m_len_r); 37012027Sjungma@eit.uni-kl.de return *this; 37112027Sjungma@eit.uni-kl.de } 37212027Sjungma@eit.uni-kl.de 37312027Sjungma@eit.uni-kl.de const sc_concatref& operator = ( const sc_unsigned& v ) 37412027Sjungma@eit.uni-kl.de { 37512027Sjungma@eit.uni-kl.de m_right_p->concat_set(v, 0); 37612027Sjungma@eit.uni-kl.de m_left_p->concat_set(v, m_len_r); 37712027Sjungma@eit.uni-kl.de return *this; 37812027Sjungma@eit.uni-kl.de } 37912027Sjungma@eit.uni-kl.de 38012027Sjungma@eit.uni-kl.de const sc_concatref& operator = ( const char* v_p ) 38112027Sjungma@eit.uni-kl.de { 38212027Sjungma@eit.uni-kl.de sc_unsigned v(m_len); 38312027Sjungma@eit.uni-kl.de v = v_p; 38412027Sjungma@eit.uni-kl.de m_right_p->concat_set(v, 0); 38512027Sjungma@eit.uni-kl.de m_left_p->concat_set(v, m_len_r); 38612027Sjungma@eit.uni-kl.de return *this; 38712027Sjungma@eit.uni-kl.de } 38812027Sjungma@eit.uni-kl.de 38912027Sjungma@eit.uni-kl.de const sc_concatref& operator = ( const sc_bv_base& v ) 39012027Sjungma@eit.uni-kl.de { 39112027Sjungma@eit.uni-kl.de sc_unsigned temp(v.length()); 39212027Sjungma@eit.uni-kl.de temp = v; 39312027Sjungma@eit.uni-kl.de m_right_p->concat_set(temp, 0); 39412027Sjungma@eit.uni-kl.de m_left_p->concat_set(temp, m_len_r); 39512027Sjungma@eit.uni-kl.de return *this; 39612027Sjungma@eit.uni-kl.de } 39712027Sjungma@eit.uni-kl.de 39812027Sjungma@eit.uni-kl.de const sc_concatref& operator = ( const sc_lv_base& v ) 39912027Sjungma@eit.uni-kl.de { 40012027Sjungma@eit.uni-kl.de sc_unsigned data(v.length()); 40112027Sjungma@eit.uni-kl.de data = v; 40212027Sjungma@eit.uni-kl.de m_right_p->concat_set(data, 0); 40312027Sjungma@eit.uni-kl.de m_left_p->concat_set(data, m_len_r); 40412027Sjungma@eit.uni-kl.de return *this; 40512027Sjungma@eit.uni-kl.de } 40612027Sjungma@eit.uni-kl.de 40712027Sjungma@eit.uni-kl.de 40812027Sjungma@eit.uni-kl.de // reduce methods 40912027Sjungma@eit.uni-kl.de 41012027Sjungma@eit.uni-kl.de bool and_reduce() const 41112027Sjungma@eit.uni-kl.de { return value().and_reduce(); } 41212027Sjungma@eit.uni-kl.de 41312027Sjungma@eit.uni-kl.de bool nand_reduce() const 41412027Sjungma@eit.uni-kl.de { return value().nand_reduce(); } 41512027Sjungma@eit.uni-kl.de 41612027Sjungma@eit.uni-kl.de bool or_reduce() const 41712027Sjungma@eit.uni-kl.de { return value().or_reduce(); } 41812027Sjungma@eit.uni-kl.de 41912027Sjungma@eit.uni-kl.de bool nor_reduce() const 42012027Sjungma@eit.uni-kl.de { return value().nor_reduce(); } 42112027Sjungma@eit.uni-kl.de 42212027Sjungma@eit.uni-kl.de bool xor_reduce() const 42312027Sjungma@eit.uni-kl.de { return value().xor_reduce(); } 42412027Sjungma@eit.uni-kl.de 42512027Sjungma@eit.uni-kl.de bool xnor_reduce() const 42612027Sjungma@eit.uni-kl.de { return value().xnor_reduce(); } 42712027Sjungma@eit.uni-kl.de 42812027Sjungma@eit.uni-kl.de // other methods 42912027Sjungma@eit.uni-kl.de 43012027Sjungma@eit.uni-kl.de void print( ::std::ostream& os = ::std::cout ) const 43112027Sjungma@eit.uni-kl.de { os << this->value(); } 43212027Sjungma@eit.uni-kl.de 43312027Sjungma@eit.uni-kl.de void scan( ::std::istream& is ) 43412027Sjungma@eit.uni-kl.de { 43512027Sjungma@eit.uni-kl.de std::string s; 43612027Sjungma@eit.uni-kl.de is >> s; 43712027Sjungma@eit.uni-kl.de *this = s.c_str(); 43812027Sjungma@eit.uni-kl.de } 43912027Sjungma@eit.uni-kl.de 44012027Sjungma@eit.uni-kl.depublic: 44112027Sjungma@eit.uni-kl.de static sc_core::sc_vpool<sc_concatref> m_pool; // Pool of temporary objects. 44212027Sjungma@eit.uni-kl.de 44312027Sjungma@eit.uni-kl.depublic: 44412027Sjungma@eit.uni-kl.de enum concat_flags { 44512027Sjungma@eit.uni-kl.de cf_none = 0, // Normal value. 44612027Sjungma@eit.uni-kl.de cf_xz_present = 1 // X and/or Z values present. 44712027Sjungma@eit.uni-kl.de }; 44812027Sjungma@eit.uni-kl.de 44912027Sjungma@eit.uni-kl.deprotected: 45012027Sjungma@eit.uni-kl.de sc_value_base* m_left_p; // Left hand operand of concatenation. 45112027Sjungma@eit.uni-kl.de sc_value_base* m_right_p; // Right hand operand of concatenation. 45212027Sjungma@eit.uni-kl.de int m_len; // Length of concatenation. 45312027Sjungma@eit.uni-kl.de int m_len_r; // Length of m_rightt_p. 45412027Sjungma@eit.uni-kl.de concat_flags m_flags; // Value is read only. 45512027Sjungma@eit.uni-kl.de 45612027Sjungma@eit.uni-kl.deprivate: 45712027Sjungma@eit.uni-kl.de sc_concatref(const sc_concatref&); 45812027Sjungma@eit.uni-kl.de sc_concatref() : m_left_p(0), m_right_p(0), m_len(0), m_len_r(0), m_flags() 45912027Sjungma@eit.uni-kl.de {} 46012027Sjungma@eit.uni-kl.de}; 46112027Sjungma@eit.uni-kl.de 46212027Sjungma@eit.uni-kl.de 46312027Sjungma@eit.uni-kl.de// functional notation for the reduce methods 46412027Sjungma@eit.uni-kl.de 46512027Sjungma@eit.uni-kl.deinline 46612027Sjungma@eit.uni-kl.debool 46712027Sjungma@eit.uni-kl.deand_reduce( const sc_concatref& a ) 46812027Sjungma@eit.uni-kl.de{ 46912027Sjungma@eit.uni-kl.de return a.and_reduce(); 47012027Sjungma@eit.uni-kl.de} 47112027Sjungma@eit.uni-kl.de 47212027Sjungma@eit.uni-kl.deinline 47312027Sjungma@eit.uni-kl.debool 47412027Sjungma@eit.uni-kl.denand_reduce( const sc_concatref& a ) 47512027Sjungma@eit.uni-kl.de{ 47612027Sjungma@eit.uni-kl.de return a.nand_reduce(); 47712027Sjungma@eit.uni-kl.de} 47812027Sjungma@eit.uni-kl.de 47912027Sjungma@eit.uni-kl.deinline 48012027Sjungma@eit.uni-kl.debool 48112027Sjungma@eit.uni-kl.deor_reduce( const sc_concatref& a ) 48212027Sjungma@eit.uni-kl.de{ 48312027Sjungma@eit.uni-kl.de return a.or_reduce(); 48412027Sjungma@eit.uni-kl.de} 48512027Sjungma@eit.uni-kl.de 48612027Sjungma@eit.uni-kl.deinline 48712027Sjungma@eit.uni-kl.debool 48812027Sjungma@eit.uni-kl.denor_reduce( const sc_concatref& a ) 48912027Sjungma@eit.uni-kl.de{ 49012027Sjungma@eit.uni-kl.de return a.nor_reduce(); 49112027Sjungma@eit.uni-kl.de} 49212027Sjungma@eit.uni-kl.de 49312027Sjungma@eit.uni-kl.deinline 49412027Sjungma@eit.uni-kl.debool 49512027Sjungma@eit.uni-kl.dexor_reduce( const sc_concatref& a ) 49612027Sjungma@eit.uni-kl.de{ 49712027Sjungma@eit.uni-kl.de return a.xor_reduce(); 49812027Sjungma@eit.uni-kl.de} 49912027Sjungma@eit.uni-kl.de 50012027Sjungma@eit.uni-kl.deinline 50112027Sjungma@eit.uni-kl.debool 50212027Sjungma@eit.uni-kl.dexnor_reduce( const sc_concatref& a ) 50312027Sjungma@eit.uni-kl.de{ 50412027Sjungma@eit.uni-kl.de return a.xnor_reduce(); 50512027Sjungma@eit.uni-kl.de} 50612027Sjungma@eit.uni-kl.de 50712027Sjungma@eit.uni-kl.de 50812027Sjungma@eit.uni-kl.de// SHIFT OPERATORS FOR sc_concatref OBJECT INSTANCES: 50912027Sjungma@eit.uni-kl.de// 51012027Sjungma@eit.uni-kl.de// Because sc_concatref has implicit casts to both uint64 and sc_unsigned 51112027Sjungma@eit.uni-kl.de// it is necessary to disambiguate the use of the shift operators. We do 51212027Sjungma@eit.uni-kl.de// this in favor of sc_unsigned so that precision is not lost. To get an 51312027Sjungma@eit.uni-kl.de// integer-based result use a cast to uint64 before performing the shift. 51412027Sjungma@eit.uni-kl.de 51512027Sjungma@eit.uni-kl.deinline const sc_unsigned operator << (const sc_concatref& target, uint64 shift) 51612027Sjungma@eit.uni-kl.de{ 51712027Sjungma@eit.uni-kl.de return target.value() << (int)shift; 51812027Sjungma@eit.uni-kl.de} 51912027Sjungma@eit.uni-kl.de 52012027Sjungma@eit.uni-kl.deinline const sc_unsigned operator << (const sc_concatref& target, int64 shift) 52112027Sjungma@eit.uni-kl.de{ 52212027Sjungma@eit.uni-kl.de return target.value() << (int)shift; 52312027Sjungma@eit.uni-kl.de} 52412027Sjungma@eit.uni-kl.de 52512027Sjungma@eit.uni-kl.deinline const sc_unsigned operator << ( 52612027Sjungma@eit.uni-kl.de const sc_concatref& target, unsigned long shift ) 52712027Sjungma@eit.uni-kl.de{ 52812027Sjungma@eit.uni-kl.de return target.value() << (int)shift; 52912027Sjungma@eit.uni-kl.de} 53012027Sjungma@eit.uni-kl.de 53112027Sjungma@eit.uni-kl.deinline const sc_unsigned operator << ( 53212027Sjungma@eit.uni-kl.de const sc_concatref& target, int shift ) 53312027Sjungma@eit.uni-kl.de{ 53412027Sjungma@eit.uni-kl.de return target.value() << shift; 53512027Sjungma@eit.uni-kl.de} 53612027Sjungma@eit.uni-kl.de 53712027Sjungma@eit.uni-kl.deinline const sc_unsigned operator << ( 53812027Sjungma@eit.uni-kl.de const sc_concatref& target, unsigned int shift ) 53912027Sjungma@eit.uni-kl.de{ 54012027Sjungma@eit.uni-kl.de return target.value() << (int)shift; 54112027Sjungma@eit.uni-kl.de} 54212027Sjungma@eit.uni-kl.de 54312027Sjungma@eit.uni-kl.deinline const sc_unsigned operator << ( const sc_concatref& target, long shift ) 54412027Sjungma@eit.uni-kl.de{ 54512027Sjungma@eit.uni-kl.de return target.value() << (int)shift; 54612027Sjungma@eit.uni-kl.de} 54712027Sjungma@eit.uni-kl.de 54812027Sjungma@eit.uni-kl.deinline const sc_unsigned operator >> (const sc_concatref& target, uint64 shift) 54912027Sjungma@eit.uni-kl.de{ 55012027Sjungma@eit.uni-kl.de return target.value() >> (int)shift; 55112027Sjungma@eit.uni-kl.de} 55212027Sjungma@eit.uni-kl.de 55312027Sjungma@eit.uni-kl.deinline const sc_unsigned operator >> (const sc_concatref& target, int64 shift) 55412027Sjungma@eit.uni-kl.de{ 55512027Sjungma@eit.uni-kl.de return target.value() >> (int)shift; 55612027Sjungma@eit.uni-kl.de} 55712027Sjungma@eit.uni-kl.de 55812027Sjungma@eit.uni-kl.deinline const sc_unsigned operator >> ( 55912027Sjungma@eit.uni-kl.de const sc_concatref& target, unsigned long shift ) 56012027Sjungma@eit.uni-kl.de{ 56112027Sjungma@eit.uni-kl.de return target.value() >> (int)shift; 56212027Sjungma@eit.uni-kl.de} 56312027Sjungma@eit.uni-kl.de 56412027Sjungma@eit.uni-kl.deinline const sc_unsigned operator >> ( 56512027Sjungma@eit.uni-kl.de const sc_concatref& target, int shift ) 56612027Sjungma@eit.uni-kl.de{ 56712027Sjungma@eit.uni-kl.de return target.value() >> shift; 56812027Sjungma@eit.uni-kl.de} 56912027Sjungma@eit.uni-kl.de 57012027Sjungma@eit.uni-kl.deinline const sc_unsigned operator >> ( 57112027Sjungma@eit.uni-kl.de const sc_concatref& target, unsigned int shift ) 57212027Sjungma@eit.uni-kl.de{ 57312027Sjungma@eit.uni-kl.de return target.value() >> (int)shift; 57412027Sjungma@eit.uni-kl.de} 57512027Sjungma@eit.uni-kl.de 57612027Sjungma@eit.uni-kl.deinline const sc_unsigned operator >> ( const sc_concatref& target, long shift ) 57712027Sjungma@eit.uni-kl.de{ 57812027Sjungma@eit.uni-kl.de return target.value() >> (int)shift; 57912027Sjungma@eit.uni-kl.de} 58012027Sjungma@eit.uni-kl.de 58112027Sjungma@eit.uni-kl.de 58212027Sjungma@eit.uni-kl.de// STREAM OPERATORS FOR sc_concatref OBJECT INSTANCES: 58312027Sjungma@eit.uni-kl.de 58412027Sjungma@eit.uni-kl.deinline 58512027Sjungma@eit.uni-kl.de::std::ostream& 58612027Sjungma@eit.uni-kl.deoperator << ( ::std::ostream& os, const sc_concatref& v ) 58712027Sjungma@eit.uni-kl.de{ 58812027Sjungma@eit.uni-kl.de return os << v.value(); 58912027Sjungma@eit.uni-kl.de} 59012027Sjungma@eit.uni-kl.de 59112027Sjungma@eit.uni-kl.deinline 59212027Sjungma@eit.uni-kl.de::std::istream& 59312027Sjungma@eit.uni-kl.deoperator >> ( ::std::istream& is, sc_concatref& a ) 59412027Sjungma@eit.uni-kl.de{ 59512027Sjungma@eit.uni-kl.de sc_unsigned temp(a.concat_length(0)); 59612027Sjungma@eit.uni-kl.de temp.scan( is ); 59712027Sjungma@eit.uni-kl.de a = temp; 59812027Sjungma@eit.uni-kl.de return is; 59912027Sjungma@eit.uni-kl.de} 60012027Sjungma@eit.uni-kl.de 60112027Sjungma@eit.uni-kl.de 60212027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 60312027Sjungma@eit.uni-kl.de// CLASS TEMPLATE : sc_concat_bool 60412027Sjungma@eit.uni-kl.de// 60512027Sjungma@eit.uni-kl.de// Proxy class for read-only boolean values in concatenations. 60612027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 60712027Sjungma@eit.uni-kl.de 60812027Sjungma@eit.uni-kl.declass sc_concat_bool : public sc_value_base 60912027Sjungma@eit.uni-kl.de{ 61012027Sjungma@eit.uni-kl.de protected: 61112027Sjungma@eit.uni-kl.de static sc_core::sc_vpool<sc_concat_bool> m_pool; // Temporaries pool. 61212027Sjungma@eit.uni-kl.de bool m_value; // Value for this obj. 61312027Sjungma@eit.uni-kl.de 61412027Sjungma@eit.uni-kl.de public: 61512027Sjungma@eit.uni-kl.de 61612027Sjungma@eit.uni-kl.de // constructor: 61712027Sjungma@eit.uni-kl.de 61812027Sjungma@eit.uni-kl.de sc_concat_bool() 61912027Sjungma@eit.uni-kl.de : sc_value_base(), m_value() 62012027Sjungma@eit.uni-kl.de {} 62112027Sjungma@eit.uni-kl.de 62212027Sjungma@eit.uni-kl.de // destructor: 62312027Sjungma@eit.uni-kl.de 62412027Sjungma@eit.uni-kl.de virtual ~sc_concat_bool() 62512027Sjungma@eit.uni-kl.de { } 62612027Sjungma@eit.uni-kl.de 62712027Sjungma@eit.uni-kl.de // allocation of temporary object: 62812027Sjungma@eit.uni-kl.de 62912027Sjungma@eit.uni-kl.de static inline sc_concat_bool* allocate( bool v ) 63012027Sjungma@eit.uni-kl.de { 63112027Sjungma@eit.uni-kl.de sc_concat_bool* result_p = m_pool.allocate(); 63212027Sjungma@eit.uni-kl.de result_p->m_value = v; 63312027Sjungma@eit.uni-kl.de return result_p; 63412027Sjungma@eit.uni-kl.de } 63512027Sjungma@eit.uni-kl.de 63612027Sjungma@eit.uni-kl.de // concatenation: 63712027Sjungma@eit.uni-kl.de 63812027Sjungma@eit.uni-kl.de virtual int concat_length( bool* xz_present_p ) const 63912027Sjungma@eit.uni-kl.de { 64012027Sjungma@eit.uni-kl.de if ( xz_present_p ) *xz_present_p = false; 64112027Sjungma@eit.uni-kl.de return 1; 64212027Sjungma@eit.uni-kl.de } 64312027Sjungma@eit.uni-kl.de 64412027Sjungma@eit.uni-kl.de virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const 64512027Sjungma@eit.uni-kl.de { 64612027Sjungma@eit.uni-kl.de int bit = 1 << (low_i % BITS_PER_DIGIT); 64712027Sjungma@eit.uni-kl.de int word_i = low_i / BITS_PER_DIGIT; 64812027Sjungma@eit.uni-kl.de dst_p[word_i] &= ~bit; 64912027Sjungma@eit.uni-kl.de return false; 65012027Sjungma@eit.uni-kl.de } 65112027Sjungma@eit.uni-kl.de 65212027Sjungma@eit.uni-kl.de virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const 65312027Sjungma@eit.uni-kl.de { 65412027Sjungma@eit.uni-kl.de int bit = 1 << (low_i % BITS_PER_DIGIT); 65512027Sjungma@eit.uni-kl.de int word_i = low_i / BITS_PER_DIGIT; 65612027Sjungma@eit.uni-kl.de if ( m_value ) 65712027Sjungma@eit.uni-kl.de dst_p[word_i] |= bit; 65812027Sjungma@eit.uni-kl.de else 65912027Sjungma@eit.uni-kl.de dst_p[word_i] &= ~bit; 66012027Sjungma@eit.uni-kl.de return m_value; 66112027Sjungma@eit.uni-kl.de } 66212027Sjungma@eit.uni-kl.de 66312027Sjungma@eit.uni-kl.de virtual uint64 concat_get_uint64() const 66412027Sjungma@eit.uni-kl.de { 66512027Sjungma@eit.uni-kl.de return m_value ? 1 : 0; 66612027Sjungma@eit.uni-kl.de } 66712027Sjungma@eit.uni-kl.de}; 66812027Sjungma@eit.uni-kl.de 66912027Sjungma@eit.uni-kl.de 67012027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 67112027Sjungma@eit.uni-kl.de// ARITHMETIC AND LOGIC OPERATORS FOR sc_concatref 67212027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 67312027Sjungma@eit.uni-kl.de 67412027Sjungma@eit.uni-kl.de#define SC_CONCAT_OP_TYPE(RESULT,OP,OTHER_TYPE) \ 67512027Sjungma@eit.uni-kl.de inline RESULT operator OP ( const sc_concatref& a, OTHER_TYPE b ) \ 67612027Sjungma@eit.uni-kl.de { \ 67712027Sjungma@eit.uni-kl.de return a.value() OP b; \ 67812027Sjungma@eit.uni-kl.de } \ 67912027Sjungma@eit.uni-kl.de inline RESULT operator OP ( OTHER_TYPE a, const sc_concatref& b ) \ 68012027Sjungma@eit.uni-kl.de { \ 68112027Sjungma@eit.uni-kl.de return a OP b.value(); \ 68212027Sjungma@eit.uni-kl.de } 68312027Sjungma@eit.uni-kl.de 68412027Sjungma@eit.uni-kl.de 68512027Sjungma@eit.uni-kl.de#define SC_CONCAT_OP(RESULT,OP) \ 68612027Sjungma@eit.uni-kl.de inline RESULT operator OP ( const sc_concatref& a, const sc_concatref& b ) \ 68712027Sjungma@eit.uni-kl.de { \ 68812027Sjungma@eit.uni-kl.de return a.value() OP b.value(); \ 68912027Sjungma@eit.uni-kl.de } \ 69012027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(const sc_signed,OP,int) \ 69112027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(const sc_signed,OP,long) \ 69212027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(const sc_signed,OP,int64) \ 69312027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(RESULT,OP,unsigned int) \ 69412027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(RESULT,OP,unsigned long) \ 69512027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(RESULT,OP,uint64) \ 69612027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(const sc_signed,OP,const sc_int_base&) \ 69712027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(RESULT,OP,const sc_uint_base&) \ 69812027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(const sc_signed,OP,const sc_signed&) \ 69912027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(RESULT,OP,const sc_unsigned&) \ 70012027Sjungma@eit.uni-kl.de inline RESULT operator OP ( const sc_concatref& a, bool b ) \ 70112027Sjungma@eit.uni-kl.de { \ 70212027Sjungma@eit.uni-kl.de return a.value() OP (int)b; \ 70312027Sjungma@eit.uni-kl.de } \ 70412027Sjungma@eit.uni-kl.de inline RESULT operator OP ( bool a, const sc_concatref& b ) \ 70512027Sjungma@eit.uni-kl.de { \ 70612027Sjungma@eit.uni-kl.de return (int)a OP b.value(); \ 70712027Sjungma@eit.uni-kl.de } 70812027Sjungma@eit.uni-kl.de 70912027Sjungma@eit.uni-kl.de#define SC_CONCAT_BOOL_OP(OP) \ 71012027Sjungma@eit.uni-kl.de inline bool operator OP ( const sc_concatref& a, const sc_concatref& b ) \ 71112027Sjungma@eit.uni-kl.de { \ 71212027Sjungma@eit.uni-kl.de return a.value() OP b.value(); \ 71312027Sjungma@eit.uni-kl.de } \ 71412027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,int) \ 71512027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,long) \ 71612027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,int64) \ 71712027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,unsigned int) \ 71812027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,unsigned long) \ 71912027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,uint64) \ 72012027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,const sc_int_base&) \ 72112027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,const sc_uint_base&) \ 72212027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,const sc_signed&) \ 72312027Sjungma@eit.uni-kl.de SC_CONCAT_OP_TYPE(bool,OP,const sc_unsigned&) \ 72412027Sjungma@eit.uni-kl.de inline bool operator OP ( const sc_concatref& a, bool b ) \ 72512027Sjungma@eit.uni-kl.de { \ 72612027Sjungma@eit.uni-kl.de return a.value() OP (int)b; \ 72712027Sjungma@eit.uni-kl.de } \ 72812027Sjungma@eit.uni-kl.de inline bool operator OP ( bool a, const sc_concatref& b ) \ 72912027Sjungma@eit.uni-kl.de { \ 73012027Sjungma@eit.uni-kl.de return (int)a OP b.value(); \ 73112027Sjungma@eit.uni-kl.de } 73212027Sjungma@eit.uni-kl.de 73312027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,+) 73412027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_signed,-) 73512027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,*) 73612027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,/) 73712027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,%) 73812027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,&) 73912027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,|) 74012027Sjungma@eit.uni-kl.deSC_CONCAT_OP(const sc_unsigned,^) 74112027Sjungma@eit.uni-kl.deSC_CONCAT_BOOL_OP(==) 74212027Sjungma@eit.uni-kl.deSC_CONCAT_BOOL_OP(<=) 74312027Sjungma@eit.uni-kl.deSC_CONCAT_BOOL_OP(>=) 74412027Sjungma@eit.uni-kl.deSC_CONCAT_BOOL_OP(!=) 74512027Sjungma@eit.uni-kl.deSC_CONCAT_BOOL_OP(>) 74612027Sjungma@eit.uni-kl.deSC_CONCAT_BOOL_OP(<) 74712027Sjungma@eit.uni-kl.de 74812027Sjungma@eit.uni-kl.de#undef SC_CONCAT_OP 74912027Sjungma@eit.uni-kl.de#undef SC_CONCAT_OP_TYPE 75012027Sjungma@eit.uni-kl.de 75112027Sjungma@eit.uni-kl.de 75212027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 75312027Sjungma@eit.uni-kl.de// CONCATENATION FUNCTION AND OPERATOR FOR STANDARD SYSTEM C DATA TYPES: 75412027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 75512027Sjungma@eit.uni-kl.de 75612027Sjungma@eit.uni-kl.deinline sc_dt::sc_concatref& concat( 75712027Sjungma@eit.uni-kl.de sc_dt::sc_value_base& a, sc_dt::sc_value_base& b) 75812027Sjungma@eit.uni-kl.de{ 75912027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 76012027Sjungma@eit.uni-kl.de 76112027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 76212027Sjungma@eit.uni-kl.de result_p->initialize( a, b ); 76312027Sjungma@eit.uni-kl.de return *result_p; 76412027Sjungma@eit.uni-kl.de} 76512027Sjungma@eit.uni-kl.de 76612027Sjungma@eit.uni-kl.deinline 76712027Sjungma@eit.uni-kl.deconst 76812027Sjungma@eit.uni-kl.desc_dt::sc_concatref& concat( 76912027Sjungma@eit.uni-kl.de const sc_dt::sc_value_base& a, const sc_dt::sc_value_base& b) 77012027Sjungma@eit.uni-kl.de{ 77112027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 77212027Sjungma@eit.uni-kl.de 77312027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 77412027Sjungma@eit.uni-kl.de result_p->initialize( a, b ); 77512027Sjungma@eit.uni-kl.de return *result_p; 77612027Sjungma@eit.uni-kl.de} 77712027Sjungma@eit.uni-kl.de 77812027Sjungma@eit.uni-kl.deinline 77912027Sjungma@eit.uni-kl.deconst 78012027Sjungma@eit.uni-kl.desc_dt::sc_concatref& concat(const sc_dt::sc_value_base& a, bool b) 78112027Sjungma@eit.uni-kl.de{ 78212027Sjungma@eit.uni-kl.de const sc_dt::sc_concat_bool* b_p; // Proxy for boolean value. 78312027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 78412027Sjungma@eit.uni-kl.de 78512027Sjungma@eit.uni-kl.de b_p = sc_dt::sc_concat_bool::allocate(b); 78612027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 78712027Sjungma@eit.uni-kl.de result_p->initialize( a, *b_p ); 78812027Sjungma@eit.uni-kl.de return *result_p; 78912027Sjungma@eit.uni-kl.de} 79012027Sjungma@eit.uni-kl.de 79112027Sjungma@eit.uni-kl.deinline 79212027Sjungma@eit.uni-kl.deconst 79312027Sjungma@eit.uni-kl.desc_dt::sc_concatref& concat(bool a, const sc_dt::sc_value_base& b) 79412027Sjungma@eit.uni-kl.de{ 79512027Sjungma@eit.uni-kl.de const sc_dt::sc_concat_bool* a_p; // Proxy for boolean value. 79612027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 79712027Sjungma@eit.uni-kl.de 79812027Sjungma@eit.uni-kl.de a_p = sc_dt::sc_concat_bool::allocate(a); 79912027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 80012027Sjungma@eit.uni-kl.de result_p->initialize( *a_p, b ); 80112027Sjungma@eit.uni-kl.de return *result_p; 80212027Sjungma@eit.uni-kl.de} 80312027Sjungma@eit.uni-kl.de 80412027Sjungma@eit.uni-kl.deinline sc_dt::sc_concatref& operator , ( 80512027Sjungma@eit.uni-kl.de sc_dt::sc_value_base& a, sc_dt::sc_value_base& b) 80612027Sjungma@eit.uni-kl.de{ 80712027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 80812027Sjungma@eit.uni-kl.de 80912027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 81012027Sjungma@eit.uni-kl.de result_p->initialize( a, b ); 81112027Sjungma@eit.uni-kl.de return *result_p; 81212027Sjungma@eit.uni-kl.de} 81312027Sjungma@eit.uni-kl.de 81412027Sjungma@eit.uni-kl.deinline 81512027Sjungma@eit.uni-kl.deconst 81612027Sjungma@eit.uni-kl.desc_dt::sc_concatref& operator , ( 81712027Sjungma@eit.uni-kl.de const sc_dt::sc_value_base& a, const sc_dt::sc_value_base& b) 81812027Sjungma@eit.uni-kl.de{ 81912027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 82012027Sjungma@eit.uni-kl.de 82112027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 82212027Sjungma@eit.uni-kl.de result_p->initialize( a, b ); 82312027Sjungma@eit.uni-kl.de return *result_p; 82412027Sjungma@eit.uni-kl.de} 82512027Sjungma@eit.uni-kl.de 82612027Sjungma@eit.uni-kl.deinline 82712027Sjungma@eit.uni-kl.deconst 82812027Sjungma@eit.uni-kl.desc_dt::sc_concatref& operator , (const sc_dt::sc_value_base& a, bool b) 82912027Sjungma@eit.uni-kl.de{ 83012027Sjungma@eit.uni-kl.de const sc_dt::sc_concat_bool* b_p; // Proxy for boolean value. 83112027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 83212027Sjungma@eit.uni-kl.de 83312027Sjungma@eit.uni-kl.de b_p = sc_dt::sc_concat_bool::allocate(b); 83412027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 83512027Sjungma@eit.uni-kl.de result_p->initialize( a, *b_p ); 83612027Sjungma@eit.uni-kl.de return *result_p; 83712027Sjungma@eit.uni-kl.de} 83812027Sjungma@eit.uni-kl.de 83912027Sjungma@eit.uni-kl.deinline 84012027Sjungma@eit.uni-kl.deconst 84112027Sjungma@eit.uni-kl.desc_dt::sc_concatref& operator , (bool a, const sc_dt::sc_value_base& b) 84212027Sjungma@eit.uni-kl.de{ 84312027Sjungma@eit.uni-kl.de const sc_dt::sc_concat_bool* a_p; // Proxy for boolean value. 84412027Sjungma@eit.uni-kl.de sc_dt::sc_concatref* result_p; // Proxy for the concatenation. 84512027Sjungma@eit.uni-kl.de 84612027Sjungma@eit.uni-kl.de a_p = sc_dt::sc_concat_bool::allocate(a); 84712027Sjungma@eit.uni-kl.de result_p = sc_dt::sc_concatref::m_pool.allocate(); 84812027Sjungma@eit.uni-kl.de result_p->initialize( *a_p, b ); 84912027Sjungma@eit.uni-kl.de return *result_p; 85012027Sjungma@eit.uni-kl.de} 85112027Sjungma@eit.uni-kl.de 85212027Sjungma@eit.uni-kl.de} // namespace sc_dt 85312027Sjungma@eit.uni-kl.de 85412027Sjungma@eit.uni-kl.de#endif // SC_CONCATREF_H 85512027Sjungma@eit.uni-kl.de 856