OpenASIP  2.0
PortCode.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 PortCode.hh
26  *
27  * Declaration of PortCode class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_PORT_CODE_HH
34 #define TTA_PORT_CODE_HH
35 
36 #include <string>
37 #include "Exception.hh"
38 
39 class SocketCodeTable;
40 class ObjectState;
41 
42 /**
43  * Base class for FUPortCode, RFPortCode and IUPortCode.
44  */
45 class PortCode {
46 public:
47  virtual ~PortCode();
48 
49  std::string unitName() const;
50 
51  bool hasEncoding() const;
52  unsigned int encoding() const;
53  unsigned int extraBits() const;
54  int width() const;
55  int encodingWidth() const;
56  int indexWidth() const;
57 
58  void setMaxIndex(unsigned regIndex) { maxRegIndex_ = regIndex; }
59  bool isMaxIndexSet() const { return maxRegIndex_ != 0; }
60  unsigned maxIndex() const { return maxRegIndex_; }
61 
62  SocketCodeTable* parent() const;
63 
64  virtual ObjectState* saveState() const;
65 
66  /// ObjectState name for PortCode.
67  static const std::string OSNAME_PORT_CODE;
68  /// ObjectState attribute key for the name of the unit.
69  static const std::string OSKEY_UNIT_NAME;
70  /// ObjectState attribute key for the encoding.
71  static const std::string OSKEY_ENCODING;
72  /// ObjectState attribute key for the number of extra bits.
73  static const std::string OSKEY_EXTRA_BITS;
74  /// ObjectState attribute key for the widht of register index.
75  static const std::string OSKEY_INDEX_WIDTH;
76  /// ObjectState attribute key for the max-index attribute.
77  static const std::string OSKEY_MAX_INDEX;
78 
79 protected:
80  PortCode(
81  const std::string& unitName, unsigned int encoding,
82  unsigned int extraBits, int indexWidth);
83  PortCode(const std::string& unitName, int indexWidth);
84  PortCode(const ObjectState* state);
86 
87 private:
88  /// Name of the unit.
89  std::string unitName_;
90  /// The encoding.
91  unsigned int encoding_;
92  /// The number of extra bits in the encoding.
93  unsigned int extraBits_;
94  /// The width of the register index in the port code.
96  /// Tells whether the port code has an encoding.
98  /// The parent socket code table.
100  /// In case this is set to non-zero, the whole width of the index
101  /// field is not used because the number of register indices is not
102  /// an exponent of two. This allow sharing the field with other
103  /// values.
104  unsigned maxRegIndex_;
105 };
106 
107 #endif
PortCode::~PortCode
virtual ~PortCode()
Definition: PortCode.cc:130
PortCode
Definition: PortCode.hh:45
Exception.hh
PortCode::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: PortCode.hh:73
ObjectState
Definition: ObjectState.hh:59
PortCode::OSKEY_UNIT_NAME
static const std::string OSKEY_UNIT_NAME
ObjectState attribute key for the name of the unit.
Definition: PortCode.hh:69
PortCode::parent_
SocketCodeTable * parent_
The parent socket code table.
Definition: PortCode.hh:99
PortCode::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding.
Definition: PortCode.hh:71
SocketCodeTable
Definition: SocketCodeTable.hh:68
PortCode::unitName
std::string unitName() const
Definition: PortCode.cc:140
PortCode::extraBits_
unsigned int extraBits_
The number of extra bits in the encoding.
Definition: PortCode.hh:93
PortCode::extraBits
unsigned int extraBits() const
Definition: PortCode.cc:177
PortCode::indexWidth_
int indexWidth_
The width of the register index in the port code.
Definition: PortCode.hh:95
PortCode::isMaxIndexSet
bool isMaxIndexSet() const
Definition: PortCode.hh:59
PortCode::OSKEY_MAX_INDEX
static const std::string OSKEY_MAX_INDEX
ObjectState attribute key for the max-index attribute.
Definition: PortCode.hh:77
PortCode::indexWidth
int indexWidth() const
Definition: PortCode.cc:215
PortCode::width
int width() const
Definition: PortCode.cc:188
PortCode::PortCode
PortCode(const std::string &unitName, unsigned int encoding, unsigned int extraBits, int indexWidth)
Definition: PortCode.cc:56
PortCode::maxRegIndex_
unsigned maxRegIndex_
In case this is set to non-zero, the whole width of the index field is not used because the number of...
Definition: PortCode.hh:104
PortCode::setParent
void setParent(SocketCodeTable *parent)
Definition: PortCode.cc:256
PortCode::encodingWidth
int encodingWidth() const
Definition: PortCode.cc:204
PortCode::maxIndex
unsigned maxIndex() const
Definition: PortCode.hh:60
PortCode::unitName_
std::string unitName_
Name of the unit.
Definition: PortCode.hh:89
PortCode::OSKEY_INDEX_WIDTH
static const std::string OSKEY_INDEX_WIDTH
ObjectState attribute key for the widht of register index.
Definition: PortCode.hh:75
PortCode::encoding_
unsigned int encoding_
The encoding.
Definition: PortCode.hh:91
PortCode::hasEncoding
bool hasEncoding() const
Definition: PortCode.cc:151
PortCode::parent
SocketCodeTable * parent() const
Definition: PortCode.cc:226
PortCode::OSNAME_PORT_CODE
static const std::string OSNAME_PORT_CODE
ObjectState name for PortCode.
Definition: PortCode.hh:67
PortCode::encoding
unsigned int encoding() const
Definition: PortCode.cc:164
PortCode::saveState
virtual ObjectState * saveState() const
Definition: PortCode.cc:237
PortCode::hasEncoding_
bool hasEncoding_
Tells whether the port code has an encoding.
Definition: PortCode.hh:97
PortCode::setMaxIndex
void setMaxIndex(unsigned regIndex)
Definition: PortCode.hh:58