OpenASIP  2.0
OneCycleOperationExecutor.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 OneCycleOperationExecutor.cc
26  *
27  * Definition of OneCycleOperationExecutor class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
35 #include "OperationContext.hh"
36 #include "SimValue.hh"
37 #include "Operation.hh"
38 #include "SequenceTools.hh"
39 #include "PortState.hh"
40 #include "OperationPool.hh"
41 #include "SimulatorToolbox.hh"
42 #include "Application.hh"
43 
44 using std::vector;
45 using std::string;
46 
47 /// a dummy simvalue which is given for operands that are not bound
48 SimValue dummy(32);
49 
50 /**
51  * Constructor.
52  *
53  * @param parent Parent of the executor.
54  */
56  OperationExecutor(parent), context_(NULL), operation_(NULL),
57  io_(NULL), ready_(false), ioVectorInitialized_(false) {
58 }
59 
60 /**
61  * Destructor.
62  */
64  delete[] io_;
65  io_ = NULL;
66 }
67 
68 /**
69  * Returns the latency of the executor.
70  *
71  * @return The latency of the executor.
72  */
73 int
75  return 1;
76 }
77 
78 /**
79  * Initializes the operation input/output vector.
80  *
81  * The I/O vector points directly to the function unit port register
82  * values. This is possible because there cannot be any other pending
83  * operations at once because of latency of 1.
84  */
85 inline void
88  return;
89  io_ = new SimValue*[bindings_.size()];
90  for (size_t i = 0; i < bindings_.size(); ++i) {
91  io_[i] = const_cast<SimValue*>(&bindings_[i]->value());
92  }
93  ioVectorInitialized_ = true;
94 }
95 
96 /**
97  * Starts the execution of the operation.
98  *
99  * @param op Operation to be triggered.
100  */
101 void
103  operation_ = &op;
107 }
108 
109 /**
110  * Advances clock by one cycle.
111  */
112 void
114  operation_ = NULL;
115  hasPendingOperations_ = false;
116 }
117 
118 /**
119  * Copies OperationExecutor.
120  *
121  * @return The copied OperationExecutor.
122  */
125  return new OneCycleOperationExecutor(*this);
126 }
127 
128 /**
129  * Sets new context for the OperationExecutor.
130  *
131  * @param context New OperationContext.
132  */
133 void
135  context_ = &context;
136 }
137 
OneCycleOperationExecutor::io_
SimValue ** io_
Inputs and outputs for the operation.
Definition: OneCycleOperationExecutor.hh:69
OneCycleOperationExecutor::ioVectorInitialized_
bool ioVectorInitialized_
True if the io_ vector is initialized-.
Definition: OneCycleOperationExecutor.hh:73
OneCycleOperationExecutor::operation_
Operation * operation_
Operation to be executed next.
Definition: OneCycleOperationExecutor.hh:67
OneCycleOperationExecutor::context_
OperationContext * context_
Operation context.
Definition: OneCycleOperationExecutor.hh:65
OperationContext
Definition: OperationContext.hh:56
OneCycleOperationExecutor::OneCycleOperationExecutor
OneCycleOperationExecutor(FUState &parent)
Definition: OneCycleOperationExecutor.cc:55
SequenceTools.hh
OneCycleOperationExecutor::ready_
bool ready_
True if all the results are ready.
Definition: OneCycleOperationExecutor.hh:71
SimValue
Definition: SimValue.hh:96
FUState
Definition: FUState.hh:58
OneCycleOperationExecutor::startOperation
virtual void startOperation(Operation &op)
Definition: OneCycleOperationExecutor.cc:102
SimulatorToolbox.hh
OperationExecutor::hasPendingOperations_
bool hasPendingOperations_
This is set to true if the OperationExecutor is not in 'idle' mode.
Definition: OperationExecutor.hh:73
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
OneCycleOperationExecutor.hh
Application.hh
OperationExecutor::bindings_
std::vector< PortState * > bindings_
PortStates that are bound to a certain input or output operand.
Definition: OperationExecutor.hh:70
OneCycleOperationExecutor::latency
virtual int latency() const
Definition: OneCycleOperationExecutor.cc:74
Operation.hh
OperationExecutor
Definition: OperationExecutor.hh:49
Operation
Definition: Operation.hh:59
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
OneCycleOperationExecutor::copy
virtual OperationExecutor * copy()
Definition: OneCycleOperationExecutor.cc:124
SimValue.hh
Operation::simulateTrigger
virtual bool simulateTrigger(SimValue **, OperationContext &context) const
Definition: Operation.cc:555
OneCycleOperationExecutor::initializeIOVector
void initializeIOVector()
Definition: OneCycleOperationExecutor.cc:86
OneCycleOperationExecutor::setContext
virtual void setContext(OperationContext &context)
Definition: OneCycleOperationExecutor.cc:134
OneCycleOperationExecutor::~OneCycleOperationExecutor
virtual ~OneCycleOperationExecutor()
Definition: OneCycleOperationExecutor.cc:63
OperationPool.hh
OperationContext.hh
PortState.hh
OneCycleOperationExecutor::advanceClock
virtual void advanceClock()
Definition: OneCycleOperationExecutor.cc:113