OpenASIP 2.2
Loading...
Searching...
No Matches
Machine.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 Machine.hh
26 *
27 * Declaration of Machine class.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 * @note reviewed 16 Jun 2004 by ml, tr, jm, ll
31 * @note rating: red
32 */
33
34#ifndef TTA_MACHINE_HH
35#define TTA_MACHINE_HH
36
37#include <vector>
38#include <string>
39
40#include "Exception.hh"
41#include "Serializable.hh"
42#include "TCEString.hh"
43
44class MachineTester;
46
47namespace TTAMachine {
48
49class Bus;
50class Socket;
51class AddressSpace;
52class Unit;
53class Bridge;
54class InstructionTemplate;
55class FunctionUnit;
56class ImmediateUnit;
57class RegisterFile;
58class Machine;
59class ControlUnit;
60class Component;
61class ImmediateSlot;
62class OperationTriggeredFormat;
63
64template <typename ComponentType>
66
67template <typename ComponentType>
69
70/**
71 * Represents a complete TTA processor.
72 */
73class Machine : public Serializable {
74public:
75
76 /**
77 * Extension mode applied to a number when it is narrower than the place
78 * where it is placed e.g. bus.
79 */
80 enum Extension {
81 ZERO, ///< Zero extension.
82 SIGN ///< Sign extension.
83 };
84
85 Machine();
86 Machine(const Machine& old);
87 virtual ~Machine();
88
89 virtual bool isUniversalMachine() const;
90
91 virtual void addBus(Bus& bus);
92 virtual void addSocket(Socket& socket);
93 void addUnit(Unit& unit);
94 virtual void addFunctionUnit(FunctionUnit& unit);
95 virtual void addImmediateUnit(ImmediateUnit& unit);
96 virtual void addRegisterFile(RegisterFile& unit);
97 virtual void addAddressSpace(AddressSpace& as);
98 virtual void addBridge(Bridge& bridge);
99 virtual void addInstructionTemplate(InstructionTemplate& instrTempl);
100 virtual void addOperationTriggeredFormat(
102 virtual void addImmediateSlot(ImmediateSlot& slot);
103 virtual void setGlobalControl(ControlUnit& unit);
104 virtual void unsetGlobalControl();
105
106 virtual ControlUnit* controlUnit() const;
107
108 virtual void removeBus(Bus& bus);
109 virtual void removeSocket(Socket& socket);
110 virtual void removeUnit(Unit& unit);
111 virtual void removeFunctionUnit(FunctionUnit& unit);
112 virtual void removeImmediateUnit(ImmediateUnit& unit);
113 virtual void removeRegisterFile(RegisterFile& unit);
114 virtual void deleteBridge(Bridge& bridge);
115 virtual void deleteInstructionTemplate(InstructionTemplate& instrTempl);
118 virtual void deleteImmediateSlot(ImmediateSlot& slot);
119 virtual void deleteAddressSpace(AddressSpace& as);
120
121 void setBusPosition(const Bus& bus, int newPosition);
122
124
125 bool alwaysWriteResults() const;
126 bool triggerInvalidatesResults() const;
127 bool isFUOrdered() const;
128 void setAlwaysWriteResults(bool);
130 void setFUOrdered(bool);
131
132 int maximumLatency() const;
133
134 // functions inherited from Serializable interface
135 virtual void loadState(const ObjectState* state);
136 virtual ObjectState* saveState() const;
137
138 virtual void copyFromMachine(Machine& machine);
139
140 static Machine* loadFromADF(const std::string& adfFileName);
141
142 void writeToADF(const std::string& adfFileName) const;
143
144 TCEString hash() const;
145
146 bool hasOperation(const TCEString& opName) const;
147 bool isRISCVMachine() const;
148
149 /**
150 * A template class which contains machine components.
151 */
152 template <typename ComponentType>
154 public:
157
158 void addComponent(ComponentType* component);
159 void removeComponent(ComponentType* component);
160 void deleteAll();
161 ComponentType* item(int index) const;
162 ComponentType* item(const std::string& name) const;
163 int count() const;
164 void moveToPosition(const ComponentType* component, int position);
165
166 /// Table of ComponentType pointers.
167 typedef std::vector<ComponentType*> ComponentTable;
168
169 typedef typename ComponentTable::const_iterator const_iterator;
170
171 const_iterator begin() const noexcept;
172 const_iterator end() const noexcept;
173
174 private:
175 /// Contains all the components of the container.
177 };
178
179 /**
180 * A template class which is a handle to a ComponentContainer.
181 *
182 * An instance of this class is intended to return outside the Machine
183 * class to allow clients to access individual components in Machine.
184 */
185 template <typename ComponentType>
186 class Navigator {
187 public:
191
192 Navigator(const Navigator& old);
194
195 ComponentType* item(int index) const;
196 ComponentType* item(const std::string& name) const;
197 bool hasItem(const std::string& name) const;
198 int count() const;
199
200 typedef typename
203
204 const_iterator begin() const noexcept;
205 const_iterator end() const noexcept;
206
207 private:
208 /// The container which this navigator handles.
209 const Machine::ComponentContainer<ComponentType>* container_;
210 };
211
212 /// Navigator type for BusNavigator.
214 /// Navigator type for SocketNavigator.
216 /// Navigator type for FunctionUnitNavigator.
218 /// Navigator type for AddressSpaceNavigator.
220 /// Navigator type for BridgeNavigator.
222 /// Navigator type for ImmediateUnitNavigator.
224 /// Navigator type for InstructionTemplateNavigator.
226 /// Navigator type for RegisterFileNavigator.
228 /// Navigator type for ImmediateSlotNavigator.
230 /// Navigator type for OperationTriggeredFormatNavigator
233
234 virtual BusNavigator busNavigator() const;
235 virtual SocketNavigator socketNavigator() const;
238 virtual BridgeNavigator bridgeNavigator() const;
241 const;
246
247
248 /// ObjectState name for Machine.
249 static const std::string OSNAME_MACHINE;
250 /// ObjectState attribute key for always-write-back-results.
251 static const std::string OSKEY_ALWAYS_WRITE_BACK_RESULTS;
252 /// ObjectState attribute key for trigger-invalidates-old-results
254 /// ObjectState attribute key for function units ordered in order
255 /// of their sequential presence in ADF
256 static const std::string OSKEY_FUNCTION_UNITS_ORDERED;
257
258 bool isLittleEndian() const { return littleEndian_; }
259 void setLittleEndian(bool flag) { littleEndian_ = flag; }
260 bool is64bit() const { return bitness64_; }
261 void set64bits(bool flag) { bitness64_ = flag; }
262private:
263 /// Assignment not allowed.
265
266 template <typename ContainerType, typename ComponentType>
267 void addComponent(ContainerType& container, ComponentType& toAdd);
268
269 template <typename ContainerType, typename ComponentType>
270 void addRegisteredComponent(ContainerType& container, ComponentType& toAdd);
271
272 template <typename ContainerType, typename ComponentType>
273 void removeComponent(ContainerType& container, ComponentType& toRemove);
274
275 template <typename ContainerType, typename ComponentType>
276 void deleteComponent(ContainerType& container, ComponentType& toDelete);
277
278 template <typename ContainerType>
279 static void saveComponentStates(
280 ContainerType& container,
281 ObjectState* parent);
282
283 /// Contains all the busses attached to the machine.
285 /// Contains all the sockets attached to the machine.
287 /// Contains all the instruction templates of the machine.
289 /// Contains all the register files of the machine.
291 /// Contains all the immediate units of the machine.
293 /// Contains all the function units of the machine.
295 /// Contains all the address spaces of the machine.
297 /// Contains all the bridges of the machine.
299 /// Contains all the immediate slots of the machine.
301 /// Contains all the OTA Formats of the machine.
303
304 /// Global control unit.
306
307 /// Tells whether to do validity checks or not.
309 /// Machine tester for the machine.
311 /// Dummy machine tester for the machine.
313
314 // Name of the empty instruction template created by default.
315 const std::string EMPTY_ITEMP_NAME_;
316
317 // Result move have to be always written to register. Effectively
318 // disable dead result read elimination.
320 // Triggering invalidates content of register where value of result will be
321 // written. Previous value can not be read any more.
323 // Function units relative order can be important (SPU).
324 // If set to 1, each FU will be given order id based on their sequential
325 // ordering in the ADF.
327 // True in case the machine is little-endian, big-endian otherwise.
329 // True in case the machine is 64-bit. Also has to be little-endian.
331};
332}
333
334#include "Machine.icc"
335
336#endif
TTAMachine::Machine * machine
the architecture definition of the estimated processor
ComponentTable::const_iterator const_iterator
Definition Machine.hh:169
std::vector< ComponentType * > ComponentTable
Table of ComponentType pointers.
Definition Machine.hh:167
void addComponent(ComponentType *component)
const_iterator begin() const noexcept
ComponentType * item(const std::string &name) const
ComponentType * item(int index) const
void removeComponent(ComponentType *component)
const_iterator end() const noexcept
ComponentTable components_
Contains all the components of the container.
Definition Machine.hh:176
void moveToPosition(const ComponentType *component, int position)
Navigator(const Navigator &old)
Machine::ComponentContainer< ComponentType >::const_iterator const_iterator
Definition Machine.hh:202
const_iterator begin() const noexcept
Navigator(const Machine::ComponentContainer< ComponentType > &container)
ComponentType * item(const std::string &name) const
Navigator & operator=(const Navigator &old)
ComponentType * item(int index) const
bool hasItem(const std::string &name) const
bool triggerInvalidatesResults() const
Definition Machine.cc:958
ComponentContainer< RegisterFile > registerFiles_
Contains all the register files of the machine.
Definition Machine.hh:290
void setLittleEndian(bool flag)
Definition Machine.hh:259
virtual void deleteOperationTriggeredFormat(OperationTriggeredFormat &format)
Definition Machine.cc:611
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition Machine.cc:462
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
Machine & operator=(const Machine &)
Assignment not allowed.
virtual BridgeNavigator bridgeNavigator() const
Definition Machine.cc:404
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition Machine.cc:428
virtual void deleteInstructionTemplate(InstructionTemplate &instrTempl)
Definition Machine.cc:599
bool isLittleEndian() const
Definition Machine.hh:258
virtual SocketNavigator socketNavigator() const
Definition Machine.cc:368
static void saveComponentStates(ContainerType &container, ObjectState *parent)
Definition Machine.cc:1012
void setTriggerInvalidatesResults(bool)
Definition Machine.cc:987
const std::string EMPTY_ITEMP_NAME_
Definition Machine.hh:315
MachineTester & machineTester() const
Definition Machine.cc:671
virtual void copyFromMachine(Machine &machine)
Definition Machine.cc:884
DummyMachineTester * dummyMachineTester_
Dummy machine tester for the machine.
Definition Machine.hh:312
void deleteComponent(ContainerType &container, ComponentType &toDelete)
virtual void addInstructionTemplate(InstructionTemplate &instrTempl)
Definition Machine.cc:275
bool hasOperation(const TCEString &opName) const
Definition Machine.cc:1042
MachineTester * machineTester_
Machine tester for the machine.
Definition Machine.hh:310
virtual void removeBus(Bus &bus)
Definition Machine.cc:477
bool alwaysWriteResults() const
Definition Machine.cc:948
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
ComponentContainer< Bridge > bridges_
Contains all the bridges of the machine.
Definition Machine.hh:298
static const std::string OSKEY_ALWAYS_WRITE_BACK_RESULTS
ObjectState attribute key for always-write-back-results.
Definition Machine.hh:251
void addComponent(ContainerType &container, ComponentType &toAdd)
virtual BusNavigator busNavigator() const
Definition Machine.cc:356
virtual void addFunctionUnit(FunctionUnit &unit)
Definition Machine.cc:202
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392
virtual void addBus(Bus &bus)
Definition Machine.cc:139
void set64bits(bool flag)
Definition Machine.hh:261
virtual void addBridge(Bridge &bridge)
Definition Machine.cc:263
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345
TCEString hash() const
Definition Machine.cc:926
ComponentContainer< ImmediateUnit > immediateUnits_
Contains all the immediate units of the machine.
Definition Machine.hh:292
ComponentContainer< ImmediateSlot > immediateSlots_
Contains all the immediate slots of the machine.
Definition Machine.hh:300
virtual bool isUniversalMachine() const
Definition Machine.cc:127
@ SIGN
Sign extension.
Definition Machine.hh:82
@ ZERO
Zero extension.
Definition Machine.hh:81
virtual void addImmediateUnit(ImmediateUnit &unit)
Definition Machine.cc:224
void writeToADF(const std::string &adfFileName) const
Definition Machine.cc:907
virtual void addRegisterFile(RegisterFile &unit)
Definition Machine.cc:236
static const std::string OSKEY_TRIGGER_INVALIDATES_OLD_RESULTS
ObjectState attribute key for trigger-invalidates-old-results.
Definition Machine.hh:253
ControlUnit * controlUnit_
Global control unit.
Definition Machine.hh:305
virtual void loadState(const ObjectState *state)
Definition Machine.cc:728
virtual void unsetGlobalControl()
Definition Machine.cc:565
virtual void deleteBridge(Bridge &bridge)
Definition Machine.cc:587
ComponentContainer< OperationTriggeredFormat > operationTriggeredFormats_
Contains all the OTA Formats of the machine.
Definition Machine.hh:302
ComponentContainer< FunctionUnit > functionUnits_
Contains all the function units of the machine.
Definition Machine.hh:294
bool is64bit() const
Definition Machine.hh:260
ComponentContainer< AddressSpace > addressSpaces_
Contains all the address spaces of the machine.
Definition Machine.hh:296
void addRegisteredComponent(ContainerType &container, ComponentType &toAdd)
virtual ObjectState * saveState() const
Definition Machine.cc:686
virtual void deleteAddressSpace(AddressSpace &as)
Definition Machine.cc:623
void setBusPosition(const Bus &bus, int newPosition)
Definition Machine.cc:651
ComponentContainer< InstructionTemplate > instructionTemplates_
Contains all the instruction templates of the machine.
Definition Machine.hh:288
virtual void removeSocket(Socket &socket)
Definition Machine.cc:490
virtual ~Machine()
Definition Machine.cc:114
virtual void setGlobalControl(ControlUnit &unit)
Definition Machine.cc:317
void removeComponent(ContainerType &container, ComponentType &toRemove)
bool triggerInvalidatesResults_
Definition Machine.hh:322
static const std::string OSKEY_FUNCTION_UNITS_ORDERED
ObjectState attribute key for function units ordered in order of their sequential presence in ADF.
Definition Machine.hh:256
virtual void addImmediateSlot(ImmediateSlot &slot)
Definition Machine.cc:299
virtual void removeFunctionUnit(FunctionUnit &unit)
Definition Machine.cc:530
static const std::string OSNAME_MACHINE
ObjectState name for Machine.
Definition Machine.hh:249
virtual OperationTriggeredFormatNavigator operationTriggeredFormatNavigator() const
Definition Machine.cc:439
virtual void removeUnit(Unit &unit)
Definition Machine.cc:505
bool doValidityChecks_
Tells whether to do validity checks or not.
Definition Machine.hh:308
virtual void removeImmediateUnit(ImmediateUnit &unit)
Definition Machine.cc:542
void setAlwaysWriteResults(bool)
Definition Machine.cc:979
void setFUOrdered(bool)
Definition Machine.cc:999
virtual void addOperationTriggeredFormat(OperationTriggeredFormat &format)
Definition Machine.cc:287
ComponentContainer< Socket > sockets_
Contains all the sockets attached to the machine.
Definition Machine.hh:286
ComponentContainer< Bus > busses_
Contains all the busses attached to the machine.
Definition Machine.hh:284
static Machine * loadFromADF(const std::string &adfFileName)
Definition Machine.cc:899
virtual void addAddressSpace(AddressSpace &as)
Definition Machine.cc:248
int maximumLatency() const
Definition Machine.cc:1023
virtual void addSocket(Socket &socket)
Definition Machine.cc:157
void addUnit(Unit &unit)
Definition Machine.cc:175
bool isRISCVMachine() const
Definition Machine.cc:1057
virtual void removeRegisterFile(RegisterFile &unit)
Definition Machine.cc:554
virtual void deleteImmediateSlot(ImmediateSlot &slot)
Definition Machine.cc:635
bool isFUOrdered() const
Definition Machine.cc:971