Changeset 52 for sources/src/graph_signals.cc
- Timestamp:
- Jan 22, 2013, 4:23:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/graph_signals.cc
r27 r52 1 1 /*------------------------------------------------------------\ 2 | |3 | Tool : systemcass |4 | |5 | File : graph_signals.cc |6 | |7 | Author : Buchmann Richard |8 | |9 | Date : 22_09_2004 |10 | |11 \------------------------------------------------------------*/2 | | 3 | Tool : systemcass | 4 | | 5 | File : graph_signals.cc | 6 | | 7 | Author : Buchmann Richard | 8 | | 9 | Date : 22_09_2004 | 10 | | 11 \------------------------------------------------------------*/ 12 12 13 13 /* … … 138 138 #include "sc_module.h" 139 139 #include "sc_port.h" 140 140 141 #ifdef HAVE_CONFIG_H 141 142 #include "config.h" … … 146 147 namespace sc_core { 147 148 148 #if 0 149 static 150 ostream& 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 167 static 168 ostream& 169 operator << (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 181 typedef std::map<const equi_t*, Vertex*> nodes_set_t; 182 183 void 184 create_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 192 void 193 create_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 206 nodes_set_t* 207 create_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 } 149 150 typedef std::map < const equi_t *, Vertex * >nodes_set_t; 151 152 void 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 160 void 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 173 nodes_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 220 185 221 186 /* Construit le graph de dépendance des signaux de Mealy */ 222 187 /* g = Mealy signal dependancy graph */ 223 Graph *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 } 188 Graph * 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 } 253 211 254 212 } // end of sc_core namespace 255 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 TracChangeset
for help on using the changeset viewer.