OpenASIP  2.0
ImmediateControlField.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 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 ImmediateControlField.hh
26  *
27  * Declaration of ImmediateControlField class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2014
31  * @note rating: red
32  */
33 
34 #ifndef TTA_IMMEDIATE_CONTROL_FIELD_HH
35 #define TTA_IMMEDIATE_CONTROL_FIELD_HH
36 
37 #include <string>
38 #include <map>
39 
40 #include "InstructionField.hh"
41 #include "Exception.hh"
42 #include "Serializable.hh"
43 
44 class BinaryEncoding;
45 class MoveSlot;
46 
47 /**
48  * ImmediateControlField is a specialised InstructionField and represents the
49  * field of the TTA instruction that contains the long immediate control tag.
50  *
51  * This tag defines the template of the instruction. A TTA instruction
52  * template specifies which move slots are used to program data
53  * transports and which are used to encode immediate bits. An
54  * ImmediateControlField object can never exist alone. It is always
55  * registered to a BinaryEncoding object.
56  */
58 public:
61  virtual ~ImmediateControlField();
62 
63  BinaryEncoding* parent() const;
64 
65  int templateCount() const;
66  std::string instructionTemplate(int index) const;
67 
68  bool hasTemplateEncoding(const std::string& name) const;
69  unsigned int templateEncoding(const std::string& name) const;
70 
71  void addTemplateEncoding(const std::string& name, unsigned int encoding);
72  void removeTemplateEncoding(const std::string& name);
73 
74  // virtual methods derived from InstructionField
75  virtual int width() const;
76  virtual int childFieldCount() const;
77  virtual InstructionField& childField(int) const;
78 
79  // methods inherited from Serializable interface
80  virtual void loadState(const ObjectState* state);
81  virtual ObjectState* saveState() const;
82 
83  /// ObjectState name for immediate control field.
84  static const std::string OSNAME_IMM_CONTROL_FIELD;
85  /// ObjectState name for a template mapping.
86  static const std::string OSNAME_TEMPLATE_MAP;
87  /// ObjectState attribute key for the name of the instruction template.
88  static const std::string OSKEY_TEMPLATE_NAME;
89  /// ObjectState attribute key for the encoding of the instruction
90  /// template.
91  static const std::string OSKEY_ENCODING;
92 
93 private:
94  /// A map type for binary encodings.
95  typedef std::map<std::string, unsigned int> EncodingMap;
96 
98 
99  /// Binary encodings for instruction templates.
101 };
102 
103 #endif
ImmediateControlField::OSKEY_TEMPLATE_NAME
static const std::string OSKEY_TEMPLATE_NAME
ObjectState attribute key for the name of the instruction template.
Definition: ImmediateControlField.hh:88
BinaryEncoding
Definition: BinaryEncoding.hh:61
InstructionField.hh
MoveSlot
Definition: MoveSlot.hh:60
Exception.hh
ImmediateControlField::OSNAME_IMM_CONTROL_FIELD
static const std::string OSNAME_IMM_CONTROL_FIELD
ObjectState name for immediate control field.
Definition: ImmediateControlField.hh:84
ImmediateControlField::parent
BinaryEncoding * parent() const
Definition: ImmediateControlField.cc:106
ImmediateControlField::templates_
EncodingMap templates_
Binary encodings for instruction templates.
Definition: ImmediateControlField.hh:100
ObjectState
Definition: ObjectState.hh:59
ImmediateControlField::templateCount
int templateCount() const
Definition: ImmediateControlField.cc:124
ImmediateControlField::EncodingMap
std::map< std::string, unsigned int > EncodingMap
A map type for binary encodings.
Definition: ImmediateControlField.hh:95
ImmediateControlField::removeTemplateEncoding
void removeTemplateEncoding(const std::string &name)
Definition: ImmediateControlField.cc:232
InstructionField
Definition: InstructionField.hh:43
ImmediateControlField::hasTemplateEncoding
bool hasTemplateEncoding(const std::string &name) const
Definition: ImmediateControlField.cc:167
ImmediateControlField::OSNAME_TEMPLATE_MAP
static const std::string OSNAME_TEMPLATE_MAP
ObjectState name for a template mapping.
Definition: ImmediateControlField.hh:86
ImmediateControlField
Definition: ImmediateControlField.hh:57
ImmediateControlField::width
virtual int width() const
Definition: ImmediateControlField.cc:243
ImmediateControlField::~ImmediateControlField
virtual ~ImmediateControlField()
Definition: ImmediateControlField.cc:92
ImmediateControlField::childField
virtual InstructionField & childField(int) const
Definition: ImmediateControlField.cc:276
ImmediateControlField::clearTemplateEncodings
void clearTemplateEncodings()
Definition: ImmediateControlField.cc:346
Serializable.hh
ImmediateControlField::instructionTemplate
std::string instructionTemplate(int index) const
Definition: ImmediateControlField.cc:138
ImmediateControlField::childFieldCount
virtual int childFieldCount() const
Definition: ImmediateControlField.cc:263
ImmediateControlField::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding of the instruction template.
Definition: ImmediateControlField.hh:91
ImmediateControlField::templateEncoding
unsigned int templateEncoding(const std::string &name) const
Definition: ImmediateControlField.cc:182
ImmediateControlField::loadState
virtual void loadState(const ObjectState *state)
Definition: ImmediateControlField.cc:290
ImmediateControlField::saveState
virtual ObjectState * saveState() const
Definition: ImmediateControlField.cc:323
ImmediateControlField::addTemplateEncoding
void addTemplateEncoding(const std::string &name, unsigned int encoding)
Definition: ImmediateControlField.cc:206
ImmediateControlField::ImmediateControlField
ImmediateControlField(BinaryEncoding &parent)
Definition: ImmediateControlField.cc:61