OpenASIP 2.2
Loading...
Searching...
No Matches
BinaryEncoding.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 BinaryEncoding.hh
26 *
27 * Declaration of BinaryEncoding 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_BINARY_ENCODING_HH
35#define TTA_BINARY_ENCODING_HH
36
37#include "Serializable.hh"
38#include "InstructionField.hh"
39#include "TCEString.hh"
40
41#include <vector>
42#include <map>
43
44class MoveSlot;
46class SocketCodeTable;
50
51/**
52 * BinaryEncoding is the root class in the object model of the binary
53 * encoding map.
54 *
55 * An instance of this class is sufficient to access all the
56 * information pertaining a binary encoding map, so an object can be
57 * passed to clients whenever a full description of the encoding map
58 * is required. BinaryEncoding is mostly a specialized container of
59 * objects of other classes.
60 */
62public:
63 enum Position {
65 RIGHT
66 };
67
69 BinaryEncoding(const ObjectState* state);
70
71 virtual ~BinaryEncoding();
72
73 int moveSlotCount() const;
74 MoveSlot& moveSlot(int index) const;
75 bool hasMoveSlot(const std::string& name) const;
76 MoveSlot& moveSlot(const std::string& name) const;
77 void addMoveSlot(MoveSlot& slot);
78 void removeMoveSlot(MoveSlot& slot);
79
80 int immediateSlotCount() const;
81 ImmediateSlotField& immediateSlot(int index) const;
82 bool hasImmediateSlot(const std::string& name) const;
83 ImmediateSlotField& immediateSlot(const std::string& name) const;
86
87 bool hasImmediateControlField() const;
91
95 const std::string& iTemp, const std::string& dstUnit) const;
98
99 int instructionFormatCount() const;
100 bool hasInstructionFormat(const std::string& name) const;
101 InstructionFormat& instructionFormat(int index) const;
102 InstructionFormat* instructionFormat(const std::string& name) const;
105
106 int socketCodeTableCount() const;
107 SocketCodeTable& socketCodeTable(int index) const;
108 SocketCodeTable& socketCodeTable(const std::string& name) const;
111 int longestTemplateExtraBits() const;
112
113 // methods inherited from InstructionField
114 virtual int childFieldCount() const;
115 virtual InstructionField& childField(int position) const;
116 virtual int width(const TCEString& templateName) const;
117 virtual int width() const;
118
119 void setTemplateExtraBits(const TCEString& templateName, int bitCount);
120 int templateExtraBits(const TCEString& templateName) const;
121
122 // methods inherited from Serializable interface
123 virtual void loadState(const ObjectState* state);
124 virtual ObjectState* saveState() const;
125
126 /// ObjectState name for binary encoding.
127 static const std::string OSNAME_BEM;
128 static const std::string OSNAME_FU_OPCODE;
129 static const std::string OSNAME_TEMPLATE_EXTRA_BITS;
130 static const std::string OSNAME_TEMPLATE_EXTRA_BIT_COUNT;
131 static const std::string OSNAME_TEMPLATE_NAME;
132
133private:
134 /// Container type for MoveSlots.
135 typedef std::vector<MoveSlot*> MoveSlotContainer;
136 /// Container type for ImmediateSlotFields.
137 typedef std::vector<ImmediateSlotField*> ImmediateSlotContainer;
138 /// Container type for SocketCodeTables.
139 typedef std::vector<SocketCodeTable*> SocketCodeTableContainer;
140 /// Container type for LImmDstRegisterFields.
141 typedef std::vector<LImmDstRegisterField*> LImmDstRegisterFieldContainer;
142 /// Container type for InstructionFormats.
143 typedef std::vector<InstructionFormat*> InstructionFormatContainer;
144 /// Template extra bit count container.
145 typedef std::map<TCEString, int> TemplateExtraBitCountMap;
146
147 bool hasSocketCodeTable(const std::string& name) const;
148 void deleteMoveSlots();
151 void deleteSocketCodes();
153
154 /// A container for instruction formats.
156 /// A container for move slots.
158 /// A container for immediate slots.
160 /// A container for socket code tables.
162 /// The immediate control field.
164 /// A container for long immediate register fields.
166 /// Extra (padding) bits per instruction template.
168};
169
170#endif
int instructionFormatCount() const
void addInstructionFormat(InstructionFormat &format)
ImmediateControlField & immediateControlField() const
static const std::string OSNAME_TEMPLATE_NAME
int socketCodeTableCount() const
LImmDstRegisterField & longImmDstRegisterField(int index) const
std::vector< ImmediateSlotField * > ImmediateSlotContainer
Container type for ImmediateSlotFields.
static const std::string OSNAME_BEM
ObjectState name for binary encoding.
int moveSlotCount() const
bool hasSocketCodeTable(const std::string &name) const
void addLongImmDstRegisterField(LImmDstRegisterField &field)
void addSocketCodeTable(SocketCodeTable &table)
virtual int width() const
bool hasInstructionFormat(const std::string &name) const
int longestTemplateExtraBits() const
void removeMoveSlot(MoveSlot &slot)
virtual ObjectState * saveState() const
ImmediateSlotContainer immediateSlots_
A container for immediate slots.
virtual int childFieldCount() const
void deleteInstructionFormats()
int templateExtraBits(const TCEString &templateName) const
int immediateSlotCount() const
static const std::string OSNAME_TEMPLATE_EXTRA_BIT_COUNT
MoveSlot & moveSlot(int index) const
InstructionFormatContainer instructionFormats_
A container for instruction formats.
int longImmDstRegisterFieldCount() const
MoveSlotContainer moveSlots_
A container for move slots.
void removeLongImmDstRegisterField(LImmDstRegisterField &field)
LImmDstRegisterFieldContainer longImmDstRegFields_
A container for long immediate register fields.
void addMoveSlot(MoveSlot &slot)
virtual void loadState(const ObjectState *state)
std::map< TCEString, int > TemplateExtraBitCountMap
Template extra bit count container.
std::vector< InstructionFormat * > InstructionFormatContainer
Container type for InstructionFormats.
bool hasImmediateSlot(const std::string &name) const
std::vector< SocketCodeTable * > SocketCodeTableContainer
Container type for SocketCodeTables.
std::vector< MoveSlot * > MoveSlotContainer
Container type for MoveSlots.
void unsetImmediateControlField()
void addImmediateSlot(ImmediateSlotField &slot)
TemplateExtraBitCountMap extraTemplateBits_
Extra (padding) bits per instruction template.
void removeInstructionFormat(InstructionFormat &format)
void removeSocketCodeTable(SocketCodeTable &table)
void removeImmediateSlot(ImmediateSlotField &slot)
void deleteLongImmDstRegisterFields()
ImmediateSlotField & immediateSlot(int index) const
void setImmediateControlField(ImmediateControlField &field)
static const std::string OSNAME_FU_OPCODE
SocketCodeTableContainer socketCodes_
A container for socket code tables.
bool hasMoveSlot(const std::string &name) const
SocketCodeTable & socketCodeTable(int index) const
std::vector< LImmDstRegisterField * > LImmDstRegisterFieldContainer
Container type for LImmDstRegisterFields.
virtual ~BinaryEncoding()
bool hasImmediateControlField() const
static const std::string OSNAME_TEMPLATE_EXTRA_BITS
ImmediateControlField * immediateField_
The immediate control field.
virtual InstructionField & childField(int position) const
void deleteImmediateSlots()
InstructionFormat & instructionFormat(int index) const
void setTemplateExtraBits(const TCEString &templateName, int bitCount)