sc_value_base.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 sc_value_base.h -- Base class for SystemC bit values. 2312853Sgabeblack@google.com 2412853Sgabeblack@google.com Original Author: Andy Goodrich, Forte Design Systems 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: sc_value_base.h,v $ 3912853Sgabeblack@google.com// Revision 1.4 2011/08/29 18:04:32 acg 4012853Sgabeblack@google.com// Philipp A. Hartmann: miscellaneous clean ups. 4112853Sgabeblack@google.com// 4212853Sgabeblack@google.com// Revision 1.3 2011/08/24 22:05:48 acg 4312853Sgabeblack@google.com// Torsten Maehne: initialization changes to remove warnings. 4412853Sgabeblack@google.com// 4512853Sgabeblack@google.com// Revision 1.2 2011/06/28 21:23:04 acg 4612853Sgabeblack@google.com// Andy Goodrich: merging of SCV tree. 4712853Sgabeblack@google.com// 4812853Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:20:05 acg 4912853Sgabeblack@google.com// SystemC 2.3 5012853Sgabeblack@google.com// 5112853Sgabeblack@google.com// Revision 1.3 2006/01/13 18:54:01 acg 5212853Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in 5312853Sgabeblack@google.com// the source. 5412853Sgabeblack@google.com// 5512853Sgabeblack@google.com 5612853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_MISC_SC_VALUE_BASE_HH__ 5712853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_MISC_SC_VALUE_BASE_HH__ 5812853Sgabeblack@google.com 5912853Sgabeblack@google.com#include "../int/sc_nbdefs.hh" 6012853Sgabeblack@google.com 6112853Sgabeblack@google.comnamespace sc_dt 6212853Sgabeblack@google.com{ 6312853Sgabeblack@google.com 6412853Sgabeblack@google.comclass sc_signed; 6512853Sgabeblack@google.comclass sc_unsigned; 6612853Sgabeblack@google.com 6712853Sgabeblack@google.com// ---------------------------------------------------------------------------- 6812853Sgabeblack@google.com// CLASS : sc_value_base 6912853Sgabeblack@google.com// 7012853Sgabeblack@google.com// Abstract base class of all SystemC native variables. It provides 7112853Sgabeblack@google.com// support for concatenation operations via a set of virtual methods. 7212853Sgabeblack@google.com// A general description of the methods appear with their default 7312853Sgabeblack@google.com// definitions in sc_object.cpp. 7412853Sgabeblack@google.com// ---------------------------------------------------------------------------- 7512853Sgabeblack@google.com 7612853Sgabeblack@google.comclass sc_value_base 7712853Sgabeblack@google.com{ 7812853Sgabeblack@google.com friend class sc_concatref; 7912853Sgabeblack@google.com private: 8012853Sgabeblack@google.com virtual void concat_clear_data(bool to_ones=false); 8112853Sgabeblack@google.com virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const; 8212853Sgabeblack@google.com virtual bool concat_get_data(sc_digit *dst_p, int low_i) const; 8312853Sgabeblack@google.com virtual uint64 concat_get_uint64() const; 8412853Sgabeblack@google.com virtual int concat_length(bool *xz_present_p=0) const; 8512853Sgabeblack@google.com virtual void concat_set(int64 src, int low_i); 8612853Sgabeblack@google.com virtual void concat_set(const sc_signed& src, int low_i); 8712853Sgabeblack@google.com virtual void concat_set(const sc_unsigned& src, int low_i); 8812853Sgabeblack@google.com virtual void concat_set(uint64 src, int low_i); 8912853Sgabeblack@google.com public: 9012853Sgabeblack@google.com virtual ~sc_value_base() {} 9112853Sgabeblack@google.com}; 9212853Sgabeblack@google.com 9312853Sgabeblack@google.com 9412853Sgabeblack@google.com// ---------------------------------------------------------------------------- 9512853Sgabeblack@google.com// CLASS : sc_generic_base 9612853Sgabeblack@google.com// 9712853Sgabeblack@google.com// Proxy class for user-defined value classes and other classes that 9812853Sgabeblack@google.com// are defined outside of SystemC. 9912853Sgabeblack@google.com// The class is utilized as a base class for the arbitrary class: 10012853Sgabeblack@google.com// 10112853Sgabeblack@google.com// class my_class : public sc_generic_base<my_class> 10212853Sgabeblack@google.com// 10312853Sgabeblack@google.com// The purpose of the class is to allow to_XXXX methods defined within that 10412853Sgabeblack@google.com// class so that assignments and casts from the arbitrary class to native 10512853Sgabeblack@google.com// SystemC types are possible. To interact correctly with the SystemC library 10612853Sgabeblack@google.com// the class derived from sc_generic_base must implement the following 10712853Sgabeblack@google.com// methods: 10812853Sgabeblack@google.com// (1) uint64 to_uint64() const 10912853Sgabeblack@google.com// (2) int64 to_int64() const 11012853Sgabeblack@google.com// (3) void to_sc_unsigned( sc_unsigned& ) const 11112853Sgabeblack@google.com// (4) void to_sc_signed( sc_signed& ) const 11212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 11312853Sgabeblack@google.comtemplate< class T > 11412853Sgabeblack@google.comclass sc_generic_base 11512853Sgabeblack@google.com{ 11612853Sgabeblack@google.com public: 11712853Sgabeblack@google.com inline const T *operator-> () const { return (const T *)this; } 11812853Sgabeblack@google.com inline T *operator-> () { return (T *)this; } 11912853Sgabeblack@google.com}; 12012853Sgabeblack@google.com 12112853Sgabeblack@google.com} // namespace sc_dt 12212853Sgabeblack@google.com 12312853Sgabeblack@google.com#endif // SYSTEMC_EXT_DT_MISC_SC_VALUE_BASE_HH__ 124