OpenASIP  2.0
IUResource.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 IUResource.hh
26  *
27  * Declaration of prototype of Resource Model:
28  * declaration of the IUResource class.
29  *
30  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_IURESOURCE_HH
35 #define TTA_IURESOURCE_HH
36 
37 #include <string>
38 #include <vector>
39 #include <memory>
40 
41 #include "SchedulingResource.hh"
42 
43 namespace TTAProgram {
44  class TerminalImmediate;
45 }
46 
47 namespace TTAMachine {
48  class Machine;
49 }
50 
51 /**
52  * An interface for scheduling resources of Resource Model
53  * The derived class IUResource
54  */
55 
57 public:
58  virtual ~IUResource();
59  IUResource(
60  const TTAMachine::Machine& mach,
61  const std::string& name,
62  const int registers,
63  const int width,
64  const int latency,
65  const bool signExtension,
66  unsigned int initiationInterval = 0);
67 
68  virtual bool isInUse(const int cycle) const override;
69  virtual bool isAvailable(const int cycle, int immRegIndex) const;
70  virtual bool isAvailable(const int cycle) const override;
71  virtual bool canAssign(const int, const MoveNode&)const override;
72  virtual bool canAssign(
73  const int defCycle,
74  const int useCycle,
75  const MoveNode& node,
76  int immRegIndex) const;
77  virtual void assign(const int cycle, MoveNode& node) override;
78  virtual void assign(
79  const int defCycle,
80  const int useCycle,
81  MoveNode& node,
82  int& index);
83 
84  virtual void unassign(const int cycle, MoveNode& node) override;
85 
86  virtual bool isIUResource() const override;
87 
88  int registerCount() const;
89  std::shared_ptr<TTAProgram::TerminalImmediate>
90  immediateValue(const MoveNode& node) const;
91  int immediateWriteCycle(const MoveNode& node) const;
92  int width() const;
93 
94  void clearOldResources();
95  void clear() override;
96 
97 protected:
98  virtual bool validateDependentGroups() override;
99  virtual bool validateRelatedGroups() override;
100  void setRegisterCount(const int registers);
101 
102 private:
103  bool canAssignUse(int useCycle) const;
104 
105  // Stores first and last cycle register is marked for use
106  // also the actual value of constant to be stored in register
108  ResourceRecordType(int definition, int use, TTAProgram::TerminalImmediate* val);
110  int use_;
111  std::shared_ptr<TTAProgram::TerminalImmediate> immediateValue_;
112  };
113  // For each register, there are several def-use combinations
114  // non overlapping
115  typedef std::vector<ResourceRecordType*> ResourceRecordVectorType;
116  // Copying forbidden
117  IUResource(const IUResource&);
118  // Assignment forbidden
120  int findAvailable(
121  const int defCycle, const int useCycle, int immRegIndex) const;
122 
123  std::vector<ResourceRecordVectorType> resourceRecord_;
124  // Number of registers in given IU
126  // The bit width of registers in IU
127  int width_;
128  // The latency of IU
129  int latency_;
130  //Extention of IU, true == sign extends, false == zero extends
132 
134 };
135 #endif
TTAProgram
Definition: Estimator.hh:65
IUResource::signExtension_
bool signExtension_
Definition: IUResource.hh:131
IUResource::validateDependentGroups
virtual bool validateDependentGroups() override
Definition: IUResource.cc:462
IUResource::IUResource
IUResource(const TTAMachine::Machine &mach, const std::string &name, const int registers, const int width, const int latency, const bool signExtension, unsigned int initiationInterval=0)
Definition: IUResource.cc:54
IUResource::canAssignUse
bool canAssignUse(int useCycle) const
Definition: IUResource.cc:297
IUResource::registerCount_
int registerCount_
Definition: IUResource.hh:125
IUResource::ResourceRecordType::definition_
int definition_
Definition: IUResource.hh:109
MoveNode
Definition: MoveNode.hh:65
IUResource::~IUResource
virtual ~IUResource()
Definition: IUResource.cc:74
IUResource::clear
void clear() override
Definition: IUResource.cc:587
IUResource::setRegisterCount
void setRegisterCount(const int registers)
Definition: IUResource.cc:377
IUResource::resourceRecord_
std::vector< ResourceRecordVectorType > resourceRecord_
Definition: IUResource.hh:123
IUResource::width
int width() const
Definition: IUResource.cc:576
IUResource::latency_
int latency_
Definition: IUResource.hh:129
SchedulingResource
Definition: SchedulingResource.hh:52
SchedulingResource.hh
IUResource::ResourceRecordType::use_
int use_
Definition: IUResource.hh:110
IUResource::ResourceRecordVectorType
std::vector< ResourceRecordType * > ResourceRecordVectorType
Definition: IUResource.hh:115
IUResource::assign
virtual void assign(const int cycle, MoveNode &node) override
Definition: IUResource.cc:175
IUResource::findAvailable
int findAvailable(const int defCycle, const int useCycle, int immRegIndex) const
Definition: IUResource.cc:491
IUResource::width_
int width_
Definition: IUResource.hh:127
IUResource::canAssign
virtual bool canAssign(const int, const MoveNode &) const override
Definition: IUResource.cc:282
IUResource::operator=
IUResource & operator=(const IUResource &)
IUResource::validateRelatedGroups
virtual bool validateRelatedGroups() override
Definition: IUResource.cc:473
IUResource::immediateWriteCycle
int immediateWriteCycle(const MoveNode &node) const
Definition: IUResource.cc:433
SchedulingResource::initiationInterval
int initiationInterval() const
Definition: SchedulingResource.cc:385
IUResource
Definition: IUResource.hh:56
TTAProgram::TerminalImmediate
Definition: TerminalImmediate.hh:44
IUResource::isIUResource
virtual bool isIUResource() const override
Definition: IUResource.cc:368
IUResource::unassign
virtual void unassign(const int cycle, MoveNode &node) override
Definition: IUResource.cc:240
IUResource::machine_
const TTAMachine::Machine & machine_
Definition: IUResource.hh:133
IUResource::immediateValue
std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &node) const
Definition: IUResource.cc:407
IUResource::isInUse
virtual bool isInUse(const int cycle) const override
Definition: IUResource.cc:86
IUResource::ResourceRecordType::immediateValue_
std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue_
Definition: IUResource.hh:111
IUResource::ResourceRecordType
Definition: IUResource.hh:107
SchedulingResource::name
virtual const std::string & name() const
TTAMachine
Definition: Assembler.hh:48
IUResource::registerCount
int registerCount() const
Definition: IUResource.cc:395
IUResource::clearOldResources
void clearOldResources()
Definition: IUResource.cc:560
IUResource::isAvailable
virtual bool isAvailable(const int cycle, int immRegIndex) const
Definition: IUResource.cc:131
TTAMachine::Machine
Definition: Machine.hh:73
IUResource::ResourceRecordType::ResourceRecordType
ResourceRecordType(int definition, int use, TTAProgram::TerminalImmediate *val)
Definition: IUResource.cc:594