source: sources/src/graph_signals.cc @ 56

Last change on this file since 56 was 52, checked in by meunier, 12 years ago

Code formatting in all source files.

File size: 6.6 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
141#ifdef HAVE_CONFIG_H
142#include "config.h"
143#endif
144
145using namespace std;
146
147namespace sc_core {
148
149
150typedef std::map < const equi_t *, Vertex * >nodes_set_t;
151
152void create_arcs(const SignalDependencyGraph & sig_g, nodes_set_t & s) {
153   SignalDependencyGraph::const_iterator j;
154   for (j = sig_g.begin(); j != sig_g.end(); ++j) {
155      new_arc(s[j->source], s[j->destination]);
156   }
157}
158
159
160void create_vertices_list(Graph * g, nodes_set_t & s) {
161   Vertex * v = g->vertices;
162   if (v == NULL) {
163      return;
164   }
165   nodes_set_t::iterator j;
166   for (j = s.begin(); j != s.end(); ++j) {
167      v->data = (void *) (j->first);
168      j->second = v++;
169   }
170}
171
172
173nodes_set_t * create_nodes_set(const SignalDependencyGraph & sig_g) {
174   /* Create a signal set */
175   nodes_set_t & s = *(new nodes_set_t);
176
177   SignalDependencyGraph::const_iterator j;
178   for (j = sig_g.begin(); j != sig_g.end(); ++j) {
179      s[j->source] = NULL;
180      s[j->destination] = NULL;
181   }
182   return &s;
183}
184
185
186/* Construit le graph de dépendance des signaux de Mealy */
187/* g = Mealy signal dependancy graph */
188Graph * makegraph(const SignalDependencyGraph & sig_g) {
189   int n = 0; /* Number of vertices */
190   Graph * g;
191
192   /* Create node set */
193   nodes_set_t * sig_s = create_nodes_set(sig_g);
194
195   /* Compute the number of vertices in the graph */
196   n = sig_s->size();
197
198   /* Create the graph */
199   g = gb_new_graph(n);
200
201   /* Create the node set */
202   create_vertices_list(g, *sig_s);
203
204   /* initialisation des vertices */
205   create_arcs(sig_g, *sig_s);
206
207   delete sig_s;
208
209   return g;
210}
211
212} // end of sc_core namespace
213
214/*
215# Local Variables:
216# tab-width: 4;
217# c-basic-offset: 4;
218# c-file-offsets:((innamespace . 0)(inline-open . 0));
219# indent-tabs-mode: nil;
220# End:
221#
222# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
223*/
224
225
Note: See TracBrowser for help on using the repository browser.