SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_macros.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_macros.h -- Miscellaneous definitions that are needed by the headers.
21 
22  Original Author: Stan Y. Liao, Synopsys, Inc.
23 
24  CHANGE LOG AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 
28 #ifndef SC_MACROS_H
29 #define SC_MACROS_H
30 
31 
32 namespace sc_dt {
33 
34 template <class T>
35 inline
36 const T
37 sc_min( const T& a, const T& b )
38 {
39  return ( ( a <= b ) ? a : b );
40 }
41 
42 template <class T>
43 inline
44 const T
45 sc_max( const T& a, const T& b )
46 {
47  return ( ( a >= b ) ? a : b );
48 }
49 
50 template <class T>
51 inline
52 const T
53 sc_abs( const T& a )
54 {
55  // return ( a >= 0 ? a : -a );
56  // the code below is functionaly the same as the code above; the
57  // difference is that the code below works for all arithmetic
58  // SystemC datatypes.
59  T z( a );
60  z = 0;
61  if( a >= z ) {
62  return a;
63  } else {
64  T c( a );
65  c = -a;
66  return c;
67  }
68 }
69 
70 } // namespace sc_dt
71 
72 namespace sc_core {
73 
74 // token stringification
75 
76 #define SC_STRINGIFY_HELPER_( Arg ) \
77  SC_STRINGIFY_HELPER_DEFERRED_( Arg )
78 #define SC_STRINGIFY_HELPER_DEFERRED_( Arg ) \
79  SC_STRINGIFY_HELPER_MORE_DEFERRED_( Arg )
80 #define SC_STRINGIFY_HELPER_MORE_DEFERRED_( Arg ) \
81  #Arg
82 
83 
84 // token concatenation
85 
86 #define SC_CONCAT_HELPER_( a, b ) \
87  SC_CONCAT_HELPER_DEFERRED_( a, b )
88 #define SC_CONCAT_HELPER_DEFERRED_( a, b ) \
89  SC_CONCAT_HELPER_MORE_DEFERRED_( a,b )
90 #define SC_CONCAT_HELPER_MORE_DEFERRED_( a, b ) \
91  a ## b
92 #define SC_CONCAT_UNDERSCORE_( a, b ) \
93  SC_CONCAT_HELPER_( a, SC_CONCAT_HELPER_( _, b ) )
94 
95 /*
96  * These help debugging --
97  * -- user can find out where each process is stopped at.
98  */
99 
100 #define WAIT() \
101  ::sc_core::sc_set_location( __FILE__, __LINE__ ); \
102  ::sc_core::wait()
103 
104 #define WAITN(n) \
105  ::sc_core::sc_set_location( __FILE__, __LINE__ ); \
106  ::sc_core::wait(n)
107 
108 #define WAIT_UNTIL(expr) \
109  ::sc_core::sc_set_location( __FILE__, __LINE__ ); \
110  do { ::sc_core::wait(); } while( !(expr) )
111 
112 } // namespace sc_core
113 
114 // $Log: sc_macros.h,v $
115 // Revision 1.5 2011/08/26 20:46:09 acg
116 // Andy Goodrich: moved the modification log to the end of the file to
117 // eliminate source line number skew when check-ins are done.
118 //
119 // Revision 1.4 2011/02/18 20:27:14 acg
120 // Andy Goodrich: Updated Copyrights.
121 //
122 // Revision 1.3 2011/02/13 21:47:37 acg
123 // Andy Goodrich: update copyright notice.
124 //
125 // Revision 1.2 2008/05/22 17:06:25 acg
126 // Andy Goodrich: updated copyright notice to include 2008.
127 //
128 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
129 // SystemC 2.3
130 //
131 // Revision 1.3 2006/01/13 18:44:29 acg
132 // Added $Log to record CVS changes into the source.
133 
134 #endif
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1003
const T sc_min(const T &a, const T &b)
Definition: sc_macros.h:37
const T sc_abs(const T &a)
Definition: sc_macros.h:53
const T sc_max(const T &a, const T &b)
Definition: sc_macros.h:45