1 | /*------------------------------------------------------------\ |
---|
2 | | | |
---|
3 | | Tool : systemcass | |
---|
4 | | | |
---|
5 | | File : mouchard_scheduling.cc | |
---|
6 | | | |
---|
7 | | Author : Buchmann Richard | |
---|
8 | | | |
---|
9 | | Date : 20_12_2006 | |
---|
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 | #include <set> |
---|
37 | #include <iostream> |
---|
38 | #include <fstream> |
---|
39 | |
---|
40 | #include "assert.h" |
---|
41 | #include "process_dependency.h" |
---|
42 | #include "methodprocess_dependency.h" |
---|
43 | #include "mouchard_scheduling.h" |
---|
44 | #include "simplify_string.h" |
---|
45 | #include "sc_fwd.h" |
---|
46 | #include "sc_module.h" |
---|
47 | #include "sc_ver.h" |
---|
48 | |
---|
49 | |
---|
50 | #ifdef HAVE_CONFIG_H |
---|
51 | #include "config.h" |
---|
52 | #endif |
---|
53 | |
---|
54 | using namespace std; |
---|
55 | |
---|
56 | namespace sc_core { |
---|
57 | |
---|
58 | typedef set<SignalDependency> signalDependencySet; |
---|
59 | typedef set<const method_process_t *> processSet; |
---|
60 | |
---|
61 | static void getSource(signalDependencySet &ss, const SignalDependencyGraph &sig_g) { |
---|
62 | typedef set<const equi_t *> nonSource_t; |
---|
63 | nonSource_t nonSource; |
---|
64 | SignalDependencyGraph::iterator it; |
---|
65 | for (it = sig_g.begin(); it != sig_g.end(); ++it) { |
---|
66 | const SignalDependency &sigDep = *it; |
---|
67 | const equi_t * dest = sigDep.destination; |
---|
68 | nonSource.insert(dest); |
---|
69 | } |
---|
70 | |
---|
71 | for (it = sig_g.begin(); it != sig_g.end(); ++it) { |
---|
72 | const SignalDependency &sigDep = *it; |
---|
73 | const equi_t * src = sigDep.source; |
---|
74 | if (nonSource.find(src) == nonSource.end()) { |
---|
75 | ss.insert(sigDep); |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | static void removeSignals(SignalDependencyGraph &sig_g, signalDependencySet &ss) { |
---|
82 | SignalDependencyGraph::iterator it = sig_g.begin(); |
---|
83 | while (it != sig_g.end()) { |
---|
84 | const SignalDependency &sigDep = *it; |
---|
85 | if (ss.find(sigDep) != ss.end()) { |
---|
86 | SignalDependencyGraph::iterator jt = it++; |
---|
87 | sig_g.erase(jt); |
---|
88 | } |
---|
89 | else { |
---|
90 | ++it; |
---|
91 | } |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | ProcessDependencyList * MakeMouchardScheduling(const SignalDependencyGraph & _sig_g) { |
---|
97 | if (dump_stage) { |
---|
98 | cerr << "Making process dependency list...\n"; |
---|
99 | } |
---|
100 | ProcessDependencyList * mod_l = new ProcessDependencyList (); |
---|
101 | SignalDependencyGraph sig_g = _sig_g; |
---|
102 | while (!sig_g.empty ()) { |
---|
103 | signalDependencySet ss; |
---|
104 | getSource(ss, sig_g); |
---|
105 | removeSignals(sig_g, ss); |
---|
106 | processSet ps; |
---|
107 | signalDependencySet::iterator sit; |
---|
108 | for (sit = ss.begin(); sit != ss.end(); ++sit) { |
---|
109 | const SignalDependency & sigdep = *sit; |
---|
110 | const method_process_t * process = sigdep.method; |
---|
111 | ps.insert(process); |
---|
112 | } |
---|
113 | processSet::iterator pit; |
---|
114 | for (pit = ps.begin(); pit != ps.end(); ++pit) { |
---|
115 | const method_process_t * process = *pit; |
---|
116 | mod_l->push_back(process); |
---|
117 | if (dump_stage) { |
---|
118 | cerr << "Process found : " << *process << "\n"; |
---|
119 | } |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | return mod_l; |
---|
124 | } |
---|
125 | |
---|
126 | } // end of sc_core namespace |
---|
127 | |
---|
128 | /* |
---|
129 | # Local Variables: |
---|
130 | # tab-width: 4; |
---|
131 | # c-basic-offset: 4; |
---|
132 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
133 | # indent-tabs-mode: nil; |
---|
134 | # End: |
---|
135 | # |
---|
136 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
137 | */ |
---|
138 | |
---|