Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

sc_macros.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2004 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.3 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_macros.h -- Miscellaneous definitions that are needed by the headers.
00021 
00022   Original Author: Stan Y. Liao, Synopsys, Inc.
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 #ifndef SC_MACROS_H
00037 #define SC_MACROS_H
00038 
00039 
00040 template <class T>
00041 inline
00042 const T
00043 sc_min( const T& a, const T& b )
00044 {
00045     return ( ( a <= b ) ? a : b );
00046 }
00047 
00048 template <class T>
00049 inline
00050 const T
00051 sc_max( const T& a, const T& b )
00052 {
00053     return ( ( a >= b ) ? a : b );
00054 }
00055 
00056 template <class T>
00057 inline
00058 const T
00059 sc_abs( const T& a )
00060 {
00061     // return ( a >= 0 ? a : -a );
00062     // the code below is functionaly the same as the code above; the
00063     // difference is that the code below works for all arithmetic
00064     // SystemC datatypes.
00065     T z( a );
00066     z = 0;
00067     if( a >= z ) {
00068   return a;
00069     } else {
00070   T c( a );
00071   c = -a;
00072   return c;
00073     }
00074 }
00075 
00076 
00077 #if defined(__GNUC__) && defined(USE_RTTI)
00078 #define HAVE_CAST_OPERATORS
00079 #endif
00080 
00081 
00082 #if defined(__GNUC__)
00083 // 10.3.5 - Some compilers (e.g. K&A C++) do not support the
00084 // construct in which a virtual function defined in a subclass returns
00085 // a pointer or reference to a class D whereas the declaration of the
00086 // same virtual function in the base class returns a pointer or
00087 // reference to a base class B of D.
00088 #define ANSI_VIRTUAL_RETURN_INHERITED_TYPE
00089 #endif
00090 
00091 
00092 /*
00093  *  Note that sc_get_curr_simcontext() may also be a member
00094  *  of sc_module. The idea is that if we are inside an sc_module,
00095  *  then its associated simcontext should always be the current
00096  *  simcontext.
00097  */
00098 
00099 #define W_BEGIN                                                               \
00100     do {                                                                      \
00101         sc_watch __aux_watch( sc_get_curr_simcontext() );
00102 
00103 #define W_DO                                                                  \
00104         try {                                                                 \
00105             __watching_first( __aux_watch.cthread_h );
00106 
00107 #define W_ESCAPE                                                              \
00108         }                                                                     \
00109         catch( int sc_level ) {                                               \
00110             __sanitycheck_watchlists( __aux_watch.cthread_h );                \
00111             if( sc_level < __watch_level( __aux_watch.cthread_h ) ) {         \
00112                 throw sc_level;                                               \
00113             }
00114 
00115 #define W_END                                                                 \
00116         }                                                                     \
00117     } while( false );
00118 
00119 
00120 /*
00121  *  These help debugging --
00122  *  -- user can find out where each process is stopped at.
00123  */
00124 
00125 #define WAIT()                                                                \
00126     sc_set_location( __FILE__, __LINE__ );                                    \
00127     wait()
00128 
00129 #define WAITN(n)                                                              \
00130     sc_set_location( __FILE__, __LINE__ );                                    \
00131     wait(n)
00132 
00133 #define WAIT_UNTIL(lambda)                                                    \
00134     sc_set_location( __FILE__, __LINE__ );                                    \
00135     wait_until( lambda )
00136 
00137 
00138 #endif

Generated on Fri Jan 14 08:29:03 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18