OpenASIP  2.0
InstructionField.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 InstructionField.hh
26  *
27  * Declaration of InstructionField class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_INSTRUCTION_FIELD_HH
34 #define TTA_INSTRUCTION_FIELD_HH
35 
36 #include "Exception.hh"
37 #include "Serializable.hh"
38 
39 /**
40  * InstructionField is an abstract base class that represents the properties
41  * common to all types of bit fields of the TTA instruction word.
42  */
44 public:
45  virtual ~InstructionField();
46 
47  InstructionField* parent() const;
48 
49  /**
50  * Returns the number of (immediate) child fields within the instruction
51  * field.
52  */
53  virtual int childFieldCount() const = 0;
54 
55  virtual InstructionField& childField(int position) const;
56 
57  /**
58  * Returns the bit width of the field.
59  */
60  virtual int width() const = 0;
61 
62  int bitPosition() const;
63  int relativePosition() const;
64  virtual void setRelativePosition(int position);
65  void setExtraBits(int bits);
66  int extraBits() const;
67 
68  // methods inherited from Serializable interface
69  virtual void loadState(const ObjectState* state);
70  virtual ObjectState* saveState() const;
71 
72  /// ObjectState name for instruction field.
73  static const std::string OSNAME_INSTRUCTION_FIELD;
74  /// ObjectState attribute key for the number of extra bits.
75  static const std::string OSKEY_EXTRA_BITS;
76  /// ObjectState attribute key for the relative position of the field.
77  static const std::string OSKEY_POSITION;
78 
79 protected:
82 
84  static void reorderSubfields(ObjectState* state);
85 
86 private:
87  /// Indicates the relative position of the field.
89  /// The number of extra bits.
91  /// The parent instruction field.
93 };
94 
95 #endif
InstructionField::OSKEY_POSITION
static const std::string OSKEY_POSITION
ObjectState attribute key for the relative position of the field.
Definition: InstructionField.hh:77
InstructionField::bitPosition
int bitPosition() const
Definition: InstructionField.cc:132
Exception.hh
Serializable
Definition: Serializable.hh:44
InstructionField::childField
virtual InstructionField & childField(int position) const
Definition: InstructionField.cc:117
ObjectState
Definition: ObjectState.hh:59
InstructionField::relativePos_
int relativePos_
Indicates the relative position of the field.
Definition: InstructionField.hh:88
InstructionField::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: InstructionField.hh:75
InstructionField
Definition: InstructionField.hh:43
InstructionField::saveState
virtual ObjectState * saveState() const
Definition: InstructionField.cc:268
InstructionField::width
virtual int width() const =0
InstructionField::setParent
void setParent(InstructionField *parent)
Definition: InstructionField.cc:282
InstructionField::parent
InstructionField * parent() const
Definition: InstructionField.cc:100
InstructionField::reorderSubfields
static void reorderSubfields(ObjectState *state)
Definition: InstructionField.cc:297
InstructionField::OSNAME_INSTRUCTION_FIELD
static const std::string OSNAME_INSTRUCTION_FIELD
ObjectState name for instruction field.
Definition: InstructionField.hh:73
InstructionField::setExtraBits
void setExtraBits(int bits)
Definition: InstructionField.cc:214
Serializable.hh
InstructionField::childFieldCount
virtual int childFieldCount() const =0
InstructionField::extraBits
int extraBits() const
Definition: InstructionField.cc:229
InstructionField::loadState
virtual void loadState(const ObjectState *state)
Definition: InstructionField.cc:242
InstructionField::relativePosition
int relativePosition() const
Definition: InstructionField.cc:160
InstructionField::parent_
InstructionField * parent_
The parent instruction field.
Definition: InstructionField.hh:92
InstructionField::InstructionField
InstructionField(InstructionField *parent)
Definition: InstructionField.cc:56
InstructionField::extraBits_
int extraBits_
The number of extra bits.
Definition: InstructionField.hh:90
InstructionField::setRelativePosition
virtual void setRelativePosition(int position)
Definition: InstructionField.cc:172
InstructionField::~InstructionField
virtual ~InstructionField()
Definition: InstructionField.cc:88