Changeset 52 for sources/src/sc_main.cc
- Timestamp:
- Jan 22, 2013, 4:23:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/sc_main.cc
r42 r52 54 54 #endif 55 55 56 // 56 57 57 using namespace std; 58 58 using namespace sc_core; 59 // 60 typedef list<sc_module * >module_list_t;61 62 // 59 60 typedef list<sc_module *> module_list_t; 61 62 63 63 namespace sc_core { 64 64 65 bool 65 bool check_port_dependencies = false; 66 66 #ifdef CONFIG_DEFAULT_RUNTIME_COMPILATION 67 bool 67 bool dynamic_link_of_scheduling_code = true; 68 68 #else 69 bool 70 #endif 71 bool dump_netlist_info= false;72 bool dump_funclist_info= false;73 bool dump_stage= false;74 bool dump_all_graph= false;75 const char * dump_module_hierarchy= NULL;76 bool edit_schedule= false;77 bool keep_generated_code= false;78 bool nobanner= false;79 bool noinitialization= false;80 bool nosimulation= false;81 bool notrace= false;82 bool print_schedule= false;83 bool print_user_resources= false;84 char * save_on_exit= NULL;85 int scheduling_method= NO_SCHEDULING;86 bool use_sensitivity_list= false;87 bool use_port_dependency= false;69 bool dynamic_link_of_scheduling_code = false; 70 #endif 71 bool dump_netlist_info = false; 72 bool dump_funclist_info = false; 73 bool dump_stage = false; 74 bool dump_all_graph = false; 75 const char * dump_module_hierarchy = NULL; 76 bool edit_schedule = false; 77 bool keep_generated_code = false; 78 bool nobanner = false; 79 bool noinitialization = false; 80 bool nosimulation = false; 81 bool notrace = false; 82 bool print_schedule = false; 83 bool print_user_resources = false; 84 char * save_on_exit = NULL; 85 int scheduling_method = NO_SCHEDULING; 86 bool use_sensitivity_list = false; 87 bool use_port_dependency = false; 88 88 89 89 #ifdef _OPENMP 90 bool use_openmp= true;90 bool use_openmp = true; 91 91 #else 92 bool use_openmp = false; 93 #endif 94 95 const char *HELP_STRING = \ 92 bool use_openmp = false; 93 #endif 94 95 96 const char * HELP_STRING = \ 96 97 "\n" 97 98 "--a\n" … … 169 170 170 171 171 static 172 void 173 print_splash_screen () 174 { 175 // Display once 176 if (nobanner == false) 177 cerr << get_splash_screen (); 178 nobanner = true; 172 173 static void print_splash_screen() { 174 // Display once 175 if (nobanner == false) { 176 cerr << get_splash_screen (); 177 } 178 nobanner = true; 179 179 } 180 180 181 static 182 void 183 check_parameters () 184 { 185 if (dump_all_graph) { 186 if (use_port_dependency) 187 cerr << "SystemCASS will dump signal dependency graph.\n"; 188 else 189 cerr << "SystemCASS will dump module dependency graph.\n"; 190 } 191 if (!use_port_dependency && check_port_dependencies) 192 cerr << "Warning : unable to check port dependencies.\n"; 193 if (!use_port_dependency) 194 { 195 use_sensitivity_list = true; 196 scheduling_method = CASS_SCHEDULING; 197 } 198 switch (scheduling_method) { 199 case CASS_SCHEDULING : 200 assert(use_port_dependency == false); 201 break; 202 case BUCHMANN_SCHEDULING : 203 case MOUCHARD_SCHEDULING : 181 182 static void check_parameters() { 183 if (dump_all_graph) { 184 if (use_port_dependency) { 185 cerr << "SystemCASS will dump signal dependency graph.\n"; 186 } 187 else { 188 cerr << "SystemCASS will dump module dependency graph.\n"; 189 } 190 } 191 if (!use_port_dependency && check_port_dependencies) { 192 cerr << "Warning : unable to check port dependencies.\n"; 193 } 204 194 if (!use_port_dependency) { 205 cerr << "Error : " 206 "The choosen scheduling needs port dependencies informations\n"; 207 exit (31); 208 } 209 break; 210 default : 211 cerr << "Error : You need to choose one of the available scheduling :\n" 212 << "- Almost static scheduling like CASS (use sensitivity list)\n" 213 << "- Simple static scheduling (use port dependencies)\n" 214 << "- Entirely static scheduling (use port dependencies)\n"; 215 exit (33); 216 } 217 assert(use_port_dependency || use_sensitivity_list); 195 use_sensitivity_list = true; 196 scheduling_method = CASS_SCHEDULING; 197 } 198 switch (scheduling_method) { 199 case CASS_SCHEDULING : 200 assert(use_port_dependency == false); 201 break; 202 case BUCHMANN_SCHEDULING : 203 case MOUCHARD_SCHEDULING : 204 if (!use_port_dependency) { 205 cerr << "Error : " 206 "The choosen scheduling needs port dependencies informations\n"; 207 exit (31); 208 } 209 break; 210 default : 211 cerr << "Error : You need to choose one of the available scheduling :\n" 212 << "- Almost static scheduling like CASS (use sensitivity list)\n" 213 << "- Simple static scheduling (use port dependencies)\n" 214 << "- Entirely static scheduling (use port dependencies)\n"; 215 exit (33); 216 } 217 assert(use_port_dependency || use_sensitivity_list); 218 218 } 219 219 220 void 221 apply_parameters (int &argc, char ** &argv) 222 { 220 221 void apply_parameters(int & argc, char ** &argv) { 223 222 #ifdef KEEP_GENERATED_CODE // supprimer scheduling-XXXXXX.cc 224 keep_generated_code = true;223 keep_generated_code = true; 225 224 #endif 226 225 #ifdef DUMP_NETLIST_INFO 227 dump_netlist_info = true;226 dump_netlist_info = true; 228 227 #endif 229 228 #ifdef DUMP_FUNCLIST_INFO 230 dump_funclist_info = true;229 dump_funclist_info = true; 231 230 #endif 232 231 #ifdef DUMP_STAGE 233 dump_stage = true;232 dump_stage = true; 234 233 #endif 235 234 #ifdef DUMP_COMBINATIONAL_LIST2DOT 236 dump_all_graph = true;235 dump_all_graph = true; 237 236 #endif 238 237 #ifdef PRINT_SCHEDULE 239 print_schedule = true;238 print_schedule = true; 240 239 #endif 241 240 #ifdef USE_PORT_DEPENDENCY 242 use_port_dependency = true; 243 #endif 244 // parse the command line 245 int i; 246 for (i = 1; i < argc; ++i) 247 { 248 if (argv[i][0] == '-') 249 { 250 if (argv[i][1] == '-') 251 { 252 switch (argv[i][2]) 253 { 254 case 'h' : 255 print_splash_screen (); 256 cerr << "Usage : " 257 << argv[0] << " [--c] [--edit] [--d] [--f] [--h] [--i] [--k] [--modules filename] [--nobanner] [--[no]dynamiclink] [--nosim] [--notrace] [--s] [--t] [--tracestart n] [--usage] [--v] [--p|m|a] [others parameters processed by sc_main]\n" 258 << "Thoses options are processed by SystemCASS library. All the remaining options are passed to sc_main.\n" 259 << "sc_main function retrieves last parameters.\n" 260 << HELP_STRING; 261 noinitialization = true; 262 nosimulation = true; 263 continue; 264 case 'v' : 265 print_splash_screen (); 266 cerr << get_used_options () << "\n"; 267 cerr << get_used_env () << "\n"; 268 cerr << sc_version () << "\n\n"; 269 exit (0); 270 case 'u' : 271 if (strcmp (argv[i]+2, "usage") == 0) 272 print_user_resources = true; 273 else 274 break; 275 continue; 276 case 'i' : 277 dump_netlist_info = true; 278 continue; 279 case 'f' : 280 dump_funclist_info = true; 281 continue; 282 case 's' : 283 if (strcmp (argv[i]+2, "save_on_exit") == 0) 284 save_on_exit = argv[++i]; 285 else 286 dump_stage = true; 287 continue; 288 case 'c' : 289 print_schedule = true; 290 continue; 291 case 'd' : 292 if (strcmp (argv[i]+2, "dynamiclink") == 0) 293 dynamic_link_of_scheduling_code = true; 294 else 295 check_port_dependencies = true; 296 continue; 297 case 'e' : 298 if (strcmp (argv[i]+2, "edit") == 0) 299 edit_schedule = true; 300 else 301 break; 302 continue; 303 case 'k' : 304 keep_generated_code = true; 305 continue; 306 case 't' : 307 if (strcmp (argv[i]+2, "tracestart") == 0) { 308 ++i; 309 istringstream iss (argv[i]); 310 iss >> trace_start; 311 trace_start <<= 1; 312 // trace_start = strtoll (argv[i],0,10) << 1; 313 // trace_start = atoll (argv[i]) << 1; 314 } else { 315 dump_all_graph = true; 241 use_port_dependency = true; 242 #endif 243 // parse the command line 244 int i; 245 for (i = 1; i < argc; ++i) { 246 if (argv[i][0] == '-') { 247 if (argv[i][1] == '-') { 248 switch (argv[i][2]) { 249 case 'h' : 250 print_splash_screen(); 251 cerr << "Usage : " 252 << argv[0] << " [--c] [--edit] [--d] [--f] [--h] [--i] [--k] [--modules filename] [--nobanner] [--[no]dynamiclink] [--nosim] [--notrace] [--s] [--t] [--tracestart n] [--usage] [--v] [--p|m|a] [others parameters processed by sc_main]\n" 253 << "Thoses options are processed by SystemCASS library. All the remaining options are passed to sc_main.\n" 254 << "sc_main function retrieves last parameters.\n" 255 << HELP_STRING; 256 noinitialization = true; 257 nosimulation = true; 258 continue; 259 case 'v' : 260 print_splash_screen (); 261 cerr << get_used_options () << "\n"; 262 cerr << get_used_env () << "\n"; 263 cerr << sc_version () << "\n\n"; 264 exit (0); 265 case 'u' : 266 if (strcmp (argv[i] + 2, "usage") == 0) { 267 print_user_resources = true; 268 } 269 else { 270 break; 271 } 272 continue; 273 case 'i' : 274 dump_netlist_info = true; 275 continue; 276 case 'f' : 277 dump_funclist_info = true; 278 continue; 279 case 's' : 280 if (strcmp (argv[i] + 2, "save_on_exit") == 0) { 281 save_on_exit = argv[++i]; 282 } 283 else { 284 dump_stage = true; 285 } 286 287 continue; 288 case 'c' : 289 print_schedule = true; 290 continue; 291 case 'd' : 292 if (strcmp (argv[i] + 2, "dynamiclink") == 0) { 293 dynamic_link_of_scheduling_code = true; 294 } 295 else { 296 check_port_dependencies = true; 297 } 298 continue; 299 case 'e' : 300 if (strcmp (argv[i] + 2, "edit") == 0) { 301 edit_schedule = true; 302 } 303 else { 304 break; 305 } 306 continue; 307 case 'k' : 308 keep_generated_code = true; 309 continue; 310 case 't' : 311 if (strcmp (argv[i] + 2, "tracestart") == 0) { 312 ++i; 313 istringstream iss (argv[i]); 314 iss >> trace_start; 315 trace_start <<= 1; 316 // trace_start = strtoll (argv[i],0,10) << 1; 317 // trace_start = atoll (argv[i]) << 1; 318 } 319 else { 320 dump_all_graph = true; 321 } 322 continue; 323 case 'm' : 324 if (strcmp (argv[i] + 2, "modules") == 0) { 325 ++i; 326 dump_module_hierarchy = argv[i]; 327 continue; 328 } 329 else if (strcmp (argv[i] + 2, "m") == 0) { 330 use_port_dependency = true; 331 scheduling_method = MOUCHARD_SCHEDULING; 332 continue; 333 } 334 break; 335 case 'n' : 336 if (strcmp (argv[i] + 2, "nobanner") == 0) { 337 nobanner = true; 338 } 339 else if (strcmp (argv[i] + 2, "nodynamiclink") == 0) { 340 dynamic_link_of_scheduling_code = false; 341 } 342 else if (strcmp (argv[i] + 2, "nosim") == 0) { 343 nosimulation = true; 344 } 345 else if (strcmp (argv[i] + 2, "notrace") == 0) { 346 notrace = true; 347 } 348 else { 349 break; 350 } 351 continue; 352 case 'a' : 353 use_sensitivity_list = true; 354 scheduling_method = CASS_SCHEDULING; 355 continue; 356 case 'p' : 357 use_port_dependency = true; 358 scheduling_method = BUCHMANN_SCHEDULING; 359 continue; 360 default : 361 break; 362 } 363 break; 316 364 } 317 continue; 318 case 'm' : 319 if (strcmp (argv[i]+2, "modules") == 0) { 320 ++i; 321 dump_module_hierarchy = argv[i]; 322 continue; 323 } else if (strcmp (argv[i]+2, "m") == 0) { 324 use_port_dependency = true; 325 scheduling_method = MOUCHARD_SCHEDULING; 326 continue; 327 } 328 break; 329 case 'n' : 330 if (strcmp (argv[i]+2, "nobanner") == 0) { 331 nobanner = true; 332 } else if (strcmp (argv[i]+2, "nodynamiclink") == 0) { 333 dynamic_link_of_scheduling_code = false; 334 } else if (strcmp (argv[i]+2, "nosim") == 0) { 335 nosimulation = true; 336 } else if (strcmp (argv[i]+2, "notrace") == 0) { 337 notrace = true; 338 } else 339 break; 340 continue; 341 case 'a' : 342 use_sensitivity_list = true; 343 scheduling_method = CASS_SCHEDULING; 344 continue; 345 case 'p' : 346 use_port_dependency = true; 347 scheduling_method = BUCHMANN_SCHEDULING; 348 continue; 349 default : 350 break; 351 } 365 } 352 366 break; 367 } 368 369 // erase SystemCASS options from the command line and give it to the sc_main 370 if (i != 1) { 371 int j = 1; 372 while (i < argc) { 373 argv[j++] = argv[i++]; 353 374 } 354 } 355 break; 356 } 357 358 // erase SystemCASS options from the command line and give it to the sc_main 359 if (i != 1) 360 { 361 int j = 1; 362 while (i < argc) 363 { 364 argv[j++] = argv[i++]; 365 } 366 argc = j; 367 } 368 #if 0 369 cerr << "The user command line length is " << argc << ".\n"; 370 #endif 375 argc = j; 376 } 371 377 } 372 378 … … 374 380 } // end of namespace 375 381 382 376 383 using namespace sc_core; 377 384 378 int 379 main(int argc, 380 char* argv[]) 381 { 382 apply_parameters (argc, argv); 383 print_splash_screen (); 384 check_parameters (); 385 386 if (noinitialization) 387 { 388 return 255; 389 } 390 391 int ret = sc_main(argc, argv); 392 free (pending_write_vector); 393 close_systemcass (); 394 395 if (have_to_stop) 396 { 397 cerr << "'sc_stop' function was called. Exit code : 1\n"; 398 return 1; 399 } 400 401 return ret; 385 int main(int argc, char * argv[]) { 386 apply_parameters(argc, argv); 387 print_splash_screen(); 388 check_parameters(); 389 390 if (noinitialization) { 391 return 255; 392 } 393 394 int ret = sc_main(argc, argv); 395 free(pending_write_vector); 396 close_systemcass(); 397 398 if (have_to_stop) { 399 cerr << "'sc_stop' function was called. Exit code : 1\n"; 400 return 1; 401 } 402 403 return ret; 402 404 } 403 405 406 /* 407 # Local Variables: 408 # tab-width: 4; 409 # c-basic-offset: 4; 410 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 411 # indent-tabs-mode: nil; 412 # End: 413 # 414 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 415 */ 416
Note: See TracChangeset
for help on using the changeset viewer.