OpenASIP  2.0
FunctionUnit.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 FunctionUnit.hh
26  *
27  * Declaration of FunctionUnit class.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  */
31 
32 #ifndef TTA_FUNCTION_UNIT_HH
33 #define TTA_FUNCTION_UNIT_HH
34 
35 #include <string>
36 #include <vector>
37 
38 #include "Unit.hh"
39 #include "BaseFUPort.hh"
40 #include "CIStringSet.hh"
41 
42 class ObjectState;
43 
44 namespace TTAMachine {
45 
46 class HWOperation;
47 class AddressSpace;
48 class HWOperation;
49 class FUPort;
50 class PipelineElement;
51 
52 /**
53  * Represents a function unit in machine object model.
54  */
55 class FunctionUnit : public Unit {
56 public:
57  FunctionUnit(const std::string& name);
58  FunctionUnit(const ObjectState* state);
59  virtual ~FunctionUnit();
60 
61  virtual FunctionUnit* copy() const;
62 
63  virtual void setName(const std::string& name);
64 
65  virtual BaseFUPort* port(const std::string& name) const;
66  virtual BaseFUPort* port(int index) const;
67  virtual int operationPortCount() const;
68  virtual bool hasOperationPort(const std::string& name) const;
69  virtual FUPort* operationPort(const std::string& name) const;
70  virtual FUPort* operationPort(int index) const;
71  virtual BaseFUPort* triggerPort() const;
72 
73  virtual void addOperation(HWOperation& operation);
74  virtual void deleteOperation(HWOperation& operation);
75 
76  virtual bool hasOperation(const std::string& name) const;
77  virtual bool hasOperationLowercase(const std::string& name) const;
78 
79  virtual HWOperation* operation(const std::string& name) const;
80  virtual HWOperation* operationLowercase(const std::string& name) const;
81 
82  virtual HWOperation* operation(int index) const;
83  virtual int operationCount() const;
84 
85  virtual void operationNames(TCETools::CIStringSet& opNames) const;
86 
87  virtual int maxLatency() const;
88 
89  virtual void addPipelineElement(PipelineElement& element);
90  virtual void deletePipelineElement(PipelineElement& element);
91 
92  virtual int pipelineElementCount() const;
93  virtual PipelineElement* pipelineElement(int index) const;
94  virtual bool hasPipelineElement(const std::string& name) const;
95  virtual PipelineElement* pipelineElement(const std::string& name) const;
96 
97  virtual AddressSpace* addressSpace() const;
98  virtual void setAddressSpace(AddressSpace* as);
99  virtual bool hasAddressSpace() const;
100 
101  virtual void cleanup(const std::string& resource);
102 
103  virtual void unsetMachine();
104 
105  virtual ObjectState* saveState() const;
106  virtual void loadState(const ObjectState* state);
107 
108  virtual bool isArchitectureEqual(
109  const FunctionUnit* fu, const bool checkPortWidths = true) const;
110 
111  bool needsConflictDetection() const;
112 
113  virtual int orderNumber() const;
114  virtual void setOrderNumber(int);
115 
116  /// ObjectState name for function unit.
117  static const std::string OSNAME_FU;
118  /// ObjectState attribute key for name of the address space.
119  static const std::string OSKEY_AS;
120  /// ObjectState attribute key for FU order number name.
121  static const std::string OSKEY_ORDER_NUMBER;
122 
123 protected:
124  void unsetMachineDerived();
125 
126 private:
127  /// Copying forbidden.
128  FunctionUnit(const FunctionUnit&);
129  /// Container for operations.
130  typedef std::vector<HWOperation*> OperationTable;
131  /// Container for pipeline elements.
132  typedef std::vector<PipelineElement*> PipelineElementTable;
133 
134  void cleanupGuards() const;
135  void loadStateWithoutReferences(const ObjectState* fuState);
136  void deleteAllOperations();
137 
138  /// Contains all the operations of the function unit.
140 
141  /// Contains all the pipeline elements of the function unit.
143 
144  /// Address space used by the function unit.
146 
147  /// Number indicating possition of the FU in the ADF file. Alows
148  /// putting the FU into the order in the instruction.
150 };
151 }
152 
153 #endif
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::FunctionUnit::OSNAME_FU
static const std::string OSNAME_FU
ObjectState name for function unit.
Definition: FunctionUnit.hh:117
TTAMachine::FunctionUnit::hasAddressSpace
virtual bool hasAddressSpace() const
Definition: FunctionUnit.cc:608
TTAMachine::FunctionUnit::FunctionUnit
FunctionUnit(const std::string &name)
Definition: FunctionUnit.cc:66
TTAMachine::FunctionUnit::OSKEY_ORDER_NUMBER
static const std::string OSKEY_ORDER_NUMBER
ObjectState attribute key for FU order number name.
Definition: FunctionUnit.hh:121
TTAMachine::HWOperation
Definition: HWOperation.hh:52
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
TTAMachine::FunctionUnit::cleanup
virtual void cleanup(const std::string &resource)
Definition: FunctionUnit.cc:622
TTAMachine::FunctionUnit::triggerPort
virtual BaseFUPort * triggerPort() const
Definition: FunctionUnit.cc:267
TTAMachine::BaseFUPort
Definition: BaseFUPort.hh:44
TTAMachine::FunctionUnit::addPipelineElement
virtual void addPipelineElement(PipelineElement &element)
Definition: FunctionUnit.cc:466
TTAMachine::FunctionUnit::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *fuState)
Definition: FunctionUnit.cc:872
TTAMachine::FunctionUnit::operationLowercase
virtual HWOperation * operationLowercase(const std::string &name) const
Definition: FunctionUnit.cc:378
TTAMachine::FunctionUnit::unsetMachine
virtual void unsetMachine()
Definition: FunctionUnit.cc:648
ObjectState
Definition: ObjectState.hh:59
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
TTAMachine::FunctionUnit::~FunctionUnit
virtual ~FunctionUnit()
Definition: FunctionUnit.cc:89
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TTAMachine::FunctionUnit::maxLatency
virtual int maxLatency() const
Definition: FunctionUnit.cc:443
BaseFUPort.hh
Unit.hh
TTAMachine::FunctionUnit::deleteAllOperations
void deleteAllOperations()
Definition: FunctionUnit.cc:899
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAMachine::FunctionUnit::cleanupGuards
void cleanupGuards() const
Definition: FunctionUnit.cc:830
TTAMachine::Unit
Definition: Unit.hh:51
CIStringSet.hh
TTAMachine::FunctionUnit::pipelineElement
virtual PipelineElement * pipelineElement(int index) const
Definition: FunctionUnit.cc:523
TCETools::CIStringSet
std::set< TCEString, CaseInsensitiveCmp > CIStringSet
Definition: CIStringSet.hh:49
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
TTAMachine::FunctionUnit::hasOperation
virtual bool hasOperation(const std::string &name) const
Definition: FunctionUnit.cc:330
TTAMachine::FunctionUnit::setAddressSpace
virtual void setAddressSpace(AddressSpace *as)
Definition: FunctionUnit.cc:594
TTAMachine::FunctionUnit::operationPortCount
virtual int operationPortCount() const
Definition: FunctionUnit.cc:182
TTAMachine::FunctionUnit::saveState
virtual ObjectState * saveState() const
Definition: FunctionUnit.cc:677
TTAMachine::FunctionUnit::operations_
OperationTable operations_
Contains all the operations of the function unit.
Definition: FunctionUnit.hh:139
TTAMachine::FunctionUnit::pipelineElementCount
virtual int pipelineElementCount() const
Definition: FunctionUnit.cc:507
TTAMachine::FunctionUnit::orderNumber
virtual int orderNumber() const
Definition: FunctionUnit.cc:915
TTAMachine::FunctionUnit::hasOperationPort
virtual bool hasOperationPort(const std::string &name) const
Definition: FunctionUnit.cc:204
TTAMachine::PipelineElement
Definition: PipelineElement.hh:46
TTAMachine::FunctionUnit::pipelineElements_
PipelineElementTable pipelineElements_
Contains all the pipeline elements of the function unit.
Definition: FunctionUnit.hh:142
TTAMachine::FunctionUnit::addOperation
virtual void addOperation(HWOperation &operation)
Definition: FunctionUnit.cc:286
TTAMachine::FunctionUnit::hasOperationLowercase
virtual bool hasOperationLowercase(const std::string &name) const
Definition: FunctionUnit.cc:341
TTAMachine::FunctionUnit::PipelineElementTable
std::vector< PipelineElement * > PipelineElementTable
Container for pipeline elements.
Definition: FunctionUnit.hh:132
TTAMachine::FunctionUnit::needsConflictDetection
bool needsConflictDetection() const
Definition: FunctionUnit.cc:804
TTAMachine::FunctionUnit::loadState
virtual void loadState(const ObjectState *state)
Definition: FunctionUnit.cc:706
TTAMachine::FunctionUnit::OperationTable
std::vector< HWOperation * > OperationTable
Container for operations.
Definition: FunctionUnit.hh:130
TTAMachine::FunctionUnit::deletePipelineElement
virtual void deletePipelineElement(PipelineElement &element)
Definition: FunctionUnit.cc:489
TTAMachine::FunctionUnit::unsetMachineDerived
void unsetMachineDerived()
Definition: FunctionUnit.cc:665
TTAMachine::FunctionUnit::addressSpace_
AddressSpace * addressSpace_
Address space used by the function unit.
Definition: FunctionUnit.hh:145
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
TTAMachine
Definition: Assembler.hh:48
TTAMachine::FunctionUnit::orderNumber_
int orderNumber_
Number indicating possition of the FU in the ADF file. Alows putting the FU into the order in the ins...
Definition: FunctionUnit.hh:149
TTAMachine::FunctionUnit::hasPipelineElement
virtual bool hasPipelineElement(const std::string &name) const
Definition: FunctionUnit.cc:540
TTAMachine::FunctionUnit::setOrderNumber
virtual void setOrderNumber(int)
Definition: FunctionUnit.cc:928
TTAMachine::FunctionUnit::copy
virtual FunctionUnit * copy() const
Definition: FunctionUnit.cc:103
TTAMachine::FunctionUnit::setName
virtual void setName(const std::string &name)
Definition: FunctionUnit.cc:118
TTAMachine::FunctionUnit::deleteOperation
virtual void deleteOperation(HWOperation &operation)
Definition: FunctionUnit.cc:309
TTAMachine::FunctionUnit::OSKEY_AS
static const std::string OSKEY_AS
ObjectState attribute key for name of the address space.
Definition: FunctionUnit.hh:119
TTAMachine::FunctionUnit::isArchitectureEqual
virtual bool isArchitectureEqual(const FunctionUnit *fu, const bool checkPortWidths=true) const
Definition: FunctionUnit.cc:747
TTAMachine::FunctionUnit::operationNames
virtual void operationNames(TCETools::CIStringSet &opNames) const
Definition: FunctionUnit.cc:428