OpenASIP  2.0
ControlUnit.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 ControlUnit.hh
26  *
27  * Declaration of ControlUnit class.
28  *
29  * @author Lasse Laasonen 2004 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_CONTROL_UNIT_HH
34 #define TTA_CONTROL_UNIT_HH
35 
36 #include <string>
37 #include <utility>
38 
39 #include "FunctionUnit.hh"
40 
41 class ObjectState;
42 
43 namespace TTAMachine {
44 
45 class SpecialRegisterPort;
46 
47 /**
48  * Represents the global control unit in the machine.
49  */
50 class ControlUnit : public FunctionUnit {
51 public:
53  const std::string& name, int delaySlots, int globalGuardLatency);
54  ControlUnit(const ObjectState* state);
55  virtual ~ControlUnit();
56 
57  virtual ControlUnit* copy() const;
58 
59  virtual void setMachine(Machine& mach);
60  virtual void unsetMachine();
61 
62  int delaySlots() const;
63  void setDelaySlots(int delaySlots);
64 
65  int globalGuardLatency() const;
66  void setGlobalGuardLatency(int latency);
67 
68  int specialRegisterPortCount() const;
69  bool hasSpecialRegisterPort(const std::string& name) const;
70  SpecialRegisterPort* specialRegisterPort(int index) const;
71  SpecialRegisterPort* specialRegisterPort(const std::string& name) const;
72 
75  bool hasReturnAddressPort() const;
77 
78  virtual ObjectState* saveState() const;
79  virtual void loadState(const ObjectState* state);
80 
81  /// ObjectState name for ControlUnit.
82  static const std::string OSNAME_CONTROL_UNIT;
83  /// ObjectState attribute key for the number of delay slots.
84  static const std::string OSKEY_DELAY_SLOTS;
85  /// ObjectState attribute key for the global guard latency.
86  static const std::string OSKEY_GUARD_LATENCY;
87  /// ObjectState attribute key for the name of the return address port.
88  static const std::string OSKEY_RA_PORT;
89 
90 protected:
91  virtual void removePort(Port& port);
92 
93 private:
94  void loadStateWithoutReferences(const ObjectState* state);
95  static bool hasLocalGuardLatencyOfZero(const Machine& machine);
96 
97  /// Number of delay instruction slots on the transport pipeline.
99 
100  /// The global guard latency.
102  /// The return address port.
104 };
105 }
106 
107 #include "ControlUnit.icc"
108 
109 #endif
TTAMachine::ControlUnit::unsetMachine
virtual void unsetMachine()
Definition: ControlUnit.cc:134
TTAMachine::ControlUnit::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: ControlUnit.cc:380
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::ControlUnit::delaySlots_
int delaySlots_
Number of delay instruction slots on the transport pipeline.
Definition: ControlUnit.hh:98
TTAMachine::ControlUnit::globalGuardLatency_
int globalGuardLatency_
The global guard latency.
Definition: ControlUnit.hh:101
TTAMachine::ControlUnit::saveState
virtual ObjectState * saveState() const
Definition: ControlUnit.cc:322
TTAMachine::ControlUnit::OSKEY_RA_PORT
static const std::string OSKEY_RA_PORT
ObjectState attribute key for the name of the return address port.
Definition: ControlUnit.hh:88
ObjectState
Definition: ObjectState.hh:59
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
TTAMachine::ControlUnit::setGlobalGuardLatency
void setGlobalGuardLatency(int latency)
Definition: ControlUnit.cc:159
TTAMachine::ControlUnit::OSKEY_GUARD_LATENCY
static const std::string OSKEY_GUARD_LATENCY
ObjectState attribute key for the global guard latency.
Definition: ControlUnit.hh:86
TTAMachine::ControlUnit::~ControlUnit
virtual ~ControlUnit()
Definition: ControlUnit.cc:92
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::ControlUnit::copy
virtual ControlUnit * copy() const
Definition: ControlUnit.cc:105
TTAMachine::SpecialRegisterPort
Definition: SpecialRegisterPort.hh:48
TTAMachine::ControlUnit::raPort_
SpecialRegisterPort * raPort_
The return address port.
Definition: ControlUnit.hh:103
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
TTAMachine::Port
Definition: Port.hh:54
TTAMachine::ControlUnit::specialRegisterPort
SpecialRegisterPort * specialRegisterPort(int index) const
Definition: ControlUnit.cc:211
TTAMachine::ControlUnit::specialRegisterPortCount
int specialRegisterPortCount() const
Definition: ControlUnit.cc:185
TTAMachine::ControlUnit::ControlUnit
ControlUnit(const std::string &name, int delaySlots, int globalGuardLatency)
Definition: ControlUnit.cc:61
TTAMachine::ControlUnit::loadState
virtual void loadState(const ObjectState *state)
Definition: ControlUnit.cc:351
TTAMachine::ControlUnit::removePort
virtual void removePort(Port &port)
Definition: ControlUnit.cc:363
TTAMachine::ControlUnit::unsetReturnAddressPort
void unsetReturnAddressPort()
Definition: ControlUnit.cc:284
TTAMachine::ControlUnit::delaySlots
int delaySlots() const
ControlUnit.icc
TTAMachine::ControlUnit::setDelaySlots
void setDelaySlots(int delaySlots)
Definition: ControlUnit.cc:145
TTAMachine::ControlUnit::OSKEY_DELAY_SLOTS
static const std::string OSKEY_DELAY_SLOTS
ObjectState attribute key for the number of delay slots.
Definition: ControlUnit.hh:84
TTAMachine::ControlUnit::hasSpecialRegisterPort
bool hasSpecialRegisterPort(const std::string &name) const
Definition: ControlUnit.cc:197
TTAMachine::ControlUnit::setMachine
virtual void setMachine(Machine &mach)
Definition: ControlUnit.cc:119
TTAMachine::ControlUnit::hasLocalGuardLatencyOfZero
static bool hasLocalGuardLatencyOfZero(const Machine &machine)
Definition: ControlUnit.cc:411
TTAMachine::Component::machine
virtual Machine * machine() const
TTAMachine::ControlUnit::setReturnAddressPort
void setReturnAddressPort(const SpecialRegisterPort &port)
Definition: ControlUnit.cc:271
TTAMachine::ControlUnit::OSNAME_CONTROL_UNIT
static const std::string OSNAME_CONTROL_UNIT
ObjectState name for ControlUnit.
Definition: ControlUnit.hh:82
TTAMachine
Definition: Assembler.hh:48
TTAMachine::ControlUnit::globalGuardLatency
int globalGuardLatency() const
TTAMachine::ControlUnit::returnAddressPort
SpecialRegisterPort * returnAddressPort() const
Definition: ControlUnit.cc:307
TTAMachine::ControlUnit::hasReturnAddressPort
bool hasReturnAddressPort() const
Definition: ControlUnit.cc:295
TTAMachine::Machine
Definition: Machine.hh:73
FunctionUnit.hh