OpenASIP 2.2
Loading...
Searching...
No Matches
IUPortCode.cc
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 IUPortCode.cc
26 *
27 * Implementation of IUPortCode class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
35#include "IUPortCode.hh"
36#include "SocketCodeTable.hh"
37#include "ObjectState.hh"
38
39using std::string;
40
41const std::string IUPortCode::OSNAME_IU_PORT_CODE = "iu_port_code";
42
43/**
44 * The constructor.
45 *
46 * Registers the created instance to the given socket code table
47 * automatically.
48 *
49 * @param immediateUnit Name of the immediate unit.
50 * @param encoding The encoding for the register file port.
51 * @param extraBits The number of extra zero bits in the encoding.
52 * @param indexWidth The number of bits reserved for the register index.
53 * @param parent The parent socket code table.
54 * @exception ObjectAlreadyExists If the socket code table has an encoding
55 * defined for the same port already, or if
56 * the encoding is ambiguous with another
57 * encoding in the same socket code table.
58 * @exception OutOfRange If some of the given values is out of range.
59 */
61 const std::string& immediateUnit, unsigned int encoding,
62 unsigned int extraBits, int indexWidth, SocketCodeTable& parent)
63 : PortCode(immediateUnit, encoding, extraBits, indexWidth) {
64 setParent(NULL);
65 parent.addIUPortCode(*this);
67}
68
69/**
70 * The constructor.
71 *
72 * Creates an IU port code without port encoding. That is, the port
73 * code consists of mere register index. This is useful if the parent
74 * socket code table does not contain other port codes. Registers the
75 * created instance to the given socket code table automatically.
76 *
77 * @param immediateUnit Name of the immediate unit.
78 * @param indexWidth The number of bits reserved for the register index.
79 * @param parent The parent socket code table.
80 * @exception ObjectAlreadyExists If the socket code table has an encoding
81 * defined for the same port already, or if
82 * the encoding is ambiguous with another
83 * encoding in the same socket code table.
84 * @exception OutOfRange If some of the given values is out of range.
85 */
87 const std::string& immediateUnit, int indexWidth, SocketCodeTable& parent)
88 : PortCode(immediateUnit, indexWidth) {
89 setParent(NULL);
90 parent.addIUPortCode(*this);
92}
93
94/**
95 * The constructor.
96 *
97 * Loads the state of the object from the given ObjectState tree.
98 *
99 * @param state The ObjectState tree.
100 * @param parent The parent encoding map.
101 * @exception ObjectStateLoadingException If an error occurs while loading
102 * the state.
103 * @exception ObjectAlreadyExists If the socket code table has an encoding
104 * defined for the same port already, or if
105 * the encoding is ambiguous with another
106 * encoding in the same socket code table.
107 */
109 : PortCode(state) {
110 if (state->name() != OSNAME_IU_PORT_CODE) {
111 const string procName = "IUPortCode::IUPortCode";
112 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
113 }
114
115 setParent(NULL);
116 parent.addIUPortCode(*this);
118}
119
120/**
121 * The destructor.
122 */
128
129
130/**
131 * Saves the state of the object to an ObjectState tree.
132 *
133 * @return The newly created ObjectState tree.
134 */
139 return state;
140}
IUPortCode(const std::string &immediateUnit, unsigned int encoding, unsigned int extraBits, int indexWidth, SocketCodeTable &parent)
Definition IUPortCode.cc:60
static const std::string OSNAME_IU_PORT_CODE
ObjectState name for RF port code.
Definition IUPortCode.hh:55
virtual ~IUPortCode()
virtual ObjectState * saveState() const
void setName(const std::string &name)
std::string name() const
virtual ObjectState * saveState() const
Definition PortCode.cc:237
SocketCodeTable * parent() const
Definition PortCode.cc:226
void setParent(SocketCodeTable *parent)
Definition PortCode.cc:256
void removeIUPortCode(IUPortCode &code)
void addIUPortCode(IUPortCode &code)