Changeset 41 for sources/src
- Timestamp:
- Aug 24, 2009, 1:11:00 PM (15 years ago)
- Location:
- sources/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/Makefile.am
r34 r41 38 38 39 39 libsystemc_la_LIBADD = libgen_code.la $(ALLIANCE_LIBS) 40 libsystemc_la_CXXFLAGS = @ALLIANCE_CFLAGS@ $(CXXFLAGS)40 libsystemc_la_CXXFLAGS = @ALLIANCE_CFLAGS@ @OPENMP_CFLAGS@ $(CXXFLAGS) 41 41 42 42 noinst_LTLIBRARIES = libgen_code.la 43 43 libgen_code_la_SOURCES = gen_code.cc 44 libgen_code_la_CXXFLAGS=-DGENERATED_MODULE_CFLAGS='"$(CXXFLAGS) -I$(prefix)/include"' 44 libgen_code_la_CXXFLAGS=-DGENERATED_MODULE_CFLAGS='"$(CXXFLAGS) -I$(prefix)/include"' @OPENMP_CFLAGS@ 45 45 46 46 include_HEADERS = alias.h casc.h data_field.h fsm_rules.h global_functions.h internal_ext.h module_hierarchy_ext.h port_dependency_ext.h sc_bigint.h sc_biguint.h sc_bit.h sc_bv.h sc_clock_ext.h sc_event.h sc_fwd.h sc_int.h sc_interface.h sc_localvar.h sc_logic.h sc_lv.h sc_module_ext.h sc_module_name.h sc_nbdefs.h sc_numrep.h sc_object.h sc_pat_trace.h sc_port_ext.h sc_sensitive.h sc_signal.h sc_signed.h sc_string.h sc_time.h sc_trace_ext.h sc_uint.h sc_unit.h sc_unsigned.h sc_vcd_trace.h sc_ver_ext.h serialization_ext.h systemc systemc.h systemcass_version_ext.h -
sources/src/gen_code.cc
r38 r41 54 54 #endif 55 55 56 #ifdef _OPENMP 57 #include <omp.h> 58 #endif 59 56 60 #ifdef CONFIG_CHECK_FSM_RULES 57 61 #include "fsm_rules.h" … … 107 111 const method_process_t &m) 108 112 { 109 SC_ENTRY_FUNC func 113 SC_ENTRY_FUNC func = m.func; 110 114 if (print_schedule) 111 115 o << " fprintf(stderr,\"evaluation de " 112 116 << m.module->name() << "->" << m.name << "()\\n\");\n"; 113 117 o << " p.integer = " << func << ";\n"; 114 118 #ifdef CPP_CALL 115 119 o << " (((sc_module*)(" << m.module << "))->*(p.pmf)) (); /* " 116 120 << m.module->name () << "->" << m.name << "() */\n"; 117 121 #else 118 122 o << " p.pf((void *)" 119 120 123 << m.module << "); /* " 124 << m.module->name () << "->" << m.name << "() */\n"; 121 125 #endif 122 126 } … … 145 149 void 146 150 open_temp (ofstream &o, 147 151 char *temp) 148 152 { 149 153 /* 150 151 154 srand (time (NULL)); 155 int r = rand () % 1000; 152 156 */ 153 157 pid_t pid = getpid(); 154 158 int r = -1; 155 156 159 do { 160 sprintf (temp, "%s/scheduling-%d-%x.cc", temporary_dir, pid, ++r); 157 161 } while (is_exist (temp)); 158 162 159 163 o.open (temp,ios::out); 160 164 if (o.is_open () == false) 161 165 { 162 166 cerr << "Error : Unable to open a file to write scheduling code.\n"; 163 167 exit (30032005); 164 168 } … … 176 180 method_process_list_t &transition_func_list) 177 181 { 178 182 // transitions 179 183 o << "\ninline void transition(void)\n{\n"; 180 184 if (transition_func_list.empty () == false) { 181 185 o << " /* fonctions de transition */\n" 182 183 186 << " register fct p;\n"; 187 method_process_list_t::iterator mm; 184 188 for( mm = transition_func_list.begin(); mm != transition_func_list.end(); ++mm) 185 189 { 186 190 PrintCall (o, **mm); 187 191 } 188 192 } 189 193 o << "}\n"; 190 194 } … … 195 199 method_process_list_t &moore_func_list) 196 200 { 197 201 // Moore generations (sequential functions) 198 202 o << "\ninline void moore_generation (void)\n{\n"; 199 200 201 202 203 if (moore_func_list.empty () == false) { 204 o << " /* fonctions de generation de Moore */\n" 205 << " register fct p;\n"; 206 method_process_list_t::reverse_iterator mm; 203 207 for( mm = moore_func_list.rbegin(); mm != moore_func_list.rend(); ++mm) 204 208 { … … 214 218 strong_component_list_t &strongcomponents) 215 219 { 216 220 // Mealy generations (combinational functions only) 217 221 o << "\nextern void mealy_generation (void)\n{\n"; 218 222 if (strongcomponents.empty ()) 219 223 return NULL; 220 221 224 o << " register fct p;\n" 225 << "\n\n /* fonctions de mealy */\n"; 222 226 #ifdef NO_STATIC_SCHEDULE 223 227 o << "\n do {\n unstable = 0;\n"; … … 227 231 if ( (*ss)->size() == 1) { 228 232 /* un seul element dans le strong component */ 229 233 method_process_t *m = (method_process_t*)(*((*ss)->begin ())); 230 234 PrintCall (o, *m); 231 235 continue; … … 237 241 component_list_t::reverse_iterator rev_mm; 238 242 for( rev_mm = (*ss)->rbegin(); rev_mm != (*ss)->rend(); ++rev_mm) { 239 243 method_process_t *m = (method_process_t*) *rev_mm; 240 244 PrintCall (o, *m); 241 245 } … … 257 261 ProcessDependencyList &mealy_func_list) 258 262 { 259 263 // Mealy generations (combinational functions only) 260 264 o << "\nextern void mealy_generation (void)\n{\n"; 261 265 o << " register fct p;\n" … … 301 305 << pmf_type 302 306 << " integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n"; 303 304 gen_transition (o, transition_func_list); 305 gen_moore (o, moore_func_list); 307 308 gen_transition (o, transition_func_list); 309 gen_moore (o, moore_func_list); 306 310 gen_mealy (o, strongcomponents); 307 311 … … 310 314 311 315 o.flush (); 312 313 314 316 o.close (); 317 318 // add "cc" extension 315 319 char file_name[PATH_MAX]; 316 320 strncpy(file_name, base_name, PATH_MAX); … … 337 341 cerr << "Generating C code for scheduling...\n"; 338 342 339 340 343 // open temporary file 344 ofstream o; 341 345 char base_name[PATH_MAX]; 342 346 open_temp (o, base_name); 343 347 344 348 if (! o.good ()) { 345 349 perror("scheduling: open file\n"); 346 350 exit(-1); … … 348 352 349 353 o << "// generated by " << sc_version () << endl 350 351 352 // 353 354 << "#include <casc.h>\n\n" 355 << "#include <cstdio>\n\n" 356 // << "#include <iostream>\n\n" 357 << "namespace sc_core {\n" 354 358 << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n" 355 359 << " typedef void (*CASC_ENTRY_FUNC)(void *);\n" 356 360 << " typedef union { unsigned long long int integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n"; 357 358 gen_transition (o, transition_func_list); 359 gen_moore (o, moore_func_list); 361 362 gen_transition (o, transition_func_list); 363 gen_moore (o, moore_func_list); 360 364 gen_mealy (o, mealy_func_list); 361 365 … … 364 368 365 369 o.flush (); 366 367 368 370 o.close (); 371 372 // add "cc" extension 369 373 char file_name[PATH_MAX]; 370 374 strncpy(file_name, base_name, PATH_MAX); … … 395 399 const char *systemc_dir = getenv ("SYSTEMCASS"); 396 400 // const char *target_arch = getenv ("TARGET_ARCH"); 397 401 const char *default_compiler = 398 402 #ifdef CPP_CALL 399 403 "g++"; 400 404 #else 401 405 "gcc"; 402 406 #endif 403 407 404 408 compiler = (compiler == NULL)?default_compiler:compiler; 405 409 if (systemc_dir == NULL) { 406 410 systemc_dir = getenv ("SYSTEMC"); 407 411 if (systemc_dir == NULL) { 408 412 cerr << "Error : set SYSTEMCASS or SYSTEMC environnement variable " 409 413 "to the SYSTEMCASS directory.\n"; 410 414 exit (-1); 411 415 } 412 416 } 413 417 //target_arch = (target_arch == NULL)?"":target_arch; 414 418 … … 439 443 const char *commandline_template = 440 444 #if defined(CONFIG_OS_DARWIN) 441 445 "(cd %s ;" " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)" 442 446 #elif defined(CONFIG_OS_LINUX) 443 447 "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)" 444 448 #else 445 446 #endif 447 449 "(cd %s ;" " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)" 450 #endif 451 ; 448 452 449 453 string cflags = casc_cflags; … … 452 456 453 457 sprintf(compil_str, 454 455 456 457 458 459 460 458 commandline_template, 459 temporary_dir, 460 compiler, 461 cflags.c_str(), 462 systemc_dir, 463 target_name, 464 source_name); 461 465 462 466 if (dump_stage) … … 476 480 sprintf (source_name, "%s.lo", base_name); 477 481 sprintf(compil_str, "(cd %s ; pwd ; libtool --mode=link %s %s -module -shared -o %s %s -rpath /tmp)", /* -L. -L%s/lib-%s */ 478 482 temporary_dir, compiler, casc_cflags, /*systemc_dir, target_arch,*/ 479 483 target_name, source_name); 480 484 #else 481 485 sprintf (source_name, "%s.o", base_name); 482 486 sprintf(compil_str, "(cd %s ; pwd ; libtool -dynamic -o %s %s)", 483 487 temporary_dir, target_name, source_name); 484 488 #endif 485 489 … … 538 542 pf.function = (fct*) malloc (sizeof (fct) * pf.func_number); 539 543 pf.instance = (void**) malloc (sizeof (void*) * pf.func_number); 540 544 ProcessDependencyList::iterator it; 541 545 int i; 542 543 544 546 for (i = 0, it = func_list.begin(); it != func_list.end(); ++it, ++i) 547 { 548 const method_process_t *mp = *it; 545 549 pf.function[i].pmf = (mp->func); 546 550 pf.instance[i] = (void*)(mp->module); … … 580 584 } 581 585 586 void 587 call_functions_in_parallel (function_call &fc) 588 { 589 int n = fc.func_number; 590 int i; 591 #pragma omp parallel for 592 for (i = 0; i < n; ++i) 593 { 594 #if 0 //defined(CONFIG_DEBUG) 595 sc_module *m = (sc_module*)(fc.instance[i]); 596 cerr << m->name () << endl; 597 cerr << "thread #" << omp_get_thread_num () << endl; 598 #endif 599 fc.function[i].pf (fc.instance[i]); 600 } 601 } 602 582 603 void static_mealy_generation () 583 604 { … … 595 616 casc_fsm_step = GEN_MOORE; 596 617 #endif 597 call_functions (pf[1]); // moore generation618 call_functions_in_parallel (pf[1]); // moore generation 598 619 #ifdef CONFIG_CHECK_FSM_RULES 599 620 casc_fsm_step = GEN_MEALY; … … 621 642 (mod->*func) (); 622 643 } 644 623 645 void quasistatic_mealy_generation () 624 646 { … … 627 649 if ( (*ss)->size() == 1) { 628 650 /* un seul element dans le strong component */ 629 651 method_process_t *m = (method_process_t*)(*((*ss)->begin ())); 630 652 Call (*m); 631 653 continue; … … 636 658 component_list_t::reverse_iterator rev_mm; 637 659 for( rev_mm = (*ss)->rbegin(); rev_mm != (*ss)->rend(); ++rev_mm) { 638 660 method_process_t *m = (method_process_t*) *rev_mm; 639 661 Call (*m); 640 662 }
Note: See TracChangeset
for help on using the changeset viewer.