OpenASIP 2.2
Loading...
Searching...
No Matches
ExecutionPipeline.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 ExecutionPipeline.hh
26 *
27 * Declaration of class ExecutionPipeline.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_EXECUTION_PIPELINE_HH
34#define TTA_EXECUTION_PIPELINE_HH
35
36#include <vector>
37#include <map>
38#include <set>
39
40#include "MachinePart.hh"
41#include "Exception.hh"
42#include "PipelineElement.hh"
43
44class Operand;
45class ObjectState;
46
47namespace TTAMachine {
48
49class HWOperation;
50class FUPort;
51
52/**
53 * Represents an execution pipeline in function unit.
54 */
56public:
57 /// Set for operand indexes.
58 typedef std::set<int> OperandSet;
59 /// Set for pipeline elements.
60 typedef std::set<PipelineElement*,PipelineElement::Comparator> ResourceSet;
61
63 virtual ~ExecutionPipeline();
64
65 const HWOperation* parentOperation() const;
66
67 void addResourceUse(const std::string& name, int start, int duration);
68 void addPortRead(int operand, int start, int duration);
69 void addPortWrite(int operand, int start, int duration);
70 void removeResourceUse(const std::string& name);
71 void removeResourceUse(const std::string& name, int cycle);
73 void removeOperandUse(int operand, int cycle);
74 bool isResourceUsed(const std::string& name, int cycle) const;
75
76 ResourceSet resourceUsages(int cycle) const;
77
78 bool isPortUsed(const FUPort& port, int cycle) const;
79 bool isPortRead(const FUPort& port, int cycle) const;
80 bool isPortWritten(const FUPort& port, int cycle) const;
81
82 OperandSet readOperands(int cycle) const;
83 OperandSet writtenOperands(int cycle) const;
86
87 int latency() const;
88 int latency(int output) const;
89 int slack(int input) const;
90
91 ObjectState* saveState() const;
92 void loadState(const ObjectState* state);
93
94 bool isArchitectureEqual(const ExecutionPipeline* pipeline) const;
95
96 /// ObjectState name for ExecutionPipeline.
97 static const std::string OSNAME_PIPELINE;
98 /// ObjectState name for pipeline resource usage.
99 static const std::string OSNAME_RESOURCE_USAGE;
100 /// ObjectState name for operand read.
101 static const std::string OSNAME_OPERAND_READ;
102 /// ObjectState name for operand write.
103 static const std::string OSNAME_OPERAND_WRITE;
104 /// ObjectState attribute key for name of resource.
105 static const std::string OSKEY_RESOURCE_NAME;
106 /// ObjectState attribute key for operand number.
107 static const std::string OSKEY_OPERAND;
108 /// ObjectState attribute key for start cycle of a resource usage.
109 static const std::string OSKEY_START_CYCLE;
110 /// ObjectState attribute key for duration of a resource usage.
111 static const std::string OSKEY_CYCLES;
112
113private:
114 /// Vector for ObjectState pointers.
115 typedef std::vector<const ObjectState*> ObjectStateTable;
116
117 /// Vector for resource sets.
118 typedef std::vector<ResourceSet> ResourceUsage;
119 /// Vector for operand sets.
120 typedef std::vector<OperandSet> IOUsage;
121
122 void checkStartCycle(int startCycle) const;
123 static void checkDuration(int duration);
124 static void checkResourceName(const std::string& name);
125 void checkInputOperand(int operand) const;
126 void checkOutputOperand(int operand) const;
128 const std::string& resource, int start, int duration) const;
129 void checkOperandAvailability(int operand, int start, int duration) const;
130
132 const std::string& name,
133 int start,
134 int duration);
136 int operand,
137 int start,
138 int duration,
139 IOUsage& toModify);
141 const std::string& name,
142 int start,
143 int duration);
144 void internalRemoveOperandUse(int operand, int start, int duration);
145 void adjustLatency(int newLatency);
146 bool isOperandBound(
147 const FUPort& port,
148 const OperandSet& operands) const;
149 bool isOperandWritten(int operand) const;
150 bool isOperandRead(int operand) const;
151 int firstCycle() const;
152 int firstCycleWithoutResource(const std::string& resource) const;
154 const std::string& resource,
155 int cycle) const;
156 int firstCycleWithoutOperandUse(int operand, int cycle) const;
158 PipelineElement* pipelineElement(const std::string& name) const;
159 PipelineElement* addPipelineElement(const std::string& name) const;
160 static void saveResourceUse(
161 const PipelineElement* element,
162 int cycleToSave,
163 ObjectState* pipelineState);
164 static void saveOperandUse(
165 int operand,
166 int cycleToSave,
167 ObjectState* pipelineState,
168 const std::string& osName);
169 ObjectStateTable sortResourceUsages(const ObjectState* pipelineState) const;
170 void addResourceUsage(
171 ObjectStateTable& usages, const ObjectState* usageState) const;
172
173 /// Resource usage.
175 /// Operand reads.
177 /// Operand writes.
179 /// The parent operation.
181
182};
183}
184
185#endif
void checkOutputOperand(int operand) const
ObjectStateTable sortResourceUsages(const ObjectState *pipelineState) const
static void checkResourceName(const std::string &name)
void loadState(const ObjectState *state)
bool isPortUsed(const FUPort &port, int cycle) const
static void checkDuration(int duration)
bool isArchitectureEqual(const ExecutionPipeline *pipeline) const
std::vector< ResourceSet > ResourceUsage
Vector for resource sets.
std::vector< const ObjectState * > ObjectStateTable
Vector for ObjectState pointers.
void addResourceUse(const std::string &name, int start, int duration)
void checkInputOperand(int operand) const
void internalRemoveOperandUse(int operand, int start, int duration)
PipelineElement * pipelineElement(const std::string &name) const
static const std::string OSKEY_RESOURCE_NAME
ObjectState attribute key for name of resource.
void addResourceUsage(ObjectStateTable &usages, const ObjectState *usageState) const
static const std::string OSNAME_OPERAND_WRITE
ObjectState name for operand write.
int firstCycleWithoutOperandUse(int operand, int cycle) const
void internalRemoveResourceUse(const std::string &name, int start, int duration)
void addPortRead(int operand, int start, int duration)
bool isOperandWritten(int operand) const
void removeOperandUse(int operand, int cycle)
IOUsage opWrites_
Operand writes.
std::set< int > OperandSet
Set for operand indexes.
static void saveOperandUse(int operand, int cycleToSave, ObjectState *pipelineState, const std::string &osName)
static const std::string OSKEY_START_CYCLE
ObjectState attribute key for start cycle of a resource usage.
bool isOperandBound(const FUPort &port, const OperandSet &operands) const
void checkStartCycle(int startCycle) const
static const std::string OSKEY_OPERAND
ObjectState attribute key for operand number.
HWOperation * parent_
The parent operation.
void internalAddResourceUse(const std::string &name, int start, int duration)
static const std::string OSNAME_OPERAND_READ
ObjectState name for operand read.
void internalAddPortUse(int operand, int start, int duration, IOUsage &toModify)
ResourceSet resourceUsages(int cycle) const
void addPortWrite(int operand, int start, int duration)
bool isPortWritten(const FUPort &port, int cycle) const
bool isPortRead(const FUPort &port, int cycle) const
void removeResourceUse(const std::string &name)
int firstCycleWithoutResource(const std::string &resource) const
void checkOperandAvailability(int operand, int start, int duration) const
bool isResourceUsed(const std::string &name, int cycle) const
static const std::string OSNAME_PIPELINE
ObjectState name for ExecutionPipeline.
static const std::string OSNAME_RESOURCE_USAGE
ObjectState name for pipeline resource usage.
std::set< PipelineElement *, PipelineElement::Comparator > ResourceSet
Set for pipeline elements.
static const std::string OSKEY_CYCLES
ObjectState attribute key for duration of a resource usage.
ResourceUsage resourceUsage_
Resource usage.
bool isOperandRead(int operand) const
const HWOperation * parentOperation() const
void checkResourceAvailability(const std::string &resource, int start, int duration) const
std::vector< OperandSet > IOUsage
Vector for operand sets.
static void saveResourceUse(const PipelineElement *element, int cycleToSave, ObjectState *pipelineState)
PipelineElement * addPipelineElement(const std::string &name) const