OpenASIP  2.0
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 
43 using std::map;
44 using std::set;
45 using std::vector;
46 using std::string;
47 using std::pair;
48 
49 namespace 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 
60 namespace TTAProgram {
61  class Program;
62  class Procedure;
63 }
64 
65 namespace TPEF {
66  class Binary;
67 }
68 
69 using namespace TTAMachine;
70 using namespace TTAProgram;
71 
73 class MinimalOpSetCheck;
74 
76 public:
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
89  MISSING_CONNECTION
90  };
91 
94 
97  const std::set<ErrorCode>& errorsToCheck);
98 
99  void checkPrimitiveSet(ProgrammabilityValidatorResults& results) const;
100  void findConnections();
101  void printConnections();
102  void printRegisterConnections();
103  const RegisterFile* findGlobalConnectionRegister();
104  void findGlobalRegisterConnections();
105  void printNotConnectedSockets(const RegisterFile* rf);
106  void searchMissingRFConnections(const RegisterFile* rf,
107  vector<pair<string,
108  string> >& toConnections,
109  vector<pair<string,
110  string> >& fromConnections);
111  bool checkBooleanRegister(
114 
115 private:
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
126  addOperationConnections(const FunctionUnit* fu,
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 
151  void addDirectConnectionsToProgram();
152  void addGlobalRegisterConnectionsToProgram();
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.
180  struct ConnectionSet {
181  const Port* sourcePort;
182  const Port* destPort;
184  };
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
ProgrammabilityValidator::minimalOpSetCheck_
MinimalOpSetCheck * minimalOpSetCheck_
Minimal operation checker.
Definition: ProgrammabilityValidator.hh:165
TTAProgram
Definition: Estimator.hh:65
ProgrammabilityValidator::Connections
Struct of connections.
Definition: ProgrammabilityValidator.hh:171
ProgrammabilityValidator::machine_
const Machine & machine_
the target machine
Definition: ProgrammabilityValidator.hh:155
ProgrammabilityValidator::gcrConnections
set< pair< const Port *, const Port * > > gcrConnections
Definition: ProgrammabilityValidator.hh:194
TTAProgram::Program
Definition: Program.hh:63
MinimalOpSetCheck
Definition: MinimalOpSetCheck.hh:53
ProgrammabilityValidator::GLOBAL_CONNECTION_REGISTER_NOT_FOUND
@ GLOBAL_CONNECTION_REGISTER_NOT_FOUND
Global connection register could not be determined.
Definition: ProgrammabilityValidator.hh:87
ProgrammabilityValidator::registerRegisterConnections
set< pair< const RegisterFile *, const RegisterFile * > > registerRegisterConnections
Definition: ProgrammabilityValidator.hh:200
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::HWOperation
Definition: HWOperation.hh:52
Exception.hh
ProgrammabilityValidator::RFConnections
map< string, map< const Socket *, Connections > > RFConnections
Register file connections.
Definition: ProgrammabilityValidator.hh:216
ProgrammabilityValidator::portRegisterConnections
set< pair< const Port *, const RegisterFile * > > portRegisterConnections
Set of unit connections to ensure that only one connection per register file is added.
Definition: ProgrammabilityValidator.hh:198
ProgrammabilityValidator::gcrRegisterConnections
set< pair< const RegisterFile *, const RegisterFile * > > gcrRegisterConnections
Definition: ProgrammabilityValidator.hh:204
TTAMachine::Segment
Definition: Segment.hh:54
ProgrammabilityValidatorResults
Definition: ProgrammabilityValidatorResults.hh:46
ProgrammabilityValidator::inputs
vector< pair< const Port *, set< Segment * > > > inputs
All inputs found in the machine are stored here.
Definition: ProgrammabilityValidator.hh:168
TPEF::Binary
Definition: Binary.hh:49
ProgrammabilityValidator::gcrPortConnections
set< pair< const RegisterFile *, const Port * > > gcrPortConnections
Definition: ProgrammabilityValidator.hh:203
ProgrammabilityValidator::Connections::outputs
set< Segment * > outputs
Definition: ProgrammabilityValidator.hh:173
ProgrammabilityValidator::program_
Program * program_
Program where moves are generated.
Definition: ProgrammabilityValidator.hh:157
ProgrammabilityValidator::Connections::triggeredInputs
set< Segment * > triggeredInputs
Definition: ProgrammabilityValidator.hh:174
ProgrammabilityValidator::GCUConnections
map< string, map< const Socket *, Connections > > GCUConnections
Global control unit connections.
Definition: ProgrammabilityValidator.hh:214
ProgrammabilityValidator::allConnections
set< pair< const Port *, const Port * > > allConnections
Set of connections to ensure that same Move is not done in multiple buses.
Definition: ProgrammabilityValidator.hh:193
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
ProgrammabilityValidator::globalConnectionRegister_
RegisterFile * globalConnectionRegister_
The global connection register of the machine.
Definition: ProgrammabilityValidator.hh:163
ProgrammabilityValidator::registerPortConnections
set< pair< const RegisterFile *, const Port * > > registerPortConnections
Definition: ProgrammabilityValidator.hh:199
ProgrammabilityValidator::Connections::inputs
set< Segment * > inputs
Definition: ProgrammabilityValidator.hh:172
ProgrammabilityValidator::gcrCounter
int gcrCounter
The counter of global register file connections added to the program.
Definition: ProgrammabilityValidator.hh:189
ProgrammabilityValidator::ConnectionSet::sourcePort
const Port * sourcePort
Definition: ProgrammabilityValidator.hh:181
TTAMachine::RegisterGuard
Definition: Guard.hh:137
ProgrammabilityValidator::BOOLEAN_REGISTER_ERROR
@ BOOLEAN_REGISTER_ERROR
Machine should have one and only one boolean register.
Definition: ProgrammabilityValidator.hh:83
ProgrammabilityValidator::portSetIter
set< pair< const Port *, const Port * > >::iterator portSetIter
type definition for going through connection sets
Definition: ProgrammabilityValidator.hh:223
TTAMachine::Port
Definition: Port.hh:54
ProgrammabilityValidator::FUConnections
map< string, map< const Socket *, Connections > > FUConnections
Function unit connections.
Definition: ProgrammabilityValidator.hh:212
ProgrammabilityValidator::OPERATION_MISSING_FROM_THE_PRIMITIVE_OPERATION_SET
@ OPERATION_MISSING_FROM_THE_PRIMITIVE_OPERATION_SET
Machine don't have all the operations needed to support ANSI C.
Definition: ProgrammabilityValidator.hh:81
ProgrammabilityValidator::BOOLEAN_REGISTER_GUARD_MISSING
@ BOOLEAN_REGISTER_GUARD_MISSING
Bus is missing a boolean register file guard.
Definition: ProgrammabilityValidator.hh:85
TTAMachine::Socket
Definition: Socket.hh:53
ProgrammabilityValidator
Definition: ProgrammabilityValidator.hh:75
ProgrammabilityValidator::ConnectionSet::destPort
const Port * destPort
Definition: ProgrammabilityValidator.hh:182
ProgrammabilityValidator::IMMConnections
map< string, map< const Socket *, Connections > > IMMConnections
Immediate unit connections.
Definition: ProgrammabilityValidator.hh:218
ProgrammabilityValidator::registerRegisterSetIter
set< pair< const RegisterFile *, const RegisterFile * > >::iterator registerRegisterSetIter
Definition: ProgrammabilityValidator.hh:224
ProgrammabilityValidator::ErrorCode
ErrorCode
Error codes for different errors.
Definition: ProgrammabilityValidator.hh:79
ProgrammabilityValidator::ConnectionSet::segment
Segment * segment
Definition: ProgrammabilityValidator.hh:183
ProgrammabilityValidator::mapIter
map< string, map< const Socket *, Connections > >::iterator mapIter
type definition for going through connection maps
Definition: ProgrammabilityValidator.hh:221
ProgrammabilityValidator::directConnections
vector< ConnectionSet > directConnections
Storage of all the Moves that are found in the machine.
Definition: ProgrammabilityValidator.hh:207
ProgrammabilityValidator::portRegisterSetIter
set< pair< const Port *, const RegisterFile * > >::iterator portRegisterSetIter
Definition: ProgrammabilityValidator.hh:225
ProgrammabilityValidator::directCounter
int directCounter
The counter of direct connections added to the program.
Definition: ProgrammabilityValidator.hh:187
ProgrammabilityValidator::Connections::registers
int registers
Definition: ProgrammabilityValidator.hh:176
ProgrammabilityValidator::booleanRegister_
RegisterFile * booleanRegister_
Boolean register file of the machine.
Definition: ProgrammabilityValidator.hh:161
ProgrammabilityValidator::registerPortSetIter
set< pair< const RegisterFile *, const Port * > >::iterator registerPortSetIter
Definition: ProgrammabilityValidator.hh:226
ProgrammabilityValidator::ConnectionSet
Moves are generated from these.
Definition: ProgrammabilityValidator.hh:180
ProgrammabilityValidator::portGcrConnections
set< pair< const Port *, const RegisterFile * > > portGcrConnections
Definition: ProgrammabilityValidator.hh:202
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine
Definition: Assembler.hh:48
TTAProgram::Procedure
Definition: Procedure.hh:55
ProgrammabilityValidator::globalRegisterConnections
vector< ConnectionSet > globalRegisterConnections
Storage of all Moves to and from the Global Connection Register.
Definition: ProgrammabilityValidator.hh:209
ProgrammabilityValidator::Connections::operations
set< HWOperation * > operations
Definition: ProgrammabilityValidator.hh:175
TPEF
Definition: Assembler.hh:43
TTAMachine::Machine
Definition: Machine.hh:73
ProgrammabilityValidator::procedure_
Procedure * procedure_
Procedure of the program.
Definition: ProgrammabilityValidator.hh:159