OpenASIP 2.2
Loading...
Searching...
No Matches
ProgrammabilityValidator.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/*
25 * @file ProgrammabilityValidator.cc
26 *
27 * Header file for ProgrammabilityValidator.
28 *
29 * @author Jari Mäntyneva 2006 (jari.mantyneva-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_PROGRAMMABILITY_VALIDATOR_HH
34#define TTA_PROGRAMMABILITY_VALIDATOR_HH
35
36#include <string>
37#include <set>
38#include <vector>
39#include <map>
40
41#include "Exception.hh"
42
43using std::map;
44using std::set;
45using std::vector;
46using std::string;
47using std::pair;
48
49namespace TTAMachine {
50 class Machine;
51 class RegisterGuard;
52 class RegisterFile;
53 class Segment;
54 class Port;
55 class FunctionUnit;
56 class HWOperation;
57 class Socket;
58}
59
60namespace TTAProgram {
61 class Program;
62 class Procedure;
63}
64
65namespace TPEF {
66 class Binary;
67}
68
69using namespace TTAMachine;
70using namespace TTAProgram;
71
74
76public:
77
78 /// Error codes for different errors.
79 enum ErrorCode {
80 /// Machine don't have all the operations needed to support ANSI C.
82 /// Machine should have one and only one boolean register.
84 /// Bus is missing a boolean register file guard.
86 /// Global connection register could not be determined.
88 /// Connection is missing to or from the global connection register
90 };
91
94
97 const std::set<ErrorCode>& errorsToCheck);
98
100 void findConnections();
101 void printConnections();
107 vector<pair<string,
108 string> >& toConnections,
109 vector<pair<string,
110 string> >& fromConnections);
114
115private:
116 void
117 addConnectionToProgram(const Port* sourcePort,
118 const Port* destPort,
119 Segment* segment,
120 int& counter);
121
122 void
123 addConnections(set<Segment*>& newConnections,
124 set<Segment*>& connections);
125 void
127 set<HWOperation*>& operations);
128
129 void
130 listConnections(set<Segment*>& connections,
131 const Socket* socket);
132 void
133 printConnection(const Port* sourcePort,
134 const Port* destPort,
135 Segment* segment,
136 int& counter);
137
138 void
139 findRegisterGuard(Segment* segment, RegisterGuard*& guard);
140
141 void
142 addDirectConnection(const Port* sourcePort,
143 const Port* destPort,
144 Segment* segment);
145
146 void
147 addGlobalRegisterConnection(const Port* sourcePort,
148 const Port* destPort,
149 Segment* segment);
150
153
154 /// the target machine
156 /// Program where moves are generated
158 /// Procedure of the program
160 /// Boolean register file of the machine
162 /// The global connection register of the machine
164 /// Minimal operation checker
166
167 /// All inputs found in the machine are stored here.
168 vector<pair<const Port*, set<Segment*> > > inputs;
169
170 /// Struct of connections.
171 struct Connections {
172 set<Segment*> inputs;
173 set<Segment*> outputs;
174 set<Segment*> triggeredInputs;
175 set<HWOperation*> operations;
177 };
178
179 /// Moves are generated from these.
185
186 /// The counter of direct connections added to the program.
188 /// The counter of global register file connections added to the program.
190
191 /// Set of connections to ensure that same Move is not done in multiple
192 /// buses
193 set<pair<const Port*, const Port*> > allConnections;
194 set<pair<const Port*, const Port*> > gcrConnections;
195
196 /// Set of unit connections to ensure that only one connection per
197 /// register file is added
198 set<pair<const Port*, const RegisterFile*> > portRegisterConnections;
199 set<pair<const RegisterFile*, const Port*> > registerPortConnections;
200 set<pair<const RegisterFile*, const RegisterFile*> > registerRegisterConnections;
201
202 set<pair<const Port*, const RegisterFile*> > portGcrConnections;
203 set<pair<const RegisterFile*, const Port*> > gcrPortConnections;
204 set<pair<const RegisterFile*, const RegisterFile*> > gcrRegisterConnections;
205
206 /// Storage of all the Moves that are found in the machine
207 vector<ConnectionSet> directConnections;
208 /// Storage of all Moves to and from the Global Connection Register
209 vector<ConnectionSet> globalRegisterConnections;
210
211 /// Function unit connections
212 map<string, map<const Socket*, Connections> > FUConnections;
213 /// Global control unit connections
214 map<string, map<const Socket*, Connections> > GCUConnections;
215 /// Register file connections
216 map<string, map<const Socket*, Connections> > RFConnections;
217 /// Immediate unit connections
218 map<string, map<const Socket*, Connections> > IMMConnections;
219
220 /// type definition for going through connection maps
221 typedef map<string, map<const Socket*, Connections> >::iterator mapIter;
222 /// type definition for going through connection sets
223 typedef set<pair<const Port*, const Port*> >::iterator portSetIter;
224 typedef set<pair<const RegisterFile*, const RegisterFile*> >::iterator registerRegisterSetIter;
225 typedef set<pair<const Port*, const RegisterFile*> >::iterator portRegisterSetIter;
226 typedef set<pair<const RegisterFile*, const Port*> >::iterator registerPortSetIter;
227};
228
229#endif
TTAMachine::Machine * machine
the architecture definition of the estimated processor
set< pair< const RegisterFile *, const RegisterFile * > > gcrRegisterConnections
void addOperationConnections(const FunctionUnit *fu, set< HWOperation * > &operations)
void searchMissingRFConnections(const RegisterFile *rf, vector< pair< string, string > > &toConnections, vector< pair< string, string > > &fromConnections)
map< string, map< const Socket *, Connections > > FUConnections
Function unit connections.
set< pair< constPort *, constPort * > >::iterator portSetIter
type definition for going through connection sets
int gcrCounter
The counter of global register file connections added to the program.
set< pair< constPort *, constRegisterFile * > >::iterator portRegisterSetIter
RegisterFile * booleanRegister_
Boolean register file of the machine.
ErrorCode
Error codes for different errors.
@ BOOLEAN_REGISTER_GUARD_MISSING
Bus is missing a boolean register file guard.
@ OPERATION_MISSING_FROM_THE_PRIMITIVE_OPERATION_SET
Machine don't have all the operations needed to support ANSI C.
@ GLOBAL_CONNECTION_REGISTER_NOT_FOUND
Global connection register could not be determined.
@ MISSING_CONNECTION
Connection is missing to or from the global connection register.
@ BOOLEAN_REGISTER_ERROR
Machine should have one and only one boolean register.
const Machine & machine_
the target machine
map< string, map< const Socket *, Connections > > RFConnections
Register file connections.
void addGlobalRegisterConnection(const Port *sourcePort, const Port *destPort, Segment *segment)
vector< pair< const Port *, set< Segment * > > > inputs
All inputs found in the machine are stored here.
set< pair< const Port *, const Port * > > gcrConnections
bool checkBooleanRegister(ProgrammabilityValidatorResults &results)
int directCounter
The counter of direct connections added to the program.
set< pair< const Port *, const Port * > > allConnections
Set of connections to ensure that same Move is not done in multiple buses.
set< pair< const RegisterFile *, const RegisterFile * > > registerRegisterConnections
void addDirectConnection(const Port *sourcePort, const Port *destPort, Segment *segment)
map< string, map< constSocket *, Connections > >::iterator mapIter
type definition for going through connection maps
RegisterFile * globalConnectionRegister_
The global connection register of the machine.
vector< ConnectionSet > globalRegisterConnections
Storage of all Moves to and from the Global Connection Register.
void checkPrimitiveSet(ProgrammabilityValidatorResults &results) const
void printConnection(const Port *sourcePort, const Port *destPort, Segment *segment, int &counter)
Procedure * procedure_
Procedure of the program.
void printNotConnectedSockets(const RegisterFile *rf)
void addConnectionToProgram(const Port *sourcePort, const Port *destPort, Segment *segment, int &counter)
map< string, map< const Socket *, Connections > > IMMConnections
Immediate unit connections.
void listConnections(set< Segment * > &connections, const Socket *socket)
MinimalOpSetCheck * minimalOpSetCheck_
Minimal operation checker.
const RegisterFile * findGlobalConnectionRegister()
set< pair< const Port *, const RegisterFile * > > portGcrConnections
TPEF::Binary * profile(ProgrammabilityValidatorResults &results)
set< pair< const RegisterFile *, const Port * > > gcrPortConnections
set< pair< constRegisterFile *, constRegisterFile * > >::iterator registerRegisterSetIter
vector< ConnectionSet > directConnections
Storage of all the Moves that are found in the machine.
map< string, map< const Socket *, Connections > > GCUConnections
Global control unit connections.
set< pair< const RegisterFile *, const Port * > > registerPortConnections
Program * program_
Program where moves are generated.
void addConnections(set< Segment * > &newConnections, set< Segment * > &connections)
set< pair< const Port *, const RegisterFile * > > portRegisterConnections
Set of unit connections to ensure that only one connection per register file is added.
ProgrammabilityValidatorResults * validate()
void findRegisterGuard(Segment *segment, RegisterGuard *&guard)
set< pair< constRegisterFile *, constPort * > >::iterator registerPortSetIter