1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22    sc_ver.cpp -- copyright information.
23
24    Original Author: Stan Y. Liao, Synopsys, Inc.
25
26  CHANGE LOG AT THE END OF THE FILE
27 *****************************************************************************/
28
29#include <cstddef>
30#include <cstdlib>
31
32#define SC_DISABLE_API_VERSION_CHECK // for in-library sc_ver.h inclusion
33
34#include "sysc/kernel/sc_ver.h"
35#include "sysc/kernel/sc_kernel_ids.h"
36#include "sysc/utils/sc_iostream.h"
37#include "sysc/utils/sc_report.h"
38
39using std::getenv;
40using std::strcmp;
41using std::cerr;
42using std::endl;
43
44namespace sc_core {
45
46
47static
48const char systemc_version[] =
49    "SystemC " SC_VERSION " --- " __DATE__ " " __TIME__;
50
51const unsigned int sc_version_major = SC_VERSION_MAJOR;
52const unsigned int sc_version_minor = SC_VERSION_MINOR;
53const unsigned int sc_version_patch = SC_VERSION_PATCH;
54const bool         sc_is_prerelease = SC_IS_PRERELEASE;
55
56const std::string  sc_version_originator   = SC_VERSION_ORIGINATOR;
57const std::string  sc_version_release_date = SC_VERSION_RELEASE_DATE;
58const std::string  sc_version_prerelease   = SC_VERSION_PRERELEASE;
59const std::string  sc_version_string       = SC_VERSION;
60const std::string  sc_copyright_string     = SC_COPYRIGHT;
61
62const char*
63sc_copyright()
64{
65    return SC_COPYRIGHT;
66}
67
68
69const char*
70sc_release()
71{
72    return SC_VERSION;
73}
74
75
76const char*
77sc_version()
78{
79    return systemc_version;
80}
81
82
83#if !defined(SC_DISABLE_COPYRIGHT_MESSAGE)
84#  define SC_DISABLE_COPYRIGHT_MESSAGE 0
85#endif
86
87// ----------------------------------------------------------------------------
88
89void
90pln()
91{
92    static bool lnp = SC_DISABLE_COPYRIGHT_MESSAGE;
93    if ( lnp || getenv("SYSTEMC_DISABLE_COPYRIGHT_MESSAGE") != 0 )
94        lnp = true;
95    if ( const char * lnp_env = getenv("SC_COPYRIGHT_MESSAGE") ) {
96        lnp = !strcmp( lnp_env, "DISABLE" );
97    }
98    if( ! lnp ) {
99
100        static const char indent[] = "        ";
101        std::string       line;
102        std::stringstream copyright;
103
104        // temporary stream to print copyright line-wise with indentation
105        copyright << sc_copyright();
106
107        cerr << endl;
108        cerr << indent << sc_version() << endl;
109        while( getline( copyright, line ) )
110            cerr << indent << line << endl;
111
112        //  regressions check point
113
114        if( getenv( "SYSTEMC_REGRESSION" ) != 0 ) {
115            cerr << "SystemC Simulation" << endl;
116        }
117
118        lnp = true;
119    }
120}
121
122#define SC_API_PERFORM_CHECK_( Type, Name, Symbol ) \
123  do { \
124    static bool SC_CONCAT_UNDERSCORE_( Name, config_seen ) = false; \
125    static Type SC_CONCAT_UNDERSCORE_( Name, config ); \
126    if( ! SC_CONCAT_UNDERSCORE_( Name, config_seen ) ) { \
127      SC_CONCAT_UNDERSCORE_( Name, config_seen ) = true; \
128      SC_CONCAT_UNDERSCORE_( Name, config ) = Name; \
129    } else if( SC_CONCAT_UNDERSCORE_( Name, config ) != Name ) { \
130      SC_REPORT_FATAL( SC_ID_INCONSISTENT_API_CONFIG_, Symbol ); \
131    } \
132  } while( false )
133
134// THIS CONSTRUCTOR ROOTS OUT OLD OBJECTS AT LINK TIME
135//
136// Each source file which includes sc_ver.h for this SystemC version
137// will have a static instance of the class sc_api_version_XXX defined
138// in it. That object instanciation will cause the constructor below
139// to be invoked. If the version of the SystemC being linked against
140// does not contain the constructor below a linkage error will occur.
141//
142// Some preprocessor switches need to be consistent between the application
143// and the library (e.g. if sizes of classes are affected or other parts of
144// the ABI are affected).  (Some of) these are checked here at link-time as
145// well, by setting template parameters to sc_api_version_XXX, while only
146// one variant is defined here.
147//
148// Some preprocessor switches need to be consistent between different
149// translation units of an application.  Those can't be easily checked
150// during link-time.  Instead, perform a check during run-time by
151// passing the value to the constructor of the api_version_check object.
152
153// const int DEBUG_SYSTEMC_CHECK_           = 1;
154const int SC_DISABLE_VIRTUAL_BIND_CHECK_ = 1;
155
156template<>
157SC_API_VERSION_STRING
158<
159//   & DEBUG_SYSTEMC_CHECK_,
160  & SC_DISABLE_VIRTUAL_BIND_CHECK_
161>
162::SC_API_VERSION_STRING
163(
164  sc_writer_policy default_writer_policy
165)
166{
167  SC_API_PERFORM_CHECK_( sc_writer_policy
168                          , default_writer_policy
169                          , "SC_DEFAULT_WRITER_POLICY" );
170}
171
172} // namespace sc_core
173
174// $Log: sc_ver.cpp,v $
175// Revision 1.14  2011/08/26 21:56:55  acg
176//  Torsten Maehne: use usings rather than absolute namespace addressing.
177//
178// Revision 1.13  2011/08/26 20:46:11  acg
179//  Andy Goodrich: moved the modification log to the end of the file to
180//  eliminate source line number skew when check-ins are done.
181//
182// Revision 1.12  2011/07/25 10:20:34  acg
183//  Andy Goodrich: check in aftermath of call to automake.
184//
185// Revision 1.11  2011/07/02 12:55:19  acg
186//  Andy Goodrich: automake refresh.
187//
188// Revision 1.10  2011/07/01 18:49:07  acg
189//  Andy Goodrich: moved pln() from sc_simcontext.cpp to sc_ver.cpp.
190//
191// Revision 1.9  2011/07/01 18:33:08  acg
192//  Andy Goodrich: changes for IEEE 1666, removal of macros and use of them.
193//
194// Revision 1.8  2011/04/08 18:27:53  acg
195//  Andy Goodrich: respin of the PoC.
196//
197// Revision 1.7  2011/04/05 20:50:57  acg
198//  Andy Goodrich:
199//    (1) changes to make sure that event(), posedge() and negedge() only
200//        return true if the clock has not moved.
201//    (2) fixes for method self-resumes.
202//    (3) added SC_PRERELEASE_VERSION
203//    (4) removed kernel events from the object hierarchy, added
204//        sc_hierarchy_name_exists().
205//
206// Revision 1.6  2011/02/18 20:27:14  acg
207//  Andy Goodrich: Updated Copyrights.
208//
209// Revision 1.5  2011/02/13 21:47:38  acg
210//  Andy Goodrich: update copyright notice.
211//
212// Revision 1.4  2011/01/18 20:10:45  acg
213//  Andy Goodrich: changes for IEEE1666_2011 semantics.
214//
215// Revision 1.3  2010/11/20 17:10:57  acg
216//  Andy Goodrich: reset processing changes for new IEEE 1666 standard.
217//
218// Revision 1.2  2008/05/22 17:06:27  acg
219//  Andy Goodrich: updated copyright notice to include 2008.
220//
221// Revision 1.1.1.1  2006/12/15 20:20:05  acg
222// SystemC 2.3
223//
224// Revision 1.3  2006/01/13 18:44:30  acg
225// Added $Log to record CVS changes into the source.
226//
227
228// Taf!
229