source: branches/with_autoconf/src/graph_signals.cc @ 56

Last change on this file since 56 was 20, checked in by nipo, 16 years ago

Sync up with trunk changes

File size: 7.0 KB
Line 
1/*------------------------------------------------------------\
2|                                                             |
3| Tool    :                  systemcass                       |
4|                                                             |
5| File    :                 graph_signals.cc                  |
6|                                                             |
7| Author  :                 Buchmann Richard                  |
8|                                                             |
9| Date    :                   22_09_2004                      |
10|                                                             |
11\------------------------------------------------------------*/
12
13/*
14 * This file is part of the Disydent Project
15 * Copyright (C) Laboratoire LIP6 - Département ASIM
16 * Universite Pierre et Marie Curie
17 *
18 * Home page          : http://www-asim.lip6.fr/disydent
19 * E-mail             : mailto:richard.buchmann@lip6.fr
20 *
21 * This library is free software; you  can redistribute it and/or modify it
22 * under the terms  of the GNU Library General Public  License as published
23 * by the Free Software Foundation; either version 2 of the License, or (at
24 * your option) any later version.
25 *
26 * Disydent is distributed  in the hope  that it  will be
27 * useful, but WITHOUT  ANY WARRANTY; without even the  implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
29 * Public License for more details.
30 *
31 * You should have received a copy  of the GNU General Public License along
32 * with the GNU C Library; see the  file COPYING. If not, write to the Free
33 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35
36/*
37 * $Log: graph_signals.cc,v $
38 * Revision 1.7  2006/06/12 14:02:04  buchmann
39 * - Now sort transition and generation functions by fonction pointer
40 *   (Thank to Nicolas Pouillon)
41 * - Add Nicolas Pouillon as contributor into splash screen
42 * - Rename files and classes from "dependancy" to "dependency".
43 * - Add some references to bibliography file
44 * - Add licence note to every files
45 * - Rename "module graph" to "process graph"
46 * - Now dump module graph when using --t option and CASS scheduling at the same
47 *   time
48 *
49 * Bug fixes :
50 * - check user time ( != 0) before computing simulation performance
51 * - Remove reinterpret_cast (for pending write) because of unexpected results
52 * - Add ASSERT in trace functions
53 *
54 * Revision 1.6  2005/10/12 10:01:00  buchmann
55 * Bug fix :
56 * - test to avoid malloc(0)
57 *
58 * Remove :
59 * - unused variable
60 *
61 * Revision 1.5  2005/09/14 14:08:24  buchmann
62 * Add Werror flag to compile the debug library.
63 * Split sc_clock implementation from sc_port to sc_clock.
64 * Add a helper message to write mealy functions avoiding combinational cycle.
65 *
66 * Bug fix :
67 * - cvs rules is no longer circular
68 * - bit2string
69 * - port binding (sc_in to sc_out)
70 * - error message from FSM rules checker
71 * - sc_time copy operator
72 *
73 * Code cleaning :
74 * - remove duplicated code (entity.cc and sc_port.cc)
75 * - remove duplicated declarations (internal_ext.h and internal.h)
76 *
77 * Revision 1.4  2005/06/22 09:15:03  buchmann
78 * Add some *_ext.h files to split internal implementation from API interface.
79 *
80 * Add -Wunused to detect unused functions.
81 *
82 * Include directory now contains API interface file only.
83 *
84 * Declar all the implementation/interface inside sc_core namespace as LRM 2.1
85 * advices.
86 *
87 * Remove casc namespace.
88 *
89 * Clean up dead code segments.
90 *
91 * Add hexadecimal dumping support.
92 *
93 * Add empty implementation of functions for object hierarchy traversal. (LRM 2.1)
94 *
95 * Bug fixes :
96 * - reference return of the following functions : operators =, |=, &= and so on.
97 * - range functions now return an sc_int_subref instead of an int.
98 *
99 * Revision 1.3  2005/03/25 14:33:01  buchmann
100 * Typo :
101 * -  dependAncy -> dependEncy
102 *
103 * sc_initialize :
104 * -  Use a hash table to speed up elaboration step. (x40 faster)
105 *
106 * Tracing :
107 * -  check for modification BEFORE building bit string.
108 * -  use sprintf instead std string concatenation.
109 *
110 * Revision 1.2  2005/01/20 09:15:12  buchmann
111 * add following functions to sc_uint classes :
112 * - operator []
113 * - range (left,right)
114 *
115 * support to port dependancy declarations.
116 * print used precompiled options in verbose mode.
117 * use pedantic flag.
118 * add some rules to generate documentations.
119 *
120 * Revision 1.1  2004/09/27 14:40:14  buchmann
121 * bug fix :
122 * - allow the use of user-defined structs in sc_signal/sc_in/sc_out/sc_inout
123 * - use sc_dt namespace like official SystemC engine
124 *
125 * add :
126 * - dump the signal/port/module dependancy graph in dot format
127 *
128 * Graph library is now splitted from the SystemCASS specific code.
129 *
130 */
131
132#include <cstdio>
133#include <map>
134
135#include "graph_signals.h"
136#include "signal_dependency.h"
137#include "sc_sensitive.h"
138#include "sc_module.h"
139#include "sc_port.h"
140#ifdef HAVE_CONFIG_H
141#include "config.h"
142#endif
143
144using namespace std;
145
146namespace sc_core {
147
148#if 0
149static
150ostream& operator << (ostream&      o,
151                      const Vertex &v)
152{
153        equi_t* m = (equi_t*)(v.data);
154  if (v.arcs == NULL)
155          o << get_name(*m) << "\n";
156  Arc *a;
157  for (a = v.arcs; a; a = a->next)
158        {
159          equi_t* m2 = (equi_t*)(a->tip->data);
160          o << get_name(*m) << "->"
161                  << get_name(*m2) << "\n";
162        }
163  return o;
164
165}
166
167static
168ostream&
169operator << (ostream     &o,
170             const Graph &g)
171{
172  Vertex *v;
173  int     i = 1;
174  for (v = g.vertices; v < g.vertices + g.n; ++v) {
175    o << i++ << " : " << *v;
176  }
177  return o;
178}
179#endif
180
181typedef std::map<const equi_t*, Vertex*> nodes_set_t;
182
183void
184create_arcs (const SignalDependencyGraph& sig_g, nodes_set_t& s)
185{
186  SignalDependencyGraph::const_iterator j;
187  for (j = sig_g.begin(); j != sig_g.end(); ++j) { 
188    new_arc (s[j->source],s[j->destination]);
189  }
190}
191
192void
193create_vertices_list (Graph *g, nodes_set_t& s)
194{
195        Vertex *v = g->vertices;
196  if (v == NULL)
197    return;
198  nodes_set_t::iterator j;
199  for (j = s.begin(); j != s.end(); ++j) 
200  {
201                v->data   = (void*) (j->first);
202                j->second = v++;
203        }       
204}
205
206nodes_set_t*
207create_nodes_set (const SignalDependencyGraph& sig_g)
208{
209        /* Create a signal set */
210        nodes_set_t &s = *(new nodes_set_t);
211
212  SignalDependencyGraph::const_iterator j;
213  for (j = sig_g.begin(); j != sig_g.end(); ++j) 
214  {
215                s[j->source] = NULL;
216                s[j->destination] = NULL;
217  }
218        return &s;
219}
220
221/* Construit le graph de dépendance des signaux de Mealy */
222/* g = Mealy signal dependancy graph */
223Graph *makegraph(const SignalDependencyGraph& sig_g)
224{
225  int         n = 0; /* Number of vertices */
226  Graph      *g;
227  //Vertex     *v;
228 
229        /* Create node set */
230        nodes_set_t *sig_s = create_nodes_set (sig_g);
231
232  /* Compute the number of vertices in the graph */
233  n = sig_s->size();
234 
235  /* Create the graph */
236  g = gb_new_graph(n);
237
238  /* Associate the netlist elements to the graph vertices, and vice-versa */
239//  v = g->vertices;
240
241        /* Create the node set */
242  create_vertices_list (g,*sig_s);
243
244  /* initialisation des vertices */
245        create_arcs (sig_g,*sig_s);
246
247        delete sig_s;
248#if 0
249        cerr << *g << "\n";
250#endif
251  return g;
252}   
253
254} // end of sc_core namespace
255
Note: See TracBrowser for help on using the repository browser.