Index: sources/src/casc.h
===================================================================
--- sources/src/casc.h	(revision 64)
+++ sources/src/casc.h	(revision 65)
@@ -23,5 +23,5 @@
 
 EXTERN char unstable;
-EXTERN int32_t * pending_write_vector_nb;
+EXTERN int32_t *pending_write_vector_nb;
 #ifdef _OPENMP
 #pragma omp threadprivate (pending_write_vector_nb)
Index: sources/src/entity.cc
===================================================================
--- sources/src/entity.cc	(revision 64)
+++ sources/src/entity.cc	(revision 65)
@@ -395,46 +395,44 @@
     equi_list_t::iterator i;
     int index = 0;
-    for (i = equi_list.begin(); i != equi_list.end(); ++i) {
-        sc_interface *out = get_out_port(*i);
-        if (out) {
-            bind_equi_to_table(*i, out->get_pointer());
-        }
-        else {
-            sc_interface * reg = get_signal(*i);
-            if (reg == NULL) {
-                reg = get_localvar(*i);
-            }
-            if (reg) {
-                bind_equi_to_table(*i, reg->get_pointer());
-            }
-            else {
-                bind_equi_to_table(*i, &(equi_table[index]));
-                index += (i->begin()->data_size_in_bytes() - 1) / sizeof(tab_t) + 1;
-            }
-        }
-#if 0
-        sc_interface *reg = get_signal (*i);
-        sc_interface *out = get_out_port (*i);
-        if (reg) {
-            std::cerr << "binding " << *i << " to reg "
-                << reg << std::endl;
-            bind_equi_to_table (*i, reg->get_pointer ());
-        } else if (out) {
-            std::cerr << "binding " << *i << " to out "
-                << out << std::endl;
-            bind_equi_to_table (*i, out->get_pointer ());
-        } else {
-            reg = get_localvar (*i);
-            if (reg) {
-                std::cerr << "binding " << *i << " to localvar "
-                    << reg << std::endl;
-                bind_equi_to_table (*i, reg->get_pointer ());
-            } else {
-                std::cerr << "binding " << *i << " to index "
-                    << index << std::endl;
-                bind_equi_to_table (*i, &(equi_table[index]));
-                index += (i->begin()->data_size_in_bytes() - 1) / sizeof(tab_t) + 1;
-            }
-        }
+    for (i = equi_list.begin (); i != equi_list.end (); ++i) 		{
+#if 1
+			sc_interface *out = get_out_port (*i);
+			if (out) {
+				bind_equi_to_table (*i, out->get_pointer ());
+			} else {
+				sc_interface *reg = get_signal (*i);
+				if (reg == NULL)
+          reg = get_localvar (*i);
+			 	if (reg) {
+          bind_equi_to_table (*i, reg->get_pointer ());
+				} else {
+	      	bind_equi_to_table (*i, &(equi_table[index]));
+				  index += (i->begin()->data_size_in_bytes() - 1) / sizeof(tab_t) + 1;
+				}
+			}
+#else
+			sc_interface *reg = get_signal (*i);
+			sc_interface *out = get_out_port (*i);
+			if (reg) {
+				std::cerr << "binding " << *i << " to reg "
+				    << reg << std::endl;
+				  bind_equi_to_table (*i, reg->get_pointer ());
+			} else if (out) {
+				std::cerr << "binding " << *i << " to out "
+				    << out << std::endl;
+				bind_equi_to_table (*i, out->get_pointer ());
+			} else {
+				reg = get_localvar (*i);
+			 	if (reg) {
+					std::cerr << "binding " << *i << " to localvar "
+					    << reg << std::endl;
+					  bind_equi_to_table (*i, reg->get_pointer ());
+				} else {
+					std::cerr << "binding " << *i << " to index "
+					    << index << std::endl;
+					bind_equi_to_table (*i, &(equi_table[index]));
+					index += (i->begin()->data_size_in_bytes() - 1) / sizeof(tab_t) + 1;
+				}
+			}
 #endif
     }
Index: sources/src/gen_code.cc
===================================================================
--- sources/src/gen_code.cc	(revision 64)
+++ sources/src/gen_code.cc	(revision 65)
@@ -50,6 +50,8 @@
 #include <fstream>
 #ifdef _OPENMP
-    #include <omp.h>
-#endif
+#include <omp.h>
+#endif
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "internal.h"
@@ -240,11 +242,12 @@
 }
 
-
-char * gen_scheduling_code_for_dynamic_link(method_process_list_t & transition_func_list,
-        method_process_list_t & moore_func_list,
-        strong_component_list_t * strongcomponents) {
-    if (dump_stage) {
-        cerr << "Generating C code for scheduling...\n";
-    }
+char *
+gen_scheduling_code_for_dynamic_link (
+               method_process_list_t           &transition_func_list,
+               method_process_list_t           &moore_func_list,
+               strong_component_list_t         *strongcomponents)
+{
+  if (dump_stage)
+    cerr << "Generating C code for scheduling...\n";
 
     // open temporary file
@@ -258,10 +261,11 @@
     }
 
-    o << "// generated by " << sc_version() << endl
-        << "#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";
+  o << "// generated by " << sc_version () << endl
+    << "#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";
 
     const char * pmf_type = get_pmf_type();
@@ -533,14 +537,15 @@
 }
 
-
-void call_functions_in_parallel(function_call & fc) {
-    int n = fc.func_number;
-    int i;
-    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;
+void
+call_functions_in_parallel (function_call &fc)
+{
+  int n = fc.func_number;
+  int i;
+  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]);
@@ -566,6 +571,6 @@
  */
 
-unsigned int nb_func[2];
-static method_process_t **func_list[2];
+unsigned int              nb_func[2];
+static method_process_t        **func_list[2];
 static strong_component_list_t quasistatic_list;
 
@@ -578,11 +583,12 @@
 #endif
 
-static void Call(const method_process_t & m) {
-    sc_module * mod = m.module;
-    SC_ENTRY_FUNC func = m.func;
-    //  CASC_ENTRY_FUNC   func = reinterpret_cast<CASC_ENTRY_FUNC> (m.func);
-    // QM
-    //cerr << "Exec " << mod->name() << "->" << m.name << endl;
-    (mod->*func) ();
+static 
+void
+Call         (const method_process_t &m)
+{
+  sc_module        *mod  = m.module;
+  SC_ENTRY_FUNC     func = m.func;
+//  CASC_ENTRY_FUNC   func = reinterpret_cast<CASC_ENTRY_FUNC> (m.func);
+  (mod->*func) ();
 }
 
@@ -620,22 +626,22 @@
 unsigned int num_omp_threads;
 
-void quasistatic_simulate_1_cycle(void) {
-    int i;
-
-    for (i = 0; i < nb_func[0]; ++i) {
-        Call(*(func_list[0][i]));
-    }
+void quasistatic_simulate_1_cycle (void) 
+{
+	int i;
+
+	for (i = 0; i < nb_func[0]; ++i)
+		Call (*(func_list[0][i]));
+#ifdef _OPENMP
 #define USE_BUSY_WAIT 1
-    update();
+#if 0
 #if USE_BUSY_WAIT
-    expected_globaltime += num_omp_threads;
-    if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) {
-        last_wait_up++;
-    }
-    __asm volatile("mfence");
-    while (globaltime < expected_globaltime) {
-        busy_wait_up++;
-        __asm volatile("lfence");
-    }
+	expected_globaltime += num_omp_threads;
+	if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime)
+		last_wait_f0++;
+	__asm volatile("mfence");
+	while (globaltime < expected_globaltime) {
+		busy_wait_f0++;
+		__asm volatile("lfence");
+	}
 #else
     #ifdef _OPENMP
@@ -643,19 +649,20 @@
     #endif
 #endif
-
-    for (i = 0; i < nb_func[1]; ++i) {
-        Call(*(func_list[1][i]));
-    }
-
+#endif
+#endif // _OPENMP
+
+	update();
+
+#ifdef _OPENMP
 #if USE_BUSY_WAIT
-    expected_globaltime += num_omp_threads;
-    if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) {
-        last_wait_f1++;
-    }
-    __asm volatile("mfence");
-    while (globaltime < expected_globaltime) {
-        busy_wait_f1++;
-        __asm volatile("lfence");
-    }
+	expected_globaltime += num_omp_threads;
+	if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime)
+		last_wait_up++;
+	__asm volatile("mfence");
+	while (globaltime < expected_globaltime) {
+		busy_wait_up++;
+		__asm volatile("lfence");
+	}
+
 #else
     #ifdef _OPENMP
@@ -663,21 +670,39 @@
     #endif
 #endif
-    if (!quasistatic_list.empty()) {
+#endif // _OPENMP
+
+	for (i = 0; i < nb_func[1]; ++i)
+		Call (*(func_list[1][i]));
+
 #ifdef _OPENMP
+#if USE_BUSY_WAIT
+	expected_globaltime += num_omp_threads;
+	if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime)
+		last_wait_f1++;
+	__asm volatile("mfence");
+	while (globaltime < expected_globaltime) {
+		busy_wait_f1++;
+		__asm volatile("lfence");
+	}
+#else
+#pragma omp barrier
+#endif
+#endif // _OPENMP
+
+	if (!quasistatic_list.empty()) {
 #pragma omp master
-#endif
-        {
-            quasistatic_mealy_generation();
-        }
+		{
+		quasistatic_mealy_generation ();
+		}
+#ifdef _OPENMP
 #if USE_BUSY_WAIT
-        expected_globaltime += num_omp_threads;
-        if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) {
-            last_wait_ml++;
-        }
-        __asm volatile("mfence");
-        while (globaltime < expected_globaltime) {
-            busy_wait_ml++;
-            __asm volatile("lfence");
-        }
+		expected_globaltime += num_omp_threads;
+		if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime)
+			last_wait_ml++;
+		__asm volatile("mfence");
+		while (globaltime < expected_globaltime) {
+			busy_wait_ml++;
+			__asm volatile("lfence");
+		}
 #else
     #ifdef _OPENMP
@@ -685,37 +710,36 @@
     #endif
 #endif
-    }
-}
-
-
-void gen_scheduling_code_for_quasistatic_func(method_process_list_t & transition_func_list,
-        method_process_list_t & moore_func_list,
-        strong_component_list_t * mealy_func_list) {
-    if (dump_stage) {
-        cerr << "Generating quasi static scheduling...\n";
-    }
-
-    nb_func[0] = transition_func_list.size();
-    nb_func[1] = moore_func_list.size();
-
-    func_list[0] = (method_process_t**) malloc(sizeof (method_process_t*) * nb_func[0]);
-    func_list[1] = (method_process_t**) malloc(sizeof (method_process_t*) * nb_func[1]);
-
-    unsigned int i;
-    for (i = 0; i < nb_func[0]; ++i) {
-        func_list[0][i] = (transition_func_list[i]);
-    }
-
-    for (i = 0; i < nb_func[1]; ++i) {
-        func_list[1][i] = (moore_func_list[i]);
-    }
-
-    if (mealy_func_list != NULL) {
-        quasistatic_list = *mealy_func_list;
-    }
-
-    if (dump_stage) {
-        cerr << "Generating quasi static scheduling done.\n";
-    }
+#endif // _OPENMP
+	}
+
+}
+
+void
+gen_scheduling_code_for_quasistatic_func (
+            method_process_list_t   &transition_func_list,
+            method_process_list_t   &moore_func_list,
+            strong_component_list_t *mealy_func_list)
+{
+  if (dump_stage)
+    cerr << "Generating quasi static scheduling...\n";
+
+  nb_func[0] = transition_func_list.size();
+  nb_func[1] = moore_func_list     .size();
+
+  func_list[0] = (method_process_t**) malloc (sizeof (method_process_t*) * nb_func[0]);
+  func_list[1] = (method_process_t**) malloc (sizeof (method_process_t*) * nb_func[1]);
+
+  unsigned int i;
+  for (i = 0; i < nb_func[0]; ++i)
+    func_list[0][i] = (transition_func_list[i]);
+
+  for (i = 0; i < nb_func[1]; ++i)
+    func_list[1][i] = (moore_func_list[i]);
+
+  if (mealy_func_list != NULL)
+    quasistatic_list = *mealy_func_list;
+
+  if (dump_stage)
+    cerr << "Generating quasi static scheduling done.\n";
 }
 } // end of sc_core namespace
Index: sources/src/gen_code.h
===================================================================
--- sources/src/gen_code.h	(revision 64)
+++ sources/src/gen_code.h	(revision 65)
@@ -42,12 +42,19 @@
 /* generate a scheduling code */
 extern void  gen_scheduling_code_for_quasistatic_func(
-      method_process_list_t   &transition_list,
-      method_process_list_t   &moore_list,
-      strong_component_list_t *mealy_list);
-
+                      method_process_list_t   &transition_list,
+                      method_process_list_t   &moore_list,
+	                    strong_component_list_t *mealy_list);
 extern void  gen_scheduling_code_for_static_func(
-      method_process_list_t   &transition_list,
-      method_process_list_t   &moore_list,
-      ProcessDependencyList   &mealy_list);
+                      method_process_list_t   &transition_list,
+                      method_process_list_t   &moore_list,
+	                    ProcessDependencyList   &mealy_list);
+extern char *gen_scheduling_code_for_dynamic_link(
+                      method_process_list_t   &transition_list,
+                      method_process_list_t   &moore_list,
+	                    ProcessDependencyList   &mealy_list);
+extern char *gen_scheduling_code_for_dynamic_link(
+                      method_process_list_t   &transition_list,
+                      method_process_list_t   &moore_list,
+	                    strong_component_list_t *strongcomponents);
 
 extern char * gen_scheduling_code_for_dynamic_link(
@@ -87,9 +94,9 @@
 #pragma omp master
     {
-        std::cerr << "begin of cycle #" << sc_simulation_time() << "\n";
-    }
-#endif
-
-	func_simulate_1_cycle();
+	std::cerr << "begin of cycle #" << sc_simulation_time () << "\n";
+    }
+#endif
+
+	func_simulate_1_cycle ();  
 
 	++nb_cycles;
@@ -97,22 +104,28 @@
 #pragma omp master
     {
-        std::cerr << "end of cycle\n";
+	std::cerr << "end of cycle\n";
     }
 #endif
 }
 
-inline void internal_sc_cycle1(int number_of_cycles) {  
-    extern unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml;
-    extern unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml;
-    extern unsigned int nb_func[2];
-    extern unsigned int expected_globaltime;
-    extern volatile unsigned int globaltime;
+inline void
+internal_sc_cycle1 (int number_of_cycles)
+{  
+
+extern unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml;
+extern unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml;
+extern unsigned int nb_func[2];
 #ifdef _OPENMP
 #pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml, nb_func)
 #pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml)
+#endif
+extern unsigned int expected_globaltime;
+extern volatile unsigned int globaltime;
+#ifdef _OPENMP
 #pragma omp threadprivate (expected_globaltime)
 #pragma omp shared (globaltime)
 #endif
-    extern unsigned int num_omp_threads;
+
+extern unsigned int num_omp_threads;
 
 
@@ -120,69 +133,63 @@
 #pragma omp parallel 
 #endif
-    {
-        int cyclecount = number_of_cycles;
-        busy_wait_f0 = busy_wait_f1 = busy_wait_up = busy_wait_ml = total_assig = 0;
-        last_wait_f0 = last_wait_f1 = last_wait_up = last_wait_ml = 0;
-
-        expected_globaltime = 0;
-#ifdef _OPENMP
-#pragma omp master
-#endif
-        {
-            globaltime = 0;
-#ifdef _OPENMP
-            num_omp_threads = omp_get_num_threads();
+  {
+	int cyclecount = number_of_cycles;
+	busy_wait_f0 = busy_wait_f1 = busy_wait_up = busy_wait_ml = total_assig = 0;
+	last_wait_f0 = last_wait_f1 = last_wait_up = last_wait_ml = 0;
+
+	expected_globaltime = 0;
+#ifdef _OPENMP
+#pragma omp master
+#endif
+    {
+	globaltime = 0;
+#ifdef _OPENMP
+  num_omp_threads = omp_get_num_threads();
 #else
-            num_omp_threads = 1;
-#endif
-        }
+  num_omp_threads = 1;
+#endif
+    }
 
 #ifdef _OPENMP
 #pragma omp barrier
 #endif
-        while (!(have_to_stop || cyclecount == 0)) {
-        //while (!(have_to_stop || number_of_cycles == 0)) {
-#ifdef _OPENMP
-#pragma omp master
-#endif
-            {
-                trace_all(false);
-            }
-            internal_sc_cycle2();
-#ifdef _OPENMP
-#pragma omp master
-#endif
-            {
-                trace_all(true);
-            }
-            cyclecount = (number_of_cycles < 0) ? number_of_cycles : cyclecount - 1;
-            // number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1;
-        }
+	while (!((have_to_stop) | (cyclecount == 0))) {
+#ifdef _OPENMP
+#pragma omp master
+#endif
+	    {
+		trace_all  (false);
+	    }
+		internal_sc_cycle2 ();
+#ifdef _OPENMP
+#pragma omp master
+#endif
+	    {
+		trace_all  (true);
+	    }
+	    cyclecount = (number_of_cycles<0)?number_of_cycles:cyclecount-1;
+	}
 #ifdef _OPENMP
 #pragma omp barrier
-#endif
-#if 0
-#ifdef _OPENMP
 #pragma omp critical
-        {
-            std::cerr << "Thread " << omp_get_thread_num() << " busy_wait " <<
-                busy_wait_f0 << " " << busy_wait_up << " " <<
-                busy_wait_f1 << " " << busy_wait_ml << std::endl;
-        }
+    {
+	std::cerr << "Thread " << omp_get_thread_num() << " busy_wait " <<
+	    busy_wait_f0 << " " << busy_wait_up << " " <<
+	    busy_wait_f1 << " " << busy_wait_ml << std::endl;
+    }
 #pragma omp critical
-        {
-            std::cerr << "Thread " << omp_get_thread_num() << " last_wait " <<
-                last_wait_f0 << " " << last_wait_up << " " <<
-                last_wait_f1 << " " << last_wait_ml << std::endl;
-        }
+    {
+	std::cerr << "Thread " << omp_get_thread_num() << " last_wait " <<
+	    last_wait_f0 << " " << last_wait_up << " " <<
+	    last_wait_f1 << " " << last_wait_ml << std::endl;
+    }
 #pragma omp critical
-        {
-            std::cerr << "Thread " << omp_get_thread_num() << " nfuncs "
-                << nb_func[0] << " " << nb_func[1] << " total_assig " <<
-                total_assig << std::endl;
-        }
-#endif
-#endif
-    }
+    {
+	std::cerr << "Thread " << omp_get_thread_num() << " nfuncs "
+	  << nb_func[0] << " " << nb_func[1] << " total_assig " <<
+	   total_assig << std::endl;
+    }
+#endif // _OPENMP
+  }
 }
 
@@ -206,19 +213,19 @@
 #ifdef _OPENMP
 #pragma omp parallel
-#endif
-        update();
-        func_combinationals();
-    }
-
-    internal_sc_cycle1((int) duration);
-
-    // don't need to do func_combinationals since 'unstable' flag is now false
-    if (is_posted_write()) {
+#endif // _OPENMP
+  	update ();
+    func_combinationals ();
+  }
+	
+	internal_sc_cycle1 ((int)duration);
+
+  // don't need to do func_combinationals since 'unstable' flag is now false
+  if (is_posted_write ()) {
 #ifdef _OPENMP
 #pragma omp parallel
-#endif
-        update();
-        func_combinationals();
-    }
+#endif // _OPENMP
+      update ();
+    func_combinationals ();
+  }
 }
 
Index: sources/src/global_functions.cc
===================================================================
--- sources/src/global_functions.cc	(revision 64)
+++ sources/src/global_functions.cc	(revision 65)
@@ -232,76 +232,67 @@
     }
 
-    /*
-     * Initialize the signals table
-     */
-    create_signals_table();
-    bind_to_table();
-    if (dump_netlist_info) {
-        print_table(cerr);
-        cerr << endl;
-        print_table_stats(cerr);
-        cerr << endl;
-    }
-    // Init variables to be able to run combinational functions
-    pending_write_vector_capacity = get_signal_table_size();
-
-    assert(pending_write_vector_capacity != 0);
+  /*
+   * Initialize the signals table
+   */
+  create_signals_table ();
+  bind_to_table ();
+  if (dump_netlist_info)
+  {
+    print_table (cerr);
+    cerr << endl;
+    print_table_stats (cerr);
+    cerr << endl;
+  }
+
+  // Init variables to be able to run combinational functions
+  pending_write_vector_capacity = get_signal_table_size ();
+
+  assert(pending_write_vector_capacity != 0);
 
 #ifdef _OPENMP
-    #define LINE_SIZE 128L
-    int malloc_size = (sizeof (pending_write_t) * (pending_write_vector_capacity + 1) + (LINE_SIZE - 1)) & ~(LINE_SIZE - 1);
-    assert((sizeof(pending_write_t) * (pending_write_vector_capacity + 1)) <= malloc_size && "bad allocation size");
-
-    #pragma omp parallel
-    {
-        posix_memalign((void **) &pending_write_vector, LINE_SIZE, malloc_size);
-        pending_write_vector_nb = (int32_t *) &pending_write_vector[0];
-        pending_write_vector = &pending_write_vector[1];
-        //printf("malloc 0x%x @%p, idx @0x%x\n", malloc_size, pending_write_vector, pending_write_vector_nb);
-        *pending_write_vector_nb = 0;
-    }
+#define LINE_SIZE 128L
+  int malloc_size =
+      (sizeof (pending_write_t) * (pending_write_vector_capacity + 1) + (LINE_SIZE - 1)) & ~(LINE_SIZE - 1);
+  assert((sizeof (pending_write_t) * (pending_write_vector_capacity + 1)) <= malloc_size && "bad allocation size");
+
+#pragma omp parallel
+  {
+	  posix_memalign((void **)&pending_write_vector, LINE_SIZE, malloc_size);
+	  pending_write_vector_nb = (int32_t *)&pending_write_vector[0];
+	  pending_write_vector = &pending_write_vector[1];
+	  printf("malloc 0x%x @%p, idx @0x%x\n", malloc_size, pending_write_vector, pending_write_vector_nb);
+	  *pending_write_vector_nb = 0;
+  }
 #else
-    pending_write_vector = (pending_write_vector_t) malloc(sizeof(pending_write_t) * pending_write_vector_capacity);
-    pending_write_vector_nb = (int32_t *) malloc(sizeof(int32_t));
-    *pending_write_vector_nb = 0;
-#endif
-
-
-    // create the clock list
-    clock_list_t clock_list;
-    create_clock_list(clock_list, get_equi_list());
-    if (dump_netlist_info) {
-        cerr << "Clock list\n" << "----------\n" << clock_list << "\n\n";
-    }
-
-    // Check if a clock exists in the system
-    if (clock_list.empty()) {
-        cerr << "System need a clock.\n" <<
-            "Please define system clock using special type \"sc_clock\".\n";
-        exit(22);
-    }
-    // Check if any constructor wrote into registers
-    if (*pending_write_vector_nb != 0) {
-        cerr <<
-            "Error : Register/Signal writing is not allowed before sc_initialize.\n"
-            "Move initializations from constructors/sc_main to module reset sequences.\n";
-        // we are unable to dump register(s) name(s) 
-        // because the table binding is not yet completed.
-        exit(24);
-    }
-
-    string base_name = get_scheduling(scheduling_method);
-
-    if (dynamic_link_of_scheduling_code) {
-        compile_and_link(base_name.c_str());
-    }
-    else {
-        use_static_func();
-    }
-
-    *pending_write_vector_nb = 0;
-
-    check_all_ports();
-    usage.start();
+	pending_write_vector_nb = (int32_t *)malloc(sizeof(int32_t));
+	pending_write_vector = (pending_write_vector_t) 
+	    malloc(sizeof (pending_write_t) * pending_write_vector_capacity);
+#endif
+  
+  // create the clock list
+  clock_list_t clock_list;
+  create_clock_list (clock_list, get_equi_list ());
+  if (dump_netlist_info)
+    cerr << "Clock list\n"
+         << "----------\n"
+         << clock_list << "\n\n";
+  // Check if a clock exists in the system
+  if (clock_list.empty()) {
+      cerr << "System need a clock.\n" <<
+          "Please define system clock using special type \"sc_clock\".\n";
+      exit(22);
+  }
+
+  string base_name = get_scheduling (scheduling_method);
+
+  if (dynamic_link_of_scheduling_code)
+    compile_and_link (base_name.c_str());
+  else
+    use_static_func ();
+  
+  *pending_write_vector_nb = 0;
+ 
+  check_all_ports ();
+  usage.start ();
 
     if (dump_stage) {
Index: sources/src/internal.h
===================================================================
--- sources/src/internal.h	(revision 64)
+++ sources/src/internal.h	(revision 65)
@@ -60,5 +60,5 @@
 extern int scheduling_method;
 extern bool use_port_dependency;
-extern bool use_openmp;
+extern const bool use_openmp;
 
 #define NO_SCHEDULING       0
Index: sources/src/sc_interface.h
===================================================================
--- sources/src/sc_interface.h	(revision 64)
+++ sources/src/sc_interface.h	(revision 65)
@@ -17,4 +17,5 @@
 #include "sc_fwd.h"
 #include "internal_ext.h"
+#include <sys/types.h>
 
 namespace sc_core {
Index: sources/src/sc_main.cc
===================================================================
--- sources/src/sc_main.cc	(revision 64)
+++ sources/src/sc_main.cc	(revision 65)
@@ -35,5 +35,6 @@
  */
 
-#include <sstream>
+#include <cassert>
+#include <cstring> // strcmp
 #include <list>
 #ifdef _OPENMP
@@ -41,6 +42,5 @@
 #endif
 #include <set>
-#include <cstring> // strcmp
-#include <cassert>
+#include <sstream>
 
 #include "internal.h"
@@ -91,7 +91,7 @@
 
 #ifdef _OPENMP
-bool use_openmp = true;
+const bool use_openmp = true;
 #else
-bool use_openmp = false;
+const bool use_openmp = false;
 #endif
 
@@ -395,7 +395,7 @@
     }
 
-    int ret = sc_main(argc, argv);
-    //free(pending_write_vector);
-    close_systemcass();
+  int ret = sc_main(argc, argv);
+//  free (pending_write_vector);
+  close_systemcass ();
 
     if (have_to_stop) {
Index: sources/src/sc_module.cc
===================================================================
--- sources/src/sc_module.cc	(revision 64)
+++ sources/src/sc_module.cc	(revision 65)
@@ -132,5 +132,5 @@
     dont_initialize = false;
 #ifdef _OPENMP
-    omp_threadnum = omp_get_thread_num();
+  omp_threadnum = omp_get_thread_num();
 #endif
 }
Index: sources/src/sc_port.cc
===================================================================
--- sources/src/sc_port.cc	(revision 64)
+++ sources/src/sc_port.cc	(revision 65)
@@ -50,4 +50,5 @@
 #endif
 
+
 extern "C" {
     extern char unstable;
@@ -228,6 +229,9 @@
             << " internal pending writings) ";
 #endif
-        unsigned int i;
-        for (i = 0; i < *pending_write_vector_nb; ++i) {
+	unsigned int i;
+	for (i = 0; i < *pending_write_vector_nb; ++i) {
+#if 0
+		cerr << "pending_write[" << i << "] : " << pending_write_vector[i];
+#endif
 #define iter (sc_core::pending_write_vector[i])
 #ifdef CONFIG_DEBUG
Index: sources/src/sc_signal.h
===================================================================
--- sources/src/sc_signal.h	(revision 64)
+++ sources/src/sc_signal.h	(revision 65)
@@ -16,4 +16,5 @@
 
 // Define registers writing method
+#include <string.h>
 #include <iostream>
 #include <cstdlib>
@@ -68,17 +69,19 @@
 // Pending write to register (simple stack)
 typedef pending_write_t * pending_write_vector_t;
-extern "C" int32_t * pending_write_vector_nb;
+extern "C" int32_t *pending_write_vector_nb;
 extern "C" unsigned long long int total_assig;
 #ifdef _OPENMP
-#pragma omp threadprivate(pending_write_vector_nb, total_assig)
+#pragma omp threadprivate (pending_write_vector_nb,total_assig)
 #endif
 extern unsigned int pending_write_vector_capacity;
+
 extern pending_write_vector_t pending_write_vector;
 #ifdef _OPENMP
-#pragma omp threadprivate(pending_write_vector)
-#endif
-
-template < typename T >
-inline void post_write(base_type * const pointer_, const T & value_) /*INLINE*/;
+#pragma omp threadprivate (pending_write_vector)
+#endif
+
+template <typename T>
+inline void post_write (base_type *const pointer_,
+                        const T          value_) /*INLINE*/;
 
 template < typename T >
@@ -93,5 +96,5 @@
 
 template < typename T >
-inline void post_write(base_type * const pointer_, const T & value_) {
+inline void post_write(base_type * const pointer_, const T value_) {
     if (sizeof(T) > sizeof(base_type)) {
         post_multiwrite(pointer_, value_);
@@ -105,11 +108,8 @@
             exit(-1);
         }
-#endif
-        pending_write_vector[*pending_write_vector_nb].pointer = pointer_;
-        // pending_write_vector[(*pending_write_vector_nb)++].value = *(reinterpret_cast<const base_type*const>(&value_)); => bug !
-        pending_write_vector[(*pending_write_vector_nb)++].value = value_; // => bug avec blues !
-
-        // -> fix to use user-defined struct in sc_signal/sc_in/sc_out/sc_inout
-        // pending_write_vector[(*pending_write_vector_nb)++].value = *((base_type*)&value_); => bug !
+#endif // CONFIG_DEBUG
+	sc_core::pending_write_vector[*pending_write_vector_nb].pointer = pointer_;
+	sc_core::pending_write_vector[(*pending_write_vector_nb)++].value = value_;
+
 #if 0
         std::cerr << "posted write : ptr = " << pointer_ << ", val = " << value_ << "\n";
@@ -124,7 +124,7 @@
 }
 
-
-inline bool is_posted_write() {
-    return *pending_write_vector_nb > 0;
+inline bool is_posted_write ()
+{
+  return *pending_write_vector_nb > 0;
 }
 
@@ -165,128 +165,109 @@
 };
 
-
-template < typename T >
-class sc_signal : public sc_signal_base {
-
-    private:
-
-    T val;
-    T new_val;
-    typedef T data_type;
-    typedef sc_signal < T > this_type;
-
-
-    ///////////
-    // Internal
-    public:
-    void init();
-    ///////////
-
-    void check_writer();
-
-    public:
-    // constructors, destructor 
-    sc_signal() {
-        if (typeid(data_type) == typeid(double) || typeid(data_type) == typeid(float)) {
-            std::cerr << "Error: SystemCASS does not support sc_signal<T> with T of type " << typeid(data_type).name() << std::endl;
-            exit(1);
-        }
-        init();
-    }
-
-    explicit sc_signal(const char * name_) : sc_signal_base(name_) {
-        init();
-    }
-
-    /*virtual*/ ~sc_signal() {}
-    /*virtual*/ inline const data_type & read() const INLINE;
-    /*virtual*/ inline void write(const data_type &) /*INLINE*/;
-
-    inline operator const data_type & () const { return this->read(); }
-
-    inline this_type & operator = (const data_type & a) {
-        sc_signal< T >::write(a);
-        return *this;
-    }
-
-    inline this_type & operator = (const sc_signal < T > & a) {
-        sc_signal< T >::write(a.read());
-        return *this;
-    }
-
-    inline this_type & operator += (const data_type & a) {
-        sc_signal< T >::write(read() + a);
-        return *this;
-    }
-
-    inline this_type & operator += (const sc_signal < T > & a) {
-        sc_signal< T >::write(read() + a.read());
-        return *this;
-    }
-
-    inline void * operator new (size_t size, size_t align) {
-        void * p;
-        const size_t nsize = (size + align - 1) & ~(align - 1);
-        if (nsize < size) {
-            std::cerr << "sc_signal new() alignement doesn't work (" <<
-                nsize << " < " << size << ")" << std::endl;
-            abort();
-        }
-
-        if (posix_memalign(&p, align, nsize) == 0) {
-            return p;
-        }
-        else {
-            return NULL;
-        }
-    }
-
-    inline void * operator new (size_t size) {
-        return malloc(size);
-    }
-
-    inline void * operator new (size_t size, void * p) {
-        return p;
-    }
-
-    const data_type & get_new_value() const {
-        // Warning: untested and doesn't support variable size
-        unsigned int i = 0;
-        for (i = 0; i < pending_write_vector_capacity; i++) {
-            if (pending_write_vector[i].pointer == get_pointer()) {
-                return pending_write_vector[i].value;
-            }
-        }
-        return val;
-    }
-
-    //  void trace (sc_trace_file * tf) const;
-    /*
-    virtual void print(std::ostream & o) const { o << *this; }
-    virtual void dump(std::ostream & o) const { o << *this; }
-    */
-
-    private:
-    // disabled 
-    sc_signal(const sc_signal < T > &);
+template <typename T>
+class sc_signal : public sc_signal_base
+{
+private:
+  T val;
+  T new_val;
+  typedef T                data_type;
+  typedef sc_signal < T >  this_type;
+
+  ///////////
+  // Internal
+public: void init ();
+  ///////////
+
+  //  virtual void update ();
+  void check_writer ();
+public:
+  // constructors, destructor 
+  sc_signal () 
+  { init (); }
+  explicit sc_signal (const char *name_): sc_signal_base(name_)
+  { init (); }
+  /*virtual */~ sc_signal () 
+  {}
+  // methods 
+  /*
+  virtual void register_port (sc_port_base &, const char *)
+  {}
+  virtual const sc_event & default_event () const 
+  {}
+  virtual const sc_event & value_changed_event () const 
+  {}
+  */
+  /*virtual*/ inline const data_type & read () const INLINE;
+/*
+  virtual const T & get_data_ref () const
+  {}
+  virtual bool event () const
+  {}
+  */
+  /*virtual*/ inline void write (const data_type &) /*INLINE*/;
+  inline operator const data_type & () const
+  { return this->read(); }
+  inline this_type& operator = (const data_type & a)
+  { sc_signal<T>::write (a); return *this; }
+  inline this_type& operator = (const sc_signal < T > &a)
+  { sc_signal<T>::write (a.read()); return *this; }
+  inline this_type& operator += (const data_type & a)
+  { sc_signal<T>::write (read() + a); return *this; }
+  inline this_type& operator += (const sc_signal < T > &a)
+  { sc_signal<T>::write (read()+a.read()); return *this; }
+  inline void * operator new (size_t size, size_t align)
+  {
+    void *p;
+    const size_t nsize = (size + align - 1) & ~(align -1);
+    if (nsize < size) {
+	std::cerr << "sc_signal new() alignement doesn't work (" <<
+	    nsize << " < " << size << ")" << std::endl;
+	abort();
+    }
+
+    if (posix_memalign(&p, align, nsize) == 0)
+	return p;
+    else
+	return NULL;
+  }
+  inline void * operator new (size_t size)
+  {
+    return malloc(size);
+  }
+  inline void * operator new (size_t size, void *p)
+  {
+    return p;
+  }
+
+  const data_type & get_new_value () const;
+//  void trace (sc_trace_file * tf) const;
+  /*
+	virtual void print (std::ostream &o) const
+  { o << *this; }
+  virtual void dump (std::ostream &o) const
+  { o << *this; }
+	*/
+private:
+  // disabled 
+  sc_signal (const sc_signal < T > &);
 
 };
 
-
-template < typename T >
-void sc_signal< T >::init() {
-    set_pointer((tab_t *) (void *) &val);
-    set_kind(kind_string);
-    sc_interface::init(sizeof(data_type)); 
+template <typename T>
+void
+sc_signal<T>::init()
+{
+	set_pointer ((tab_t*)(void*)&val);
+  set_kind    (kind_string);
+  sc_interface::init (sizeof (data_type)); 
 #if 0
-    val = (T) 0; /* The simulator initializes the signal/register to 0.    */
-                 /* However, hardware initialization still has to be done. */
-                 /* This kind of initialization is for trace diffing.      */
+  val = 0; /* The simulator initializes the signal/register to 0.    */
+           /* However, hardware initialization still has to be done. */
+           /* This kind of initialization is for trace diffing.      */
 #else
-    memset(&val, 0, sizeof(val));
-    memset(&new_val, 0, sizeof(new_val));
-#endif
-}
-
+   memset(&val, 0, sizeof(val));
+   memset(&new_val, 0, sizeof(new_val));
+#endif
+}
 
 // read the value
@@ -307,4 +288,6 @@
         return;
     }
+  if (sc_signal<T>::val == value_ && sc_signal<T>::new_val == value_)
+    return;
 #ifdef CONFIG_DEBUG
     if (get_pointer() == NULL) {
@@ -319,6 +302,6 @@
     std::cerr << "write (posted) " << value_ << " on sc_signal (writing into register) '" << name() << "'\n";
 #endif
-    sc_signal<T>::new_val = value_;
-    post_write(/*(tab_t*)&val*/ get_pointer(), value_);
+  sc_signal<T>::new_val = value_;
+  post_write (/*(tab_t*)&val*/ get_pointer(), value_);
 }
 
Index: sources/src/schedulers.cc
===================================================================
--- sources/src/schedulers.cc	(revision 64)
+++ sources/src/schedulers.cc	(revision 65)
@@ -61,11 +61,13 @@
 namespace sc_core {
 
+//
 // sort_functions splits and sorts instances_list into three functions lists : 
-method_process_list_t * transition_func_list;
-method_process_list_t * moore_func_list;
-#ifdef _OPENMP
-#pragma omp threadprivate(transition_func_list, moore_func_list)
+method_process_list_t *transition_func_list;
+method_process_list_t *moore_func_list;
+#ifdef _OPENMP
+#pragma omp threadprivate (transition_func_list, moore_func_list)
 #endif
 method_process_list_t combinational_func_list;
+
 /* ***************************** */
 /* Dumping functions (for debug) */
@@ -84,6 +86,4 @@
 /*  functions   */
 /****************/
-
-
 
 static bool sort_by_module_ptr (const method_process_t * a1, const method_process_t * a2) {
@@ -133,24 +133,26 @@
             if ((*m)->omp_threadnum == omp_get_thread_num())
 #endif
-            {
-                if ((*m)->is_transition()) {
-                    transition_func_list->push_back(*m);
-                }
-                else if ((*m)->is_genmoore()) {
-                    moore_func_list->push_back(*m);
-                }
-            }
-        }
-        // Sort transition functions by method pointer (1) and by module pointer (2)
-        std::sort(transition_func_list->begin(), transition_func_list->end(), sort_by_fct_ptr);
-        // Sort generation functions by method pointer (1) and by module pointer (2)
-        std::sort(moore_func_list->begin(), moore_func_list->end(), sort_by_fct_ptr);
-    }
-
-    for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
-        if ((*m)->is_combinational()) {
-            combinational_func_list.push_back(*m);
-        }
-    }
+	    {
+	        if ((*m)->is_transition ())
+		    transition_func_list->push_back(*m);
+	        else if ((*m)->is_genmoore ())
+		    moore_func_list->push_back(*m);
+	    }
+	}
+#if 1
+	// Sort transition functions by method pointer (1) and by module pointer (2)
+	std::sort (transition_func_list->begin(), transition_func_list->end(), sort_by_fct_ptr);
+	// Sort generation functions by method pointer (1) and by module pointer (2)
+	std::sort (moore_func_list->begin(), moore_func_list->end(), sort_by_fct_ptr);
+#endif
+#if 0
+	std::sort (transition_func_list->begin(), transition_func_list->end(), only_sort_by_module_ptr);
+	std::sort (moore_func_list->begin(), moore_func_list->end(), only_sort_by_module_ptr);
+#endif
+  }
+
+  for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
+    if ((*m)->is_combinational()) combinational_func_list.push_back(*m);
+  }
 }
 
@@ -225,13 +227,12 @@
 }
 
-
-string get_scheduling(int scheduling_method) {
-    string base_name;
-    /* marque les fonctions comme fonction de mealy ou non */
-    if (dump_funclist_info) {
-        cerr << "method process list : " << method_process_list << "\n";
-    }
-
-    sort_functions();
+string
+get_scheduling (int scheduling_method) 
+{
+  string base_name;
+  /* marque les fonctions comme fonction de mealy ou non */
+  if (dump_funclist_info)
+    cerr << "method process list : " << method_process_list << "\n";
+  sort_functions ();
 #ifdef _OPENMP
 #pragma omp parallel
@@ -243,91 +244,76 @@
             cerr << "Thread " << omp_get_thread_num() << "\n";
 #endif
-            cerr << "  Transition functions : " << *transition_func_list << "\n";
-            cerr << "  Moore generation functions : " << *moore_func_list << "\n";
+    cerr << "  Transition functions : " << *transition_func_list << "\n";
+    cerr << "  Moore generation functions : " << *moore_func_list << "\n";
 #ifdef _OPENMP
 #pragma omp master
 #endif
-            {
-                if (!combinational_func_list.empty()) {
-                    cerr << "Mealy generation functions : " << combinational_func_list << "\n";
-                }
-            }
-        }
-
-    /* Schedule */
-        switch (scheduling_method) {
-            case BUCHMANN_SCHEDULING :
-            {
-                // Generate the scheduled code, compile and link.
-                // Buchmann's thesis explains this scheduling method.
-                // Uses port dependancies like Dr. Mouchard.
-                ProcessDependencyList * process_list = BuchmannScheduling();
-                if (dynamic_link_of_scheduling_code) {
-                    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
-                }
-                else {
-                    gen_scheduling_code_for_static_func(*transition_func_list, *moore_func_list, *process_list);
-                }
-                break;
-            }
-
-            case MOUCHARD_SCHEDULING :
-            {
-                // Generate the scheduled code, compile and link.
-                // Mouchard's thesis explains this scheduling method.
-                // Uses port dependancies like Dr. Mouchard.
-                // CAUTION : unlike FastSysC, this scheduling is totally static 
-                // and does not use an event-driven scheduler.
-                ProcessDependencyList * process_list = MouchardScheduling();
-                if (dynamic_link_of_scheduling_code) {
-                    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
-                }
-                else {
-                    gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
-                }
-                break;
-            }
-
-            case CASS_SCHEDULING :
-            {
-                // Generate the scheduled code, compile and link
-                // Hommais's thesis explains this scheduling method (like CASS strategy)
-                // Doesn't use port dependancies
-                strong_component_list_t * strong_list = NULL;
+    {
+      if (!combinational_func_list.empty()) {
+	    cerr << "Mealy generation functions : " <<
+		combinational_func_list << "\n";
+      }
+    }
+  }
+
+  /* Schedule */ 
+  switch (scheduling_method) {
+  case BUCHMANN_SCHEDULING : {
+    // Generate the scheduled code, compile and link.
+    // Buchmann's thesis explains this scheduling method.
+    // Uses port dependancies like Dr. Mouchard.
+    ProcessDependencyList* process_list = BuchmannScheduling ();
+  if (dynamic_link_of_scheduling_code)
+    base_name = gen_scheduling_code_for_dynamic_link (*transition_func_list, *moore_func_list,*process_list);
+  else
+    gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
+    break;
+  }
+  case MOUCHARD_SCHEDULING : {
+    // Generate the scheduled code, compile and link.
+    // Mouchard's thesis explains this scheduling method.
+    // Uses port dependancies like Dr. Mouchard.
+    // CAUTION : unlike FastSysC, this scheduling is totally static 
+    // and does not use an event-driven scheduler.
+    ProcessDependencyList* process_list = MouchardScheduling ();
+  if (dynamic_link_of_scheduling_code)
+    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list,*process_list);
+  else
+    gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
+    break;
+  }
+  case CASS_SCHEDULING : {
+    // Generate the scheduled code, compile and link
+    // Hommais's thesis explains this scheduling method (like CASS strategy)
+    // Doesn't use port dependancies
+    strong_component_list_t *strong_list = NULL;
 #ifdef _OPENMP
 #pragma omp master
 #endif
-                {
-                    Graph * g = makegraph (&combinational_func_list);
-                    if (dump_all_graph && g) {
-                        graph2dot("module_graph", *g);
-                    }
-                    strong_list = strong_component(g);
-                }
-                if (dynamic_link_of_scheduling_code) {
-                    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, strong_list);
-                }
-                else {
-                    gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);
-                }
-                // free the void_lists in strong_list
-                //for ( strong_component_list_t::iterator i = strong_list->begin(); i < strong_list->end(); i++) {
-                //    delete *i;
-                //}
+    {
+    Graph *g = makegraph (&combinational_func_list);
+    if (dump_all_graph && g)
+      graph2dot("module_graph", *g);
+    strong_list = strong_component (g);
+    }
+  if (dynamic_link_of_scheduling_code)
+    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list,strong_list);
+  else
+    gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);
 #ifdef _OPENMP
 #pragma omp master
 #endif
-                {
-                    delete strong_list;
-                }
-                break;
-            }
-            default :
-                cerr << "Error : Unable to schedule SystemC process."
-                    "Please select a scheduling method.\n";
-                exit (35);
-        }
-    }
-    return base_name;
+  {
+    delete strong_list;
+  }
+  break;
+  }
+  default :
+    cerr << "Error : Unable to schedule SystemC process."
+            "Please select a scheduling method.\n";
+    exit (35);
+  }
+  }
+  return base_name;
 }
 
