OpenASIP  2.0
SimpleBrokerDirector.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 SimpleBrokerDirector.hh
26  *
27  * Declaration of SimpleBrokerDirector class.
28  *
29  * @author Ari Mets�halme 2006 (ari.metsahalme-no.spam-tut.fi)
30  * @author Vladimir Guzma 2007 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_SIMPLE_BROKER_DIRECTOR_HH
35 #define TTA_SIMPLE_BROKER_DIRECTOR_HH
36 
37 #include <vector>
38 #include <map>
39 #include "BrokerDirector.hh"
40 #include "Exception.hh"
41 #include "MoveNode.hh"
42 
43 namespace TTAProgram {
44  class Instruction;
45  class TerminalImmediate;
46  class Terminal;
47  class Immediate;
48  class MoveGuard;
49 }
50 
51 namespace TTAMachine {
52  class Bus;
53 }
54 
55 class ResourceBroker;
56 class IUBroker;
57 class ITemplateBroker;
58 class BusBroker;
61 class ControlFlowGraph;
62 class BasicBlockNode;
63 
64 /**
65  * A simple broker director.
66  */
68 public:
71  AssignmentPlan& plan,
72  unsigned int initiationInterval_);
73 
74  virtual ~SimpleBrokerDirector();
75 
76  virtual bool canAssign(
77  int cycle, MoveNode& node,
78  const TTAMachine::Bus* bus = nullptr,
79  const TTAMachine::FunctionUnit* srcFU = nullptr,
80  const TTAMachine::FunctionUnit* dstFU = nullptr,
81  int immWriteCycle = -1,
82  const TTAMachine::ImmediateUnit* immu = nullptr,
83  int immRegIndex = -1) const override;
84 
85  virtual bool canTransportImmediate(
86  const MoveNode& node, const TTAMachine::Bus* preAssignedBus) const;
87 
88  virtual void assign(
89  int cycle, MoveNode& node,
90  const TTAMachine::Bus* bus = nullptr,
91  const TTAMachine::FunctionUnit* srcFU = nullptr,
92  const TTAMachine::FunctionUnit* dstFU = nullptr,
93  int immWriteCycle = -1,
94  const TTAMachine::ImmediateUnit* immu = nullptr,
95  int immRegIndex = -1) override;
96  virtual void unassign(MoveNode& node) override;
97  virtual int earliestCycle(
98  MoveNode& node,
99  const TTAMachine::Bus* bus = nullptr,
100  const TTAMachine::FunctionUnit* srcFU = nullptr,
101  const TTAMachine::FunctionUnit* dstFU = nullptr,
102  int immWriteCycle = -1,
103  const TTAMachine::ImmediateUnit* immu = nullptr,
104  int immRegIndex = -1) const override;
105  virtual int earliestCycle(
106  int cycle, MoveNode& node,
107  const TTAMachine::Bus* bus = nullptr,
108  const TTAMachine::FunctionUnit* srcFU = nullptr,
109  const TTAMachine::FunctionUnit* dstFU = nullptr,
110  int immWriteCycle = -1,
111  const TTAMachine::ImmediateUnit* immu = nullptr,
112  int immRegIndex = -1) const override;
113  virtual int latestCycle(
114  MoveNode& node,
115  const TTAMachine::Bus* bus = nullptr,
116  const TTAMachine::FunctionUnit* srcFU = nullptr,
117  const TTAMachine::FunctionUnit* dstFU = nullptr,
118  int immWriteCycle = -1,
119  const TTAMachine::ImmediateUnit* immu = nullptr,
120  int immRegIndex = -1) const override;
121  virtual int latestCycle(
122  int cycle, MoveNode& node,
123  const TTAMachine::Bus* bus = nullptr,
124  const TTAMachine::FunctionUnit* srcFU = nullptr,
125  const TTAMachine::FunctionUnit* dstFU = nullptr,
126  int immWriteCycle = -1,
127  const TTAMachine::ImmediateUnit* immu = nullptr,
128  int immRegIndex = -1) const override;
129 
130  virtual bool hasGuard(const MoveNode& node) const;
131  virtual TTAProgram::Instruction* instruction(int cycle) const override;
132  virtual bool supportsExternalAssignments() const override;
133  virtual int largestCycle() const override;
134  virtual int smallestCycle() const override;
135  virtual void loseInstructionOwnership(int cycle);
136  virtual std::shared_ptr<TTAProgram::TerminalImmediate>
137  immediateValue(const MoveNode&);
138  virtual int immediateWriteCycle(const MoveNode&) const;
139  virtual bool isTemplateAvailable(
140  int, std::shared_ptr<TTAProgram::Immediate>) const;
141  void setMaxCycle(unsigned int cycle);
142  void clearOldResources();
143  void clear();
144  void setDDG(const DataDependenceGraph* ddg);
145  void setCFG(const ControlFlowGraph* cfg);
146  void setBBN(const BasicBlockNode* bbn);
147 
148 private:
153  const TTAMachine::Bus*,
155  bool);
157 
163  };
164  IUBroker& immediateUnitBroker() const;
166  BusBroker& busBroker() const;
168 
169  std::map<const MoveNode*, OriginalResources*, MoveNode::Comparator>
173  unsigned int initiationInterval_;
174 
175  /// the number of instructions to look back in the schedule
176  /// for a free slot
178 
179  // how many moves in each cycle, for quick bus check fail.
180  std::map<int,int> moveCounts_;
182 
183  unsigned int instructionIndex(unsigned int maxCycle) const ;
184 };
185 
186 #endif
TTAProgram
Definition: Estimator.hh:65
SimpleBrokerDirector::OriginalResources::isGuarded_
bool isGuarded_
Definition: SimpleBrokerDirector.hh:162
SimpleBrokerDirector::OriginalResources::~OriginalResources
~OriginalResources()
Definition: SimpleBrokerDirector.cc:789
SimpleBrokerDirector::busBroker
BusBroker & busBroker() const
Definition: SimpleBrokerDirector.cc:737
SimpleBrokerDirector::latestCycle
virtual int latestCycle(MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
Definition: SimpleBrokerDirector.cc:560
SimpleBrokerDirector::clear
void clear()
Definition: SimpleBrokerDirector.cc:944
SimpleBrokerDirector::SimpleBrokerDirector
SimpleBrokerDirector(const TTAMachine::Machine &machine, AssignmentPlan &plan, unsigned int initiationInterval_)
Definition: SimpleBrokerDirector.cc:79
SimpleBrokerDirector::unassign
virtual void unassign(MoveNode &node) override
Definition: SimpleBrokerDirector.cc:340
Exception.hh
SimpleBrokerDirector::smallestCycle
virtual int smallestCycle() const override
Definition: SimpleBrokerDirector.cc:859
SimpleBrokerDirector::isTemplateAvailable
virtual bool isTemplateAvailable(int, std::shared_ptr< TTAProgram::Immediate >) const
Definition: SimpleBrokerDirector.cc:899
SimpleBrokerDirector::clearOldResources
void clearOldResources()
Definition: SimpleBrokerDirector.cc:913
SimpleBrokerDirector::hasGuard
virtual bool hasGuard(const MoveNode &node) const
Definition: SimpleBrokerDirector.cc:811
SimpleBrokerDirector::initiationInterval_
unsigned int initiationInterval_
Definition: SimpleBrokerDirector.hh:173
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAMachine::Bus
Definition: Bus.hh:53
SimpleBrokerDirector::canAssign
virtual bool canAssign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
Definition: SimpleBrokerDirector.cc:120
SimpleBrokerDirector::assign
virtual void assign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) override
Definition: SimpleBrokerDirector.cc:236
ResourceBroker
Definition: ResourceBroker.hh:61
MoveNode
Definition: MoveNode.hh:65
SimpleBrokerDirector::canTransportImmediate
virtual bool canTransportImmediate(const MoveNode &node, const TTAMachine::Bus *preAssignedBus) const
Definition: SimpleBrokerDirector.cc:680
SimpleBrokerDirector::loseInstructionOwnership
virtual void loseInstructionOwnership(int cycle)
Definition: SimpleBrokerDirector.cc:872
ITemplateBroker
Definition: ITemplateBroker.hh:65
SimpleBrokerDirector::OriginalResources
Definition: SimpleBrokerDirector.hh:149
SimpleBrokerDirector::schedulingWindow_
int schedulingWindow_
the number of instructions to look back in the schedule for a free slot
Definition: SimpleBrokerDirector.hh:177
SimpleBrokerDirector::instructionTemplateBroker
ITemplateBroker & instructionTemplateBroker() const
Definition: SimpleBrokerDirector.cc:717
SimpleBrokerDirector::~SimpleBrokerDirector
virtual ~SimpleBrokerDirector()
Definition: SimpleBrokerDirector.cc:100
SimpleBrokerDirector::busCount_
int busCount_
Definition: SimpleBrokerDirector.hh:181
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
BusBroker
Definition: BusBroker.hh:60
SimpleBrokerDirector::OriginalResources::OriginalResources
OriginalResources(TTAProgram::Terminal *, TTAProgram::Terminal *, const TTAMachine::Bus *, TTAProgram::MoveGuard *, bool)
Definition: SimpleBrokerDirector.cc:772
SimpleBrokerDirector::moveCounts_
std::map< int, int > moveCounts_
Definition: SimpleBrokerDirector.hh:180
SimpleBrokerDirector::OriginalResources::dst_
TTAProgram::Terminal * dst_
Definition: SimpleBrokerDirector.hh:159
SimpleBrokerDirector::earliestCycle
virtual int earliestCycle(MoveNode &node, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
Definition: SimpleBrokerDirector.cc:457
SimpleBrokerDirector::setBBN
void setBBN(const BasicBlockNode *bbn)
Definition: SimpleBrokerDirector.cc:962
SimpleBrokerDirector::largestCycle
virtual int largestCycle() const override
Definition: SimpleBrokerDirector.cc:848
SimpleBrokerDirector::executionPipelineBroker
ExecutionPipelineBroker & executionPipelineBroker() const
Definition: SimpleBrokerDirector.cc:756
BasicBlockNode
Definition: BasicBlockNode.hh:64
SimpleBrokerDirector::OriginalResources::guard_
TTAProgram::MoveGuard * guard_
Definition: SimpleBrokerDirector.hh:161
SimpleBrokerDirector::setCFG
void setCFG(const ControlFlowGraph *cfg)
Definition: SimpleBrokerDirector.cc:957
SimpleBrokerDirector::OriginalResources::bus_
const TTAMachine::Bus * bus_
Definition: SimpleBrokerDirector.hh:160
SimpleBrokerDirector::setDDG
void setDDG(const DataDependenceGraph *ddg)
Definition: SimpleBrokerDirector.cc:952
SimpleBrokerDirector::immediateValue
virtual std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &)
Definition: SimpleBrokerDirector.cc:883
SimpleBrokerDirector::instructionIndex
unsigned int instructionIndex(unsigned int maxCycle) const
Definition: SimpleBrokerDirector.cc:929
SimpleBrokerDirector::OriginalResources::src_
TTAProgram::Terminal * src_
Definition: SimpleBrokerDirector.hh:158
SimpleBrokerDirector
Definition: SimpleBrokerDirector.hh:67
SimpleBrokerDirector::immediateWriteCycle
virtual int immediateWriteCycle(const MoveNode &) const
Definition: SimpleBrokerDirector.cc:894
SimpleBrokerDirector::immediateUnitBroker
IUBroker & immediateUnitBroker() const
Definition: SimpleBrokerDirector.cc:698
AssignmentPlan
Definition: AssignmentPlan.hh:56
ResourceManager::machine
const TTAMachine::Machine & machine() const
Definition: ResourceManager.cc:56
SimpleBrokerDirector::instruction
virtual TTAProgram::Instruction * instruction(int cycle) const override
Definition: SimpleBrokerDirector.cc:827
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
TTAProgram::Terminal
Definition: Terminal.hh:60
SimpleBrokerDirector::supportsExternalAssignments
virtual bool supportsExternalAssignments() const override
Definition: SimpleBrokerDirector.cc:838
BrokerDirector
Definition: BrokerDirector.hh:42
SimpleBrokerDirector::origResMap_
std::map< const MoveNode *, OriginalResources *, MoveNode::Comparator > origResMap_
Definition: SimpleBrokerDirector.hh:170
TTAMachine
Definition: Assembler.hh:48
MoveNode.hh
SimpleBrokerDirector::knownMinCycle_
int knownMinCycle_
Definition: SimpleBrokerDirector.hh:172
TTAProgram::MoveGuard
Definition: MoveGuard.hh:47
SimpleBrokerDirector::knownMaxCycle_
int knownMaxCycle_
Definition: SimpleBrokerDirector.hh:171
ExecutionPipelineBroker
Definition: ExecutionPipelineBroker.hh:53
IUBroker
Definition: IUBroker.hh:57
ControlFlowGraph
Definition: ControlFlowGraph.hh:100
TTAMachine::Machine
Definition: Machine.hh:73
BrokerDirector.hh
SimpleBrokerDirector::setMaxCycle
void setMaxCycle(unsigned int cycle)
Definition: SimpleBrokerDirector.cc:967
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50