Switch to unified view

a b/src/DAF/AE/AE.cc
1
//
2
// This program is free software: you can redistribute it and/or modify
3
// it under the terms of the GNU Lesser General Public License as published by
4
// the Free Software Foundation, either version 3 of the License, or
5
// (at your option) any later version.
6
// 
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
// GNU Lesser General Public License for more details.
11
// 
12
// You should have received a copy of the GNU Lesser General Public License
13
// along with this program.  If not, see http://www.gnu.org/licenses/.
14
// 
15
16
#include "AE.h"
17
18
Define_Module(AE);
19
20
AE::AE()  {
21
}
22
23
AE::~AE() {
24
}
25
26
void AE::initSignalsAndListeners() {
27
    //cModule* catcher = this->getParentModule()->getParentModule();
28
29
    //Signals that this module is emitting
30
    sigAEAllocReq      = registerSignal(SIG_AE_AllocateRequest);
31
    sigAEDeallocReq    = registerSignal(SIG_AE_DeallocateRequest);
32
33
    //Signals that this module is processing
34
35
}
36
37
void AE::initialize() {
38
    //Init pointers
39
    initPointers();
40
    //Source info
41
    initNamingInfo();
42
    //Setup signals
43
    initSignalsAndListeners();
44
    //Watchers
45
    WATCH_LIST(flows);
46
}
47
48
void AE::handleMessage(cMessage* msg) {
49
}
50
51
void AE::createBinding(Flow& flow) {
52
    EV << this->getFullPath() << " created bindings and registered a new flow" << endl;
53
    //Create new gates
54
    cGate* g1i;
55
    cGate* g1o;
56
    Irm->getOrCreateFirstUnconnectedGatePair(GATE_AEIO, false, true, *&g1i, *&g1o);
57
58
    //cGate* g0i;
59
    //cGate* g0o;
60
    //this->getOrCreateFirstUnconnectedGatePair("southIo", true, true, *&g0i, *&g0o);
61
62
    //Get AE gates
63
    cGate* g2i;
64
    cGate* g2o;
65
    this->getOrCreateFirstUnconnectedGatePair(GATE_DATAIO, false, true, *&g2i, *&g2o);
66
67
    //Connect gates together
68
    g1o->connectTo(g2i);
69
    g2o->connectTo(g1i);
70
71
    //Set north-half of the routing in ConnectionTable
72
    ConTab->setNorthGates(&flow, g1i, g1o);
73
}
74
75
void AE::initPointers() {
76
    Irm = ModuleAccess<IRM>(MOD_IRM).get();
77
    ConTab = ModuleAccess<ConnectionTable>(MOD_CONNTABLE).get();
78
}
79
80
void AE::signalizeAllocateRequest(Flow* flow) {
81
    emit(sigAEAllocReq, flow);
82
}
83
84
void AE::insertFlow(Flow& flow) {
85
    //Add a new flow to the end of the Flow list
86
    flows.push_back(flow);
87
88
    //Create a new record in ConnectionTable
89
    ConTab->insertNew(&flows.back());
90
91
    //Interconnect IRM and AE
92
    createBinding(flows.back());
93
}
94
95
void AE::signalizeDeallocateRequest(Flow* flow) {
96
    emit(sigAEDeallocReq, flow);
97
}
98
99