OpenASIP  2.0
RegisterFile.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 RegisterFile.hh
26  *
27  * Declaration of RegisterFile class.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  * @note reviewed 17 Jun 2004 by jn, pj, jm, ll
31  * @note rating: red
32  */
33 
34 #ifndef TTA_REGISTER_FILE_HH
35 #define TTA_REGISTER_FILE_HH
36 
37 #include <string>
38 
39 #include "MachinePart.hh"
40 #include "BaseRegisterFile.hh"
41 
42 namespace TTAMachine {
43 
44 /**
45  * Represents a register-file in TTA processor.
46  */
48 public:
49  /// Type of the register file indicates how the RF is used.
50  enum Type {
51  NORMAL, ///< Used for general register allocation.
52  RESERVED, ///< Used for custom, user controlled register allocation.
53  VOLATILE ///< Used for user-controlled I/O communication.
54  };
55 
57  const std::string& name, unsigned int size, unsigned int width,
58  unsigned int maxReads, unsigned int maxwrites,
59  unsigned int guardLatency, Type type, bool zeroRegister = false);
60  explicit RegisterFile(const ObjectState* state);
61  virtual ~RegisterFile();
62  virtual RegisterFile* copy() const;
63 
64  virtual int maxReads() const;
65  virtual int maxWrites() const;
66  virtual RegisterFile::Type type() const;
67 
68  virtual bool isNormal() const;
69  virtual bool isVolatile() const;
70  virtual bool isReserved() const;
71 
72  virtual void setName(const std::string& name);
73  virtual void setMaxReads(int maxReads);
74  virtual void setMaxWrites(int maxWrites);
75  virtual void setType(RegisterFile::Type type);
76  virtual void setNumberOfRegisters(int registers);
77 
78  virtual int guardLatency() const;
79  virtual void setGuardLatency(int latency);
80 
81  virtual void unsetMachine();
82 
83  virtual ObjectState* saveState() const;
84  virtual void loadState(const ObjectState* state);
85 
86  virtual bool isArchitectureEqual(const RegisterFile& rf) const;
87 
88  virtual bool isUsedAsGuard() const;
89 
90  virtual bool zeroRegister() const;
91  virtual void setZeroRegister(const bool& value);
92 
93  /// ObjectState name for RegisterFile.
94  static const std::string OSNAME_REGISTER_FILE;
95  /// ObjectState attribute key for register file type.
96  static const std::string OSKEY_TYPE;
97  /// ObjectState attribute value for normal register file type.
98  static const std::string OSVALUE_NORMAL;
99  /// ObjectState attribute value for reserved register file type.
100  static const std::string OSVALUE_RESERVED;
101  /// ObjectState attribute value for volatile register file type.
102  static const std::string OSVALUE_VOLATILE;
103  /// ObjectState attribute key for maximum simultaneous readers.
104  static const std::string OSKEY_MAX_READS;
105  /// ObjectState attribute key for maximum simultaneous writers.
106  static const std::string OSKEY_MAX_WRITES;
107  /// ObjectState attribute key for the guard latency.
108  static const std::string OSKEY_GUARD_LATENCY;
109  /// ObjectState attribute key for zero register flag.
110  static const std::string OSKEY_ZERO_REGISTER;
111 
112 
113  Port* firstReadPort() const;
114  Port* firstWritePort() const;
115 
116 protected:
117 
118 private:
119  bool updateMaxReadsAndWrites() const;
120  /// Copying forbidden, use the copy() method.
121  RegisterFile(const RegisterFile&);
122  /// Assingment forbidden.
124 
125  void loadStateWithoutReferences(const ObjectState* state);
126  void deleteGuards(int registers) const;
127 
128  /// Max number of ports that can read a register all in the same cycle.
129  mutable int maxReads_;
130  /// Max number of ports that can read a register all in the same cycle.
131  mutable int maxWrites_;
132  /// The guard latency of the register file.
134 
135  /// Type of the register file.
137  // True if the first index is hard coded to zero
139 };
140 }
141 
142 #endif
143 
TTAMachine::RegisterFile::firstReadPort
Port * firstReadPort() const
Definition: RegisterFile.cc:607
TTAMachine::RegisterFile::setMaxWrites
virtual void setMaxWrites(int maxWrites)
Definition: RegisterFile.cc:247
BaseRegisterFile.hh
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::RegisterFile::isReserved
virtual bool isReserved() const
Definition: RegisterFile.cc:184
TTAMachine::RegisterFile::RESERVED
@ RESERVED
Used for custom, user controlled register allocation.
Definition: RegisterFile.hh:52
TTAMachine::RegisterFile::OSKEY_GUARD_LATENCY
static const std::string OSKEY_GUARD_LATENCY
ObjectState attribute key for the guard latency.
Definition: RegisterFile.hh:108
TTAMachine::RegisterFile::type_
Type type_
Type of the register file.
Definition: RegisterFile.hh:136
TTAMachine::RegisterFile::OSKEY_TYPE
static const std::string OSKEY_TYPE
ObjectState attribute key for register file type.
Definition: RegisterFile.hh:96
TTAMachine::RegisterFile::unsetMachine
virtual void unsetMachine()
Definition: RegisterFile.cc:375
ObjectState
Definition: ObjectState.hh:59
TTAMachine::RegisterFile::setType
virtual void setType(RegisterFile::Type type)
Definition: RegisterFile.cc:304
TTAMachine::RegisterFile::OSVALUE_RESERVED
static const std::string OSVALUE_RESERVED
ObjectState attribute value for reserved register file type.
Definition: RegisterFile.hh:100
TTAMachine::RegisterFile::copy
virtual RegisterFile * copy() const
Definition: RegisterFile.cc:601
TTAMachine::RegisterFile::maxWrites
virtual int maxWrites() const
Definition: RegisterFile.cc:135
MachinePart.hh
TTAMachine::RegisterFile::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: RegisterFile.cc:449
TTAMachine::RegisterFile::loadState
virtual void loadState(const ObjectState *state)
Definition: RegisterFile.cc:433
TTAMachine::RegisterFile::updateMaxReadsAndWrites
bool updateMaxReadsAndWrites() const
Definition: RegisterFile.cc:266
TTAMachine::RegisterFile::saveState
virtual ObjectState * saveState() const
Definition: RegisterFile.cc:392
TTAMachine::RegisterFile::setGuardLatency
virtual void setGuardLatency(int latency)
Definition: RegisterFile.cc:346
TTAMachine::BaseRegisterFile
Definition: BaseRegisterFile.hh:48
TTAMachine::RegisterFile::firstWritePort
Port * firstWritePort() const
Definition: RegisterFile.cc:618
TTAMachine::RegisterFile::VOLATILE
@ VOLATILE
Used for user-controlled I/O communication.
Definition: RegisterFile.hh:53
TTAMachine::RegisterFile::maxReads
virtual int maxReads() const
Definition: RegisterFile.cc:123
TTAMachine::RegisterFile::isNormal
virtual bool isNormal() const
Definition: RegisterFile.cc:158
TTAMachine::RegisterFile::OSKEY_MAX_READS
static const std::string OSKEY_MAX_READS
ObjectState attribute key for maximum simultaneous readers.
Definition: RegisterFile.hh:104
TTAMachine::RegisterFile::setMaxReads
virtual void setMaxReads(int maxReads)
Definition: RegisterFile.cc:227
TTAMachine::Port
Definition: Port.hh:54
TTAMachine::RegisterFile::OSKEY_ZERO_REGISTER
static const std::string OSKEY_ZERO_REGISTER
ObjectState attribute key for zero register flag.
Definition: RegisterFile.hh:110
TTAMachine::RegisterFile::~RegisterFile
virtual ~RegisterFile()
Definition: RegisterFile.cc:112
TTAMachine::RegisterFile::OSNAME_REGISTER_FILE
static const std::string OSNAME_REGISTER_FILE
ObjectState name for RegisterFile.
Definition: RegisterFile.hh:94
TTAMachine::RegisterFile::operator=
RegisterFile & operator=(const RegisterFile &)
Assingment forbidden.
TTAMachine::RegisterFile::isArchitectureEqual
virtual bool isArchitectureEqual(const RegisterFile &rf) const
Definition: RegisterFile.cc:532
TTAMachine::RegisterFile::zeroRegister_
bool zeroRegister_
Definition: RegisterFile.hh:138
TTAMachine::RegisterFile::deleteGuards
void deleteGuards(int registers) const
Definition: RegisterFile.cc:492
TTAMachine::RegisterFile::RegisterFile
RegisterFile(const std::string &name, unsigned int size, unsigned int width, unsigned int maxReads, unsigned int maxwrites, unsigned int guardLatency, Type type, bool zeroRegister=false)
Definition: RegisterFile.cc:74
TTAMachine::RegisterFile::isUsedAsGuard
virtual bool isUsedAsGuard() const
Definition: RegisterFile.cc:567
TTAMachine::RegisterFile::setZeroRegister
virtual void setZeroRegister(const bool &value)
Definition: RegisterFile.cc:634
TTAMachine::RegisterFile::NORMAL
@ NORMAL
Used for general register allocation.
Definition: RegisterFile.hh:51
TTAMachine::RegisterFile::OSVALUE_NORMAL
static const std::string OSVALUE_NORMAL
ObjectState attribute value for normal register file type.
Definition: RegisterFile.hh:98
TTAMachine::RegisterFile::Type
Type
Type of the register file indicates how the RF is used.
Definition: RegisterFile.hh:50
TTAMachine::RegisterFile::guardLatency
virtual int guardLatency() const
Definition: RegisterFile.cc:333
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine::RegisterFile::maxReads_
int maxReads_
Max number of ports that can read a register all in the same cycle.
Definition: RegisterFile.hh:129
TTAMachine
Definition: Assembler.hh:48
TTAMachine::BaseRegisterFile::size
virtual int size() const
TTAMachine::RegisterFile::OSVALUE_VOLATILE
static const std::string OSVALUE_VOLATILE
ObjectState attribute value for volatile register file type.
Definition: RegisterFile.hh:102
TTAMachine::RegisterFile::isVolatile
virtual bool isVolatile() const
Definition: RegisterFile.cc:171
TTAMachine::BaseRegisterFile::width
virtual int width() const
TTAMachine::RegisterFile::type
virtual RegisterFile::Type type() const
Definition: RegisterFile.cc:147
TTAMachine::RegisterFile::OSKEY_MAX_WRITES
static const std::string OSKEY_MAX_WRITES
ObjectState attribute key for maximum simultaneous writers.
Definition: RegisterFile.hh:106
TTAMachine::RegisterFile::maxWrites_
int maxWrites_
Max number of ports that can read a register all in the same cycle.
Definition: RegisterFile.hh:131
TTAMachine::RegisterFile::setNumberOfRegisters
virtual void setNumberOfRegisters(int registers)
Definition: RegisterFile.cc:320
TTAMachine::RegisterFile::zeroRegister
virtual bool zeroRegister() const
Definition: RegisterFile.cc:629
TTAMachine::RegisterFile::setName
virtual void setName(const std::string &name)
Definition: RegisterFile.cc:198
TTAMachine::RegisterFile::guardLatency_
int guardLatency_
The guard latency of the register file.
Definition: RegisterFile.hh:133