OpenASIP  2.0
TemplateSlot.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 TemplateSlot.cc
26  *
27  * Implementation of class TemplateSlot.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "TemplateSlot.hh"
34 #include "MapTools.hh"
35 #include "ImmediateUnit.hh"
36 #include "ContainerTools.hh"
37 #include "ObjectState.hh"
38 
39 using std::string;
40 
41 namespace TTAMachine {
42 
43 // initialization of static data members
44 const string TemplateSlot::OSNAME_TEMPLATE_SLOT = "template_slot";
45 const string TemplateSlot::OSKEY_SLOT = "slot";
46 const string TemplateSlot::OSKEY_WIDTH = "width";
47 const string TemplateSlot::OSKEY_DESTINATION = "destination";
48 const string TemplateSlot::OSKEY_RF_READ = "rf_read";
49 const string TemplateSlot::OSKEY_RF_WRITE = "rf_write";
50 const string TemplateSlot::OSKEY_FU_READ = "fu_read";
51 const string TemplateSlot::OSKEY_FU_WRITE = "fu_write";
52 
53 /**
54  * Constructor.
55  *
56  * @param slot The bus or which is programmed by the instruction bit field
57  * of this template slot.
58  * @param width The number of significant bits that can be encoded in this
59  * instruction field.
60  * @param destination The destination ImmediateUnit, that is, the
61  * ImmediateUnit that contains the registers that can be
62  * written with the bits in this template slot.
63  */
65  const Bus& slot,
66  int width,
67  ImmediateUnit& destination) :
68  bus_(&slot), immSlot_(NULL), width_(width), destination_(&destination) {
69 }
70 
71 /**
72  * Constructor.
73  *
74  * @param slot The immediate slot which is programmed by the instruction bit
75  * field of this template slot.
76  * @param width The number of significant bits that can be encoded in this
77  * instruction field.
78  * @param destination The destination ImmediateUnit, that is, the
79  * ImmediateUnit that contains the registers that can be
80  * written with the bits in this template slot.
81  */
83  const ImmediateSlot& slot,
84  int width,
85  ImmediateUnit& destination) :
86  bus_(NULL), immSlot_(&slot), width_(width), destination_(&destination) {
87 }
88 
89 /**
90  * Creates an implicit slot in a template that does not target
91  * an ImmediateUnit.
92  *
93  * @param slot The bus or which is programmed by the instruction bit field
94  * of this template slot.
95  */
96 
98  : bus_(&slot), width_(0), destination_(NULL) {}
99 
100 /**
101  * Destructor.
102  */
104 }
105 
106 
107 /**
108  * Saves the state of the object into an ObjectState instance.
109  *
110  * @return The newly created ObjectState instance.
111  */
114  ObjectState* slotState = new ObjectState(OSNAME_TEMPLATE_SLOT);
115  slotState->setAttribute(OSKEY_SLOT, slot());
116  slotState->setAttribute(OSKEY_WIDTH, width());
117  slotState->setAttribute(OSKEY_DESTINATION, destination()->name());
118  return slotState;
119 }
120 }
TTAMachine::TemplateSlot::OSKEY_SLOT
static const std::string OSKEY_SLOT
ObjectState attribute key for slot name.
Definition: TemplateSlot.hh:81
TTAMachine::TemplateSlot::saveState
ObjectState * saveState() const
Definition: TemplateSlot.cc:113
TTAMachine::TemplateSlot::OSNAME_TEMPLATE_SLOT
static const std::string OSNAME_TEMPLATE_SLOT
ObjectState name for template slot.
Definition: TemplateSlot.hh:79
TTAMachine::TemplateSlot::TemplateSlot
TemplateSlot(const Bus &slot, int width, ImmediateUnit &destination)
Definition: TemplateSlot.cc:64
TTAMachine::TemplateSlot::~TemplateSlot
virtual ~TemplateSlot()
Definition: TemplateSlot.cc:103
MapTools.hh
TTAMachine::Bus
Definition: Bus.hh:53
ObjectState
Definition: ObjectState.hh:59
ImmediateUnit.hh
TTAMachine::TemplateSlot::OSKEY_WIDTH
static const std::string OSKEY_WIDTH
ObjectState attribute key for bit width.
Definition: TemplateSlot.hh:83
TTAMachine::TemplateSlot::OSKEY_FU_WRITE
static const std::string OSKEY_FU_WRITE
Definition: TemplateSlot.hh:93
TemplateSlot.hh
TTAMachine::TemplateSlot::OSKEY_RF_READ
static const std::string OSKEY_RF_READ
Definition: TemplateSlot.hh:87
TTAMachine::TemplateSlot::destination
ImmediateUnit * destination() const
ObjectState.hh
TTAMachine::TemplateSlot::slot
std::string slot() const
TTAMachine::TemplateSlot::OSKEY_RF_WRITE
static const std::string OSKEY_RF_WRITE
Definition: TemplateSlot.hh:89
TTAMachine::TemplateSlot::OSKEY_FU_READ
static const std::string OSKEY_FU_READ
Definition: TemplateSlot.hh:91
TTAMachine
Definition: Assembler.hh:48
TTAMachine::TemplateSlot::width
int width() const
TTAMachine::ImmediateSlot
Definition: ImmediateSlot.hh:44
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
ContainerTools.hh
TTAMachine::TemplateSlot::OSKEY_DESTINATION
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination.
Definition: TemplateSlot.hh:85
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50