00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
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;
00062 static char** argv_copy;
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
00099 sc_in_action = true;
00100
00101 status = sc_main( argc, argv );
00102
00103
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
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 }