Index: sources/src/graph_cass.cc
===================================================================
--- sources/src/graph_cass.cc	(revision 27)
+++ sources/src/graph_cass.cc	(revision 52)
@@ -1,15 +1,15 @@
 /*------------------------------------------------------------\
-|                                                             |
-| Tool    :                  systemcass                       |
-|                                                             |
-| File    :                 graph_cass.cc                     |
-|                                                             |
-| Author  :                 Petrot Frédéric                   |
-|                           Taktak Sami                       |
-|                           Buchmann Richard                  |
-|                                                             |
-| Date    :                   09_07_2004                      |
-|                                                             |
-\------------------------------------------------------------*/
+  |                                                             |
+  | Tool    :                  systemcass                       |
+  |                                                             |
+  | File    :                 graph_cass.cc                     |
+  |                                                             |
+  | Author  :                 Petrot Frédéric                   |
+  |                           Taktak Sami                       |
+  |                           Buchmann Richard                  |
+  |                                                             |
+  | Date    :                   09_07_2004                      |
+  |                                                             |
+  \------------------------------------------------------------*/
 
 /* 
@@ -107,12 +107,12 @@
  * bug fix :
  * - allow the use of user-defined structs in sc_signal/sc_in/sc_out/sc_inout
- * - use sc_dt namespace like official SystemC engine
- *
- * add :
- * - dump the signal/port/module dependancy graph in dot format
- *
- * Graph library is now splitted from the SystemCASS specific code.
- *
- */
+* - use sc_dt namespace like official SystemC engine
+*
+* add :
+* - dump the signal/port/module dependancy graph in dot format
+*
+* Graph library is now splitted from the SystemCASS specific code.
+*
+*/
 
 #include <iostream>
@@ -129,5 +129,5 @@
 #include "entity.h"
 #include "simplify_string.h" // simplify_string
-#include "sc_ver_ext.h"      // sc_version for dumping to DOT
+#include "sc_ver_ext.h" // sc_version for dumping to DOT
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -138,93 +138,50 @@
 namespace sc_core {
 
-#if 0
-static
-ostream& operator << (ostream& o,
-		      const Vertex & v)
-{
-#if 0
-      if (v.arcs == NULL)
-	o << v.name << "(" << v.module->ins_name << ")->(none)\n";
-      Arc *a;
-      for (a = v.arcs; a; a = a->next)
-	o << v.name << "(" << v.module->ins_name << ")->"
-		<< a->tip->name << "(" << a->tip->module << ")\n";
-  return o;
-#endif
-	method_process_t* m = (method_process_t*)(v.data);
-  if (v.arcs == NULL)
-	  o << *m << "\n";
-  Arc *a;
-  for (a = v.arcs; a; a = a->next) {
-	  method_process_t* m2 = (method_process_t*)(a->tip->data);
-    o << *m << "->"
-		  << *m2 << ")\n";
-	}
-  return o;
-
-}
-#endif
-
-#if 0
-static
-ostream& 
-operator << (ostream &o,
-		         const Graph &g)
-{
-  Vertex     *v;
-    for (v = g.vertices; v < g.vertices + g.n; v++) {
-	o << *v;
-    }
-    return o;
-}
-#endif
-
-std::map<const method_process_t*,Vertex*> m_v;
-
-/* Ajoute un arc */ 
-void add_arcs(const method_process_t &mp, const sc_module &module)
-{
-	std::map<const method_process_t*,Vertex*>::iterator i;
-  for (i =	m_v.begin ();	 i != m_v.end (); ++i) {
-	  if (i->first->module == &module)
-			new_arc (m_v[&mp],i->second);
-	}
-}
-
-/* Ajoute un arc */ 
-void add_arcs(const  method_process_t &mp,
-              tab_t *signal_pointer)
-{
-  equi_t &e = get_equi (signal_pointer);
-  equi_t::iterator i;
-  for (i = e.begin (); i != e.end (); ++i) {
-		const char *kind = i->kind ();
-    if (strstr (kind,"out")) {
-			const sc_port_base &port = *(i->port);
-		  const sc_module &module = port.get_module ();
-			if (&module == mp.module)
-				continue;
-			add_arcs (mp, module);
-      break;
-		}
-  }
-}
-
-void
-add_arcs(const method_process_t &mp)
-{
-  sensitivity_list_t::const_iterator port_bound;
-	for (port_bound = mp.sensitivity_list.begin(); port_bound != mp.sensitivity_list.end(); ++port_bound) {
-      // pour tous les ports/signaux p associés à la fonction au couple m
-      	/* si pp est un port de sortie d'une autre fonction de mealy,
-	   crée un arc entre m et mm */
-	/* on ne peut pas savoir si un port est la sortie d'une fonction de mealy. 
-	   on va donc chercher à savoir si c'est un port de sortie d'un automate de moore,
-	   sinon on considère que c'est une sortie de mealy.
-	*/
-
-      add_arcs(mp, port_bound->get_interface().get_pointer ());
-    }
-}
+std::map < const method_process_t *, Vertex * >m_v;
+
+/* Ajoute un arc */
+void add_arcs(const method_process_t & mp, const sc_module & module) {
+    std::map < const method_process_t *, Vertex * >::iterator i;
+    for (i = m_v.begin(); i != m_v.end(); ++i) {
+        if (i->first->module == &module)
+            new_arc(m_v[&mp], i->second);
+    }
+}
+
+
+/* Ajoute un arc */
+void add_arcs(const method_process_t & mp, tab_t * signal_pointer) {
+    equi_t & e = get_equi(signal_pointer);
+    equi_t::iterator i;
+    for (i = e.begin(); i != e.end(); ++i) {
+        const char * kind = i->kind();
+        if (strstr(kind, "out")) {
+            const sc_port_base & port = *(i->port);
+            const sc_module & module = port.get_module();
+            if (&module == mp.module) {
+                continue;
+            }
+            add_arcs(mp, module);
+            break;
+        }
+    }
+}
+
+
+void add_arcs(const method_process_t & mp) {
+    sensitivity_list_t::const_iterator port_bound;
+    for (port_bound = mp.sensitivity_list.begin();
+            port_bound != mp.sensitivity_list.end(); ++port_bound) {
+        // pour tous les ports/signaux p associés à la fonction au couple m
+        /* si pp est un port de sortie d'une autre fonction de mealy,
+           crée un arc entre m et mm */
+        /* on ne peut pas savoir si un port est la sortie d'une fonction de mealy. 
+           on va donc chercher à savoir si c'est un port de sortie d'un automate de moore,
+           sinon on considère que c'est une sortie de mealy.
+           */
+        add_arcs(mp, port_bound->get_interface().get_pointer());
+    }
+}
+
 
 /* Construit le graph de dépendance des signaux de Mealy */
@@ -238,178 +195,121 @@
    Vertex is an array of (method_process_t*)
    Edge is a couple Vertex->Vertex.
+   */
+extern Graph * makegraph(const method_process_list_t * lm) {
+    method_process_list_t::const_iterator mp;
+
+    int n = 0; /* Number of vertices */
+    Graph * g;
+    Vertex * v;
+
+    /* Compute the number of vertices in the graph:
+     * The vertices set is the method set. */
+
+    /*  for (m = lm->begin(); m != lm->end(); m++)
+        n++;*/
+    n = lm->size();
+
+    /* Create the graph */
+    g = gb_new_graph(n);
+
+    /* Associate the netlist elements to the graph vertices, and vice-versa */
+    v = g->vertices;
+
+    /* initialisation des vertices */
+    for (mp = lm->begin(); mp != lm->end(); ++mp) {
+        v->data = *mp;
+        m_v[*mp] = v++;
+    }
+
+    for (mp = lm->begin(); mp != lm->end(); ++mp) {
+        // pour tous couples m, instance module/function de la liste lm
+        add_arcs(**mp);
+    }
+
+    return g;
+}
+
+
+static string & get_method_process_fullname(string & name, const method_process_t & mp) {
+    sc_module * module = mp.module;
+    name = module->name();
+    name += "_";
+    name += mp.name;
+    return name;
+}
+
+
+static bool dot_write(ofstream & o, const Graph & g) {
+    string name1, name2, s;
+    // Printing into dot file
+    for (int i = 0; i < g.n; ++i) { // Printing node list
+        Vertex * v = g.vertices + i;
+        method_process_t *mp = (method_process_t *) (v->data);
+        get_method_process_fullname(name1, *mp);
+        const char * pname1 = name1.c_str();
+        o << "node [name=";
+        o.width(35);
+        o << simplify_name(pname1, s);
+        o << "];\n";
+    }
+    for (int i = 0; i < g.n; ++i) { // Printing edge list
+        Vertex * v1 = g.vertices + i;
+        method_process_t *mp1 = (method_process_t *) (v1->data);
+        get_method_process_fullname(name1, *mp1);
+        const char * pname1 = name1.c_str();
+        for (Arc * a = v1->arcs; a != NULL; a = a->next) {
+            Vertex *v2 = a->tip;
+            method_process_t * mp2 = (method_process_t *) (v2->data);
+            get_method_process_fullname(name2, *mp2);
+            const char * pname2 = name2.c_str();
+            o.width(35);
+            o << simplify_name(pname2, s);
+            o << " -> ";
+            o.width(35);
+            o << simplify_name(pname1, s);
+            o << ";\n";
+        }
+    }
+    return true;
+}
+
+extern bool graph2dot(const char * name, const Graph & g) {
+    if (!name) {
+        return false;
+    }
+    string filename;
+    filename = name;
+    filename += ".dot";
+    ofstream o;
+    o.open(filename.c_str(), ios::out | ios::trunc);
+    if (o.is_open() == false) {
+        return false;
+    }
+    o << "// Module dependency graph\n// Generated by " << sc_version() << "\n";
+    o << "strict digraph " << name << " {\n";
+    o << "node [shape=box];\n";
+    //       "concentrate=true;\n";
+    o << left;
+    dot_write(o, g);
+    // Closing dot file
+    o << "}\n";
+    o.close();
+    if (dump_stage) {
+        cerr << "Module dependency graph written into '" << filename << "'.\n";
+    }
+    return true;
+}
+
+} // end of sc_core namespace
+
+/*
+# Local Variables:
+# tab-width: 4;
+# c-basic-offset: 4;
+# c-file-offsets:((innamespace . 0)(inline-open . 0));
+# indent-tabs-mode: nil;
+# End:
+#
+# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
 */
-extern Graph*
-makegraph (const method_process_list_t *lm)
-{
-  method_process_list_t::const_iterator mp;
-
-  int         n = 0; /* Number of vertices */
-  Graph      *g;
-  Vertex     *v;
-  
-  /* Compute the number of vertices in the graph:
-   * The vertices set is the method set. */
-  
-/*  for (m = lm->begin(); m != lm->end(); m++)
-    n++;*/
-  n = lm->size ();
-  
-  /* Create the graph */
-  g = gb_new_graph(n);
-
-  /* Associate the netlist elements to the graph vertices, and vice-versa */
-  v = g->vertices;
-
-  /* initialisation des vertices */
-  for (mp = lm->begin(); mp != lm->end(); ++mp) {
-    v->data = *mp;
-    m_v[*mp] = v++;
-  }
-
-  for (mp = lm->begin(); mp != lm->end(); ++mp) { 
-    // pour tous couples m, instance module/function de la liste lm
-    add_arcs (**mp);
-  }
-
-  return g;
-}   
-
-/* 
-void 
-dot_write_edge (const  method_process_t &mp,
-                tab_t *signal_pointer)
-{
-  equi_t &e = get_equi (signal_pointer);
-  equi_t::iterator i;
-  for (i = e.begin (); i != e.end (); ++i) {
-		const char *kind = i->kind ();
-    if (strstr (kind,"out")) {
-			const sc_port_base &port = *(i->port);
-		  const sc_module &module = port.get_module ();
-			if (&module == mp.module)
-				continue;
-			add_arcs (mp, module);
-	    o << "edge [label="
-        << "];\n";
-      o	<< " -> ";
-      o << ";\n";
-		}
-  }
-}
-
-static
-bool
-dot_write_edge (ofstream &o,
-                const method_process_t &mp)
-{
-  sensitivity_list_t::const_iterator port_bound;
-	for (port_bound = mp.sensitivity_list.begin(); port_bound != mp.sensitivity_list.end(); ++port_bound)
-      dot_write_edge (o, mp, port_bound->get_interface().get_pointer ());
-}
-
-static
-bool
-dot_write (ofstream &o,
-           const method_process_list_t &lm)
-{
-  // Printing into dot file
-  string s;
-  method_process_list_t::const_iterator mp;
-  for (mp = lm.begin(); mp != lm.end(); ++mp) {
-    method_process_t *amp = *mp;
-    sc_module *module = amp->module;
-    o << "node [name="
-//      << simplify_name(module.get_name().c_str(),s)
-      << "];\n";
-  }
-  for (mp = lm->begin(); mp != lm->end(); ++mp)
-    dot_write (o, **mp);
-}
-*/
-
-static
-string&
-get_method_process_fullname (string &name, 
-                             const method_process_t &mp)
-{
-  sc_module *module = mp.module;
-  name = module->name ();
-  name += "_";
-  name += mp.name;
-  return name;
-}
-
-static
-bool
-dot_write (ofstream &o,
-           const Graph &g)
-{
-  string name1,name2,s;
-  // Printing into dot file
-  for (int i = 0; i < g.n; ++i)
-  { // Printing node list
-    Vertex *v = g.vertices + i;
-    method_process_t *mp     = (method_process_t*) (v->data);
-    get_method_process_fullname (name1,*mp);
-    const char *pname1 = name1.c_str();
-    o << "node [name=";
-    o.width (35);
-    o << simplify_name(pname1,s);
-    o << "];\n";
-  }
-  for (int i = 0; i < g.n; ++i)
-  { // Printing edge list
-    Vertex *v1 = g.vertices + i;
-    method_process_t *mp1     = (method_process_t*) (v1->data);
-    get_method_process_fullname (name1,*mp1);
-    const char *pname1 = name1.c_str();
-    for (Arc *a = v1->arcs; a != NULL; a = a->next)
-    {
-      Vertex *v2 = a->tip;
-      method_process_t *mp2 = (method_process_t*) (v2->data);
-      get_method_process_fullname (name2,*mp2);
-      const char *pname2 = name2.c_str();
-      o.width (35);
-      o << simplify_name(pname2,s);
-      o << " -> ";
-      o.width (35);
-      o << simplify_name(pname1,s);
-      o << ";\n";
-    }
-  }
-
-  return true;
-}
-
-extern bool
-graph2dot (const char *name,
-           const Graph &g)
-{
-	if (!name)
-		return false;
-	string filename;
-	filename =  name;
-	filename += ".dot";
-	ofstream o;
-  o.open (filename.c_str(),ios::out | ios::trunc);
-	if (o.is_open () == false)
-		return false;
-	o << "// Module dependency graph\n"
-       "// Generated by "
-    << sc_version () << "\n";
-	o << "strict digraph " << name << " {\n";
-  o << "node [shape=box];\n";
-//       "concentrate=true;\n";
-  o << left;
-	dot_write (o,g);
-  // Closing dot file
-	o << "}\n";
-	o.close ();
-  if (dump_stage)
-    cerr << "Module dependency graph written into '" 
-         << filename << "'.\n";
-	return true;
-}
-
-} // end of sc_core namespace
-
+
