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