Index: sources/src/Makefile.am
===================================================================
--- sources/src/Makefile.am	(revision 40)
+++ sources/src/Makefile.am	(revision 41)
@@ -38,9 +38,9 @@
 
 libsystemc_la_LIBADD = libgen_code.la $(ALLIANCE_LIBS)
-libsystemc_la_CXXFLAGS = @ALLIANCE_CFLAGS@ $(CXXFLAGS)
+libsystemc_la_CXXFLAGS = @ALLIANCE_CFLAGS@ @OPENMP_CFLAGS@ $(CXXFLAGS)
 
 noinst_LTLIBRARIES =  libgen_code.la
 libgen_code_la_SOURCES = gen_code.cc
-libgen_code_la_CXXFLAGS=-DGENERATED_MODULE_CFLAGS='"$(CXXFLAGS) -I$(prefix)/include"'
+libgen_code_la_CXXFLAGS=-DGENERATED_MODULE_CFLAGS='"$(CXXFLAGS) -I$(prefix)/include"' @OPENMP_CFLAGS@
 
 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
Index: sources/src/gen_code.cc
===================================================================
--- sources/src/gen_code.cc	(revision 40)
+++ sources/src/gen_code.cc	(revision 41)
@@ -54,4 +54,8 @@
 #endif
 
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
 #ifdef CONFIG_CHECK_FSM_RULES
 #include "fsm_rules.h"
@@ -107,16 +111,16 @@
                    const method_process_t &m)
 {
-  SC_ENTRY_FUNC func	= m.func;
+  SC_ENTRY_FUNC func  = m.func;
   if (print_schedule)
     o << "    fprintf(stderr,\"evaluation de "
-	  	<< m.module->name() << "->" << m.name << "()\\n\");\n";
+      << m.module->name() << "->" << m.name << "()\\n\");\n";
   o << " p.integer = " << func << ";\n";
 #ifdef CPP_CALL
   o << " (((sc_module*)(" << m.module << "))->*(p.pmf)) (); /* " 
-		<< m.module->name () << "->" << m.name << "() */\n";
+    << m.module->name () << "->" << m.name << "() */\n";
 #else
   o << " p.pf((void *)" 
-	  << m.module << "); /* " 
-		<< m.module->name () << "->" << m.name << "() */\n";
+    << m.module << "); /* " 
+    << m.module->name () << "->" << m.name << "() */\n";
 #endif
 }
@@ -145,20 +149,20 @@
 void
 open_temp          (ofstream &o,
-		                char     *temp)
+                    char     *temp)
 {
 /*
-	srand (time (NULL));
-		int r = rand () % 1000;
+  srand (time (NULL));
+    int r = rand () % 1000;
 */
   pid_t pid = getpid();
   int r = -1;
-	do {
-		sprintf (temp, "%s/scheduling-%d-%x.cc", temporary_dir, pid, ++r);
+  do {
+    sprintf (temp, "%s/scheduling-%d-%x.cc", temporary_dir, pid, ++r);
   } while (is_exist (temp));
 
   o.open (temp,ios::out);
-	if (o.is_open () == false)
+  if (o.is_open () == false)
   {
-		cerr << "Error : Unable to open a file to write scheduling code.\n";
+    cerr << "Error : Unable to open a file to write scheduling code.\n";
     exit (30032005);
   }
@@ -176,15 +180,15 @@
                 method_process_list_t &transition_func_list)
 {
-	// transitions
+  // transitions
   o << "\ninline void transition(void)\n{\n";
   if (transition_func_list.empty () == false) {
     o << " /* fonctions de transition */\n"
-			<< " register fct p;\n";
-  	method_process_list_t::iterator mm;
+      << " register fct p;\n";
+    method_process_list_t::iterator mm;
     for( mm = transition_func_list.begin(); mm != transition_func_list.end(); ++mm)
     {
       PrintCall (o, **mm);
     }
-	}
+  }
   o << "}\n";
 }
@@ -195,10 +199,10 @@
            method_process_list_t &moore_func_list)
 {
-	// Moore generations (sequential functions)
+  // Moore generations (sequential functions)
   o << "\ninline void moore_generation (void)\n{\n";
-	if (moore_func_list.empty () == false) {
-		o << "  /* fonctions de generation de Moore */\n"
-		  << " register fct p;\n";
-  	method_process_list_t::reverse_iterator mm;
+  if (moore_func_list.empty () == false) {
+    o << "  /* fonctions de generation de Moore */\n"
+      << " register fct p;\n";
+    method_process_list_t::reverse_iterator mm;
     for( mm = moore_func_list.rbegin(); mm != moore_func_list.rend(); ++mm)
     {
@@ -214,10 +218,10 @@
            strong_component_list_t &strongcomponents)
 {
-	// Mealy generations (combinational functions only)
+  // Mealy generations (combinational functions only)
   o << "\nextern void mealy_generation (void)\n{\n";
-	if (strongcomponents.empty ())
+  if (strongcomponents.empty ())
     return NULL;
- 	o << "  register fct p;\n"
-	  << "\n\n  /* fonctions de mealy */\n";
+   o << "  register fct p;\n"
+    << "\n\n  /* fonctions de mealy */\n";
 #ifdef NO_STATIC_SCHEDULE
   o << "\n  do {\n    unstable = 0;\n";
@@ -227,5 +231,5 @@
     if ( (*ss)->size() == 1) {
       /* un seul element dans le strong component */
-			method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
+      method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
       PrintCall (o, *m);
       continue;
@@ -237,5 +241,5 @@
       component_list_t::reverse_iterator rev_mm;
       for( rev_mm = (*ss)->rbegin(); rev_mm != (*ss)->rend(); ++rev_mm) {
-				method_process_t *m = (method_process_t*) *rev_mm;
+        method_process_t *m = (method_process_t*) *rev_mm;
         PrintCall (o, *m);
       }
@@ -257,5 +261,5 @@
            ProcessDependencyList   &mealy_func_list)
 {
-	// Mealy generations (combinational functions only)
+  // Mealy generations (combinational functions only)
   o << "\nextern void mealy_generation (void)\n{\n";
   o << "  register fct p;\n"
@@ -301,7 +305,7 @@
     << pmf_type 
     << " integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n"; 
-	
-  gen_transition (o, transition_func_list);	
-  gen_moore      (o, moore_func_list);	
+  
+  gen_transition (o, transition_func_list);  
+  gen_moore      (o, moore_func_list);  
   gen_mealy      (o, strongcomponents);
 
@@ -310,7 +314,7 @@
  
   o.flush ();
-	o.close ();
-
-	// add "cc" extension
+  o.close ();
+
+  // add "cc" extension
   char file_name[PATH_MAX];
   strncpy(file_name, base_name, PATH_MAX);
@@ -337,10 +341,10 @@
     cerr << "Generating C code for scheduling...\n";
 
-	// open temporary file
-	ofstream o;
+  // open temporary file
+  ofstream o;
   char base_name[PATH_MAX];
-	open_temp (o, base_name);
+  open_temp (o, base_name);
  
-	if (! o.good ()) {
+  if (! o.good ()) {
     perror("scheduling: open file\n");
     exit(-1);
@@ -348,14 +352,14 @@
 
   o << "// generated by " << sc_version () << endl
-		<< "#include <casc.h>\n\n"
-		<< "#include <cstdio>\n\n"
-//		<< "#include <iostream>\n\n"
-		<< "namespace sc_core {\n"
+    << "#include <casc.h>\n\n"
+    << "#include <cstdio>\n\n"
+//    << "#include <iostream>\n\n"
+    << "namespace sc_core {\n"
     << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
-		<< " typedef void (*CASC_ENTRY_FUNC)(void *);\n"
+    << " typedef void (*CASC_ENTRY_FUNC)(void *);\n"
     << " typedef union { unsigned long long int integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n"; 
-	
-  gen_transition (o, transition_func_list);	
-  gen_moore      (o, moore_func_list);	
+  
+  gen_transition (o, transition_func_list);  
+  gen_moore      (o, moore_func_list);  
   gen_mealy      (o, mealy_func_list);
 
@@ -364,7 +368,7 @@
  
   o.flush ();
-	o.close ();
-  
-	// add "cc" extension
+  o.close ();
+  
+  // add "cc" extension
   char file_name[PATH_MAX];
   strncpy(file_name, base_name, PATH_MAX);
@@ -395,20 +399,20 @@
   const char *systemc_dir = getenv ("SYSTEMCASS");
 //  const char *target_arch = getenv ("TARGET_ARCH");
-	const char *default_compiler =
+  const char *default_compiler =
 #ifdef CPP_CALL
-		"g++";
+    "g++";
 #else
-		"gcc";
+    "gcc";
 #endif
 
   compiler = (compiler == NULL)?default_compiler:compiler;
-	if (systemc_dir == NULL) {
+  if (systemc_dir == NULL) {
     systemc_dir = getenv ("SYSTEMC");
     if (systemc_dir == NULL) {
-  		cerr << "Error : set SYSTEMCASS or SYSTEMC environnement variable "
+      cerr << "Error : set SYSTEMCASS or SYSTEMC environnement variable "
               "to the SYSTEMCASS directory.\n";
-	  	exit (-1);
+      exit (-1);
     }
-	}
+  }
   //target_arch = (target_arch == NULL)?"":target_arch;
   
@@ -439,11 +443,11 @@
   const char *commandline_template =
 #if defined(CONFIG_OS_DARWIN)
-	  "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)"
+    "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)"
 #elif defined(CONFIG_OS_LINUX)
-	  "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)"
+    "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)"
 #else
-	  "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)"
-#endif
-	  ;
+    "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)"
+#endif
+    ;
 
   string cflags = casc_cflags;
@@ -452,11 +456,11 @@
 
   sprintf(compil_str, 
-		  commandline_template,
-		  temporary_dir,
-		  compiler, 
-		  cflags.c_str(), 
-		  systemc_dir, 
-		  target_name,
-		  source_name);
+      commandline_template,
+      temporary_dir,
+      compiler, 
+      cflags.c_str(), 
+      systemc_dir, 
+      target_name,
+      source_name);
 
   if (dump_stage) 
@@ -476,10 +480,10 @@
   sprintf (source_name, "%s.lo", base_name);
   sprintf(compil_str, "(cd %s ; pwd ; libtool --mode=link %s %s -module -shared -o %s %s -rpath /tmp)", /* -L. -L%s/lib-%s */ 
-	   temporary_dir, compiler, casc_cflags, /*systemc_dir, target_arch,*/ 
+     temporary_dir, compiler, casc_cflags, /*systemc_dir, target_arch,*/ 
      target_name, source_name);
 #else
   sprintf (source_name, "%s.o", base_name);
   sprintf(compil_str, "(cd %s ; pwd ; libtool -dynamic -o %s %s)", 
-	   temporary_dir, target_name, source_name);
+     temporary_dir, target_name, source_name);
 #endif
 
@@ -538,9 +542,9 @@
   pf.function = (fct*)   malloc (sizeof (fct)   * pf.func_number);
   pf.instance = (void**) malloc (sizeof (void*) * pf.func_number);
-	ProcessDependencyList::iterator it;
+  ProcessDependencyList::iterator it;
   int i;
-	for (i = 0, it = func_list.begin(); it != func_list.end(); ++it, ++i)
-	{
-		const method_process_t *mp = *it;
+  for (i = 0, it = func_list.begin(); it != func_list.end(); ++it, ++i)
+  {
+    const method_process_t *mp = *it;
     pf.function[i].pmf = (mp->func);
     pf.instance[i] = (void*)(mp->module);
@@ -580,4 +584,21 @@
 }
 
+void
+call_functions_in_parallel (function_call &fc)
+{
+  int n = fc.func_number;
+  int i;
+  #pragma omp parallel for
+  for (i = 0; i < n; ++i)
+  {
+#if 0 //defined(CONFIG_DEBUG)
+    sc_module *m = (sc_module*)(fc.instance[i]);
+    cerr << m->name () << endl;
+    cerr << "thread #" << omp_get_thread_num () << endl;
+#endif
+    fc.function[i].pf (fc.instance[i]);
+  }
+}
+
 void static_mealy_generation ()
 {
@@ -595,5 +616,5 @@
   casc_fsm_step = GEN_MOORE;
 #endif
-  call_functions (pf[1]); // moore generation
+  call_functions_in_parallel (pf[1]); // moore generation
 #ifdef CONFIG_CHECK_FSM_RULES
   casc_fsm_step = GEN_MEALY;
@@ -621,4 +642,5 @@
   (mod->*func) ();
 }
+
 void quasistatic_mealy_generation ()
 {
@@ -627,5 +649,5 @@
     if ( (*ss)->size() == 1) {
       /* un seul element dans le strong component */
-			method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
+      method_process_t *m = (method_process_t*)(*((*ss)->begin ()));
       Call (*m);
       continue;
@@ -636,5 +658,5 @@
         component_list_t::reverse_iterator rev_mm;
         for( rev_mm = (*ss)->rbegin(); rev_mm != (*ss)->rend(); ++rev_mm) {
-		 	 	method_process_t *m = (method_process_t*) *rev_mm;
+          method_process_t *m = (method_process_t*) *rev_mm;
           Call (*m);
         }
