sc_main_main.cpp

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-2006 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.4 (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_main_main.cpp - Wrapper around user's toplevel routine `sc_main'.
00021 
00022   Original Author: Andy Goodrich, Forte Design Systems
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 
00037 // $Log: sc_main_main.cpp,v $
00038 // Revision 1.1.1.1  2006/12/15 20:31:37  acg
00039 // SystemC 2.2
00040 //
00041 // Revision 1.4  2006/01/25 00:31:19  acg
00042 //  Andy Goodrich: Changed over to use a standard message id of
00043 //  SC_ID_IEEE_1666_DEPRECATION for all deprecation messages.
00044 //
00045 // Revision 1.3  2006/01/13 18:44:29  acg
00046 // Added $Log to record CVS changes into the source.
00047 //
00048 
00049 #include "sysc/kernel/sc_cmnhdr.h"
00050 #include "sysc/kernel/sc_externs.h"
00051 #include "sysc/utils/sc_iostream.h"
00052 #include "sysc/utils/sc_report.h"
00053 #include "sysc/utils/sc_report_handler.h"
00054 
00055 #include <exception>
00056 
00057 namespace sc_core {
00058 
00059 extern void pln();
00060 
00061 static int    argc_copy;    // Copy of argc value passed to sc_elab_and_sim.
00062 static char** argv_copy;    // Copy of argv value passed to sc_elab_and_sim.
00063 
00064 static
00065 inline
00066 void
00067 message_function( const char* s )
00068 {
00069     ::std::cout << "\n" << s << ::std::endl;
00070 }
00071 
00072 bool sc_in_action = false;
00073 
00074 int sc_argc() 
00075 {
00076     return argc_copy;
00077 }
00078 
00079 const char* const* sc_argv() 
00080 {
00081     return argv_copy;
00082 }
00083 
00084 
00085 int
00086 sc_elab_and_sim( int argc, char* argv[] )
00087 {
00088     int status = 0;
00089     argc_copy = argc;
00090     argv_copy = new char*[argc];
00091     for ( int i = 0; i < argc; i++ ) 
00092     argv_copy[i] = argv[i];
00093 
00094     try
00095     {
00096         pln();
00097 
00098         // Perform initialization here
00099         sc_in_action = true;
00100 
00101         status = sc_main( argc, argv );
00102 
00103         // Perform cleanup here
00104         sc_in_action = false;
00105     }
00106     catch( const sc_report& x )
00107     {
00108         message_function( x.what() );
00109     }
00110     catch( const char* s )
00111     {
00112         message_function( s );
00113     }
00114     catch (std::exception& e) {
00115       message_function("Exception caught");
00116     }
00117     catch( ... )
00118     {
00119         message_function( "UNKNOWN EXCEPTION OCCURED" );
00120     }
00121 
00122     // IF DEPRECATION WARNINGS WERE ISSUED TELL THE USER HOW TO TURN THEM OFF 
00123 
00124     if ( sc_report_handler::get_count("/IEEE_Std_1666/deprecated") > 0 )
00125     {
00126         SC_REPORT_INFO("/IEEE_Std_1666/deprecated",
00127           "You can turn off warnings about\n" \
00128           "             IEEE 1666 deprecated features by placing this method " \
00129           "call as the\n" \
00130           "             first statement in your sc_main() function:\n" \
00131           "\n  sc_report_handler::set_actions(\"/IEEE_Std_1666/deprecated\", " \
00132           "SC_DO_NOTHING);\n\n" );
00133     }
00134 
00135     delete [] argv_copy;
00136     return status;
00137 }
00138 
00139 } // namespace sc_core

Generated on Wed Jan 21 15:32:09 2009 for SystemC by  doxygen 1.5.5