OpenASIP 2.2
Loading...
Searching...
No Matches
OperationBehavior.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 OperationBehavior.cc
26 *
27 * Implementations of OperationBehavior class.
28 *
29 * @author Pekka Jääskeläinen 2004 (pekka.jaaskelainen-no.spam-tut.fi)
30 * @note rating: red
31 * @note reviewed 19 August 2004 by pj, jn, ao, ac
32 */
33
34#include <string>
35
36#include "OperationBehavior.hh"
37#include "Application.hh"
38#include "Exception.hh"
39#include "OperationState.hh"
40#include "OperationContext.hh"
41#include "OperationPool.hh"
42#include "OperationGlobals.hh"
43#include "Operation.hh"
44#include "Operand.hh"
45
46using std::string;
47
48
49/**
50 * Constructor with NULL parent.
51 */
53 : parent_(NullOperation::instance()){
54}
55
56/**
57 * Constructor with parent.
58 */
60 : parent_(parent) {
61}
62
63/**
64 * Destructor.
65 */
68
69/**
70 * Simulates the process of starting the execution of an operation.
71 *
72 * Clients should invoke isTriggerLocking() before any attempt to call
73 * simulateTrigger() in current clock cycle. By default, an operation
74 * invocations are successful.
75 *
76 *
77 * @param io The input operands and the results of the operation.
78 * @param context The operation context affecting the operation results.
79 * @return bool True if all values could be computed, false otherwise.
80 * @exception Exception Depends on the implementation.
81 */
82bool
84 SimValue**,
85 OperationContext&) const {
86 return true;
87}
88
89/**
90 * The default implementation of input operand validation.
91 *
92 * This always return true. This is meant to be overridden in derived classes
93 * when necessary.
94 */
95bool
97 const InputOperandVector& /*inputs*/,
98 const OperationContext& /*context*/) const {
99
100 return true;
101}
102
103
104/**
105 * Writes text to the output stream specified
106 *
107 * @param text text to be written to the output stream
108 */
109void
111 const char* text) const {
113}
114
115
116/**
117 * Creates the instance of operation state for this operation and adds it to
118 * its operation context.
119 *
120 * By default this function does nothing (assumes that the operation has no
121 * state). If the operation context already contains the required operation
122 * state instance, nothing is done.
123 *
124 * @param context The operation context to add the state to.
125 */
126void
129
130/**
131 * Deletes the instance of operation state for this operation from its
132 * operation context.
133 *
134 * By default this function does nothing (assumes that the operation has no
135 * state). If the operation context does not contain the required operation
136 * state instance, nothing is done.
137 *
138 * @param context The operation context to delete the state from.
139 */
140void
143
144/**
145 * Returns the name of the state of this operation behavior.
146 *
147 * By default returns an empty string which denotes that there is no state.
148 *
149 * @return The state name for this operation behavior.
150 */
151const char*
153 return "";
154}
155
156/**
157 * If behavior can be simulated.
158 *
159 * @return true If simulation of behavior is possible.
160 */
161bool
163 return true;
164}
165
166///////////////////////////////////////////////////////////////////////////////
167// NullOperationBehavior
168///////////////////////////////////////////////////////////////////////////////
169
171const char* ERROR_MESSAGE =
172 "Attempted to use a NULL OperationBehavior object.";
173
174/**
175 * Writes an error message to error log and aborts the program.
176 *
177 * @param io Not used.
178 * @param context Not used.
179 * @return Never returns.
180 */
181bool
189
190/**
191 * Writes an error message to error log and aborts the program.
192 *
193 * @param io Not used.
194 * @param context Not used.
195 * @return Never returns.
196 */
197bool
199 SimValue**,
200 OperationContext&) const {
201
203 return true;
204}
205
#define abortWithError(message)
const char * ERROR_MESSAGE
virtual bool lateResult(SimValue **, OperationContext &context) const
virtual bool simulateTrigger(SimValue **, OperationContext &context) const
static NullOperationBehavior instance_
virtual void createState(OperationContext &context) const
virtual bool simulateTrigger(SimValue **io, OperationContext &context) const =0
std::vector< SimValue > InputOperandVector
Input operand type for areValid()
virtual void deleteState(OperationContext &context) const
virtual bool canBeSimulated() const
virtual void writeOutput(const char *text) const
virtual bool areValid(const InputOperandVector &inputs, const OperationContext &context) const
virtual const char * stateName() const
static std::ostream & outputStream()