OpenASIP  2.0
ImmediateUnit.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 ImmediateUnit.hh
26  *
27  * Declaration of ImmediateUnit class.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  */
31 
32 #ifndef TTA_IMMEDIATE_UNIT_HH
33 #define TTA_IMMEDIATE_UNIT_HH
34 
35 #include <string>
36 #include <list>
37 
38 #include "Machine.hh"
39 #include "RegisterFile.hh"
40 
41 class ObjectState;
42 
43 namespace TTAMachine {
44 
45 class InstructionTemplate;
46 
47 /**
48  * Represent a immediate unit in the machine.
49  */
50 class ImmediateUnit : public RegisterFile {
51 public:
53  const std::string& name, unsigned int size, unsigned int width,
54  unsigned int maxReads, unsigned int guardLatency,
55  Machine::Extension extension);
56  ImmediateUnit(const ObjectState* state);
58 
59  virtual void setMaxWrites(int maxWrites);
60  virtual void setName(const std::string& name);
61 
62  bool signExtends() const { return extension_ == Machine::SIGN; }
63  bool zeroExtends() const { return extension_ == Machine::ZERO; }
64 
65  virtual Machine::Extension extensionMode() const;
66  virtual int latency() const;
68 
69  virtual void unsetMachine();
70 
71  virtual ObjectState* saveState() const;
72  virtual void loadState(const ObjectState* state);
73 
74  /// ObjectState name for ImmediateUnit.
75  static const std::string OSNAME_IMMEDIATE_UNIT;
76  /// ObjectState attribute key for the extension mode.
77  static const std::string OSKEY_EXTENSION;
78  /// ObjectState attribute value for sign extension.
79  static const std::string OSVALUE_SIGN;
80  /// ObjectState attribute value for zero extension.
81  static const std::string OSVALUE_ZERO;
82  /// ObjectState attribute key for latency.
83  static const std::string OSKEY_LATENCY;
84 
85 private:
86  virtual void setLatency(int latency);
87  void loadStateWithoutReferences(const ObjectState* state);
88 
89  /**
90  * Extension mode applied to the long immediate when it is narrower than
91  * the immediate register.
92  */
94 
95  /**
96  * Minimum number of cycles needed between the encoding of a long
97  * immediate and its earliest transport on a data bus.
98  */
99  int latency_;
100 };
101 }
102 
103 #endif
TTAMachine::ImmediateUnit::OSVALUE_ZERO
static const std::string OSVALUE_ZERO
ObjectState attribute value for zero extension.
Definition: ImmediateUnit.hh:81
TTAMachine::Machine::ZERO
@ ZERO
Zero extension.
Definition: Machine.hh:81
mode
mode
Definition: tceopgen.cc:45
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::ImmediateUnit::extension_
Machine::Extension extension_
Definition: ImmediateUnit.hh:93
TTAMachine::ImmediateUnit::signExtends
bool signExtends() const
Definition: ImmediateUnit.hh:62
ObjectState
Definition: ObjectState.hh:59
TTAMachine::RegisterFile::maxWrites
virtual int maxWrites() const
Definition: RegisterFile.cc:135
TTAMachine::ImmediateUnit::latency
virtual int latency() const
Definition: ImmediateUnit.cc:155
TTAMachine::ImmediateUnit::~ImmediateUnit
~ImmediateUnit()
Definition: ImmediateUnit.cc:105
TTAMachine::ImmediateUnit::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: ImmediateUnit.cc:275
TTAMachine::ImmediateUnit::unsetMachine
virtual void unsetMachine()
Definition: ImmediateUnit.cc:209
TTAMachine::ImmediateUnit::setName
virtual void setName(const std::string &name)
Definition: ImmediateUnit.cc:120
TTAMachine::ImmediateUnit::zeroExtends
bool zeroExtends() const
Definition: ImmediateUnit.hh:63
TTAMachine::RegisterFile::maxReads
virtual int maxReads() const
Definition: RegisterFile.cc:123
TTAMachine::ImmediateUnit::latency_
int latency_
Definition: ImmediateUnit.hh:99
TTAMachine::ImmediateUnit::ImmediateUnit
ImmediateUnit(const std::string &name, unsigned int size, unsigned int width, unsigned int maxReads, unsigned int guardLatency, Machine::Extension extension)
Definition: ImmediateUnit.cc:74
TTAMachine::ImmediateUnit::saveState
virtual ObjectState * saveState() const
Definition: ImmediateUnit.cc:233
TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT
static const std::string OSNAME_IMMEDIATE_UNIT
ObjectState name for ImmediateUnit.
Definition: ImmediateUnit.hh:75
TTAMachine::ImmediateUnit::OSKEY_EXTENSION
static const std::string OSKEY_EXTENSION
ObjectState attribute key for the extension mode.
Definition: ImmediateUnit.hh:77
Machine.hh
TTAMachine::Machine::SIGN
@ SIGN
Sign extension.
Definition: Machine.hh:82
TTAMachine::ImmediateUnit::loadState
virtual void loadState(const ObjectState *state)
Definition: ImmediateUnit.cc:261
RegisterFile.hh
TTAMachine::ImmediateUnit::OSVALUE_SIGN
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
Definition: ImmediateUnit.hh:79
TTAMachine::ImmediateUnit::OSKEY_LATENCY
static const std::string OSKEY_LATENCY
ObjectState attribute key for latency.
Definition: ImmediateUnit.hh:83
TTAMachine::Machine::Extension
Extension
Definition: Machine.hh:80
TTAMachine::RegisterFile::guardLatency
virtual int guardLatency() const
Definition: RegisterFile.cc:333
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine::ImmediateUnit::extensionMode
virtual Machine::Extension extensionMode() const
Definition: ImmediateUnit.cc:143
TTAMachine::ImmediateUnit::setExtensionMode
virtual void setExtensionMode(Machine::Extension mode)
Definition: ImmediateUnit.cc:185
TTAMachine::ImmediateUnit::setLatency
virtual void setLatency(int latency)
Definition: ImmediateUnit.cc:197
TTAMachine
Definition: Assembler.hh:48
TTAMachine::BaseRegisterFile::size
virtual int size() const
TTAMachine::BaseRegisterFile::width
virtual int width() const
TTAMachine::ImmediateUnit::setMaxWrites
virtual void setMaxWrites(int maxWrites)
Definition: ImmediateUnit.cc:171
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50