OpenASIP  2.0
OperationBehavior.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 OperationBehavior.hh
26  *
27  * Declaration of OperationBehavior class.
28  *
29  * @author Pekka Jääskeläinen 2004 (pekka.jaaskelainen-no.spam-tut.fi)
30  * @note This file is used in compiled simulation. Keep dependencies *clean*
31  * @note rating: red
32  * @note reviewed 19 August 2004 by pj, jn, ao, ac
33  */
34 
35 
36 #ifndef TTA_OPERATION_BEHAVIOR_HH
37 #define TTA_OPERATION_BEHAVIOR_HH
38 
39 #include <vector>
40 #include "SimValue.hh"
41 
42 class OperationContext;
43 class Operation;
44 
45 /**
46  * Interface to access the behavior model of TTA operations.
47  *
48  * This abstract class that is inherited by the custom operation behavior
49  * classes. Instances of user defined OperationBehavior derived classes are
50  * loaded run-time from dynamic library modules (plugins).
51  *
52  */
54 public:
55 
56  /// Input operand type for areValid()
57  typedef std::vector<SimValue> InputOperandVector;
58 
59  virtual bool simulateTrigger(
60  SimValue** io,
61  OperationContext& context) const = 0;
62  virtual bool areValid(
63  const InputOperandVector& inputs,
64  const OperationContext& context) const;
65 
66  virtual void createState(OperationContext& context) const;
67  virtual void deleteState(OperationContext& context) const;
68 
69  virtual const char* stateName() const;
70 
71  virtual bool canBeSimulated() const;
72 
73  virtual void writeOutput(const char* text) const;
74 
76  OperationBehavior(const Operation& parent);
77  virtual ~OperationBehavior();
78 
79 protected:
81 };
82 
83 ///////////////////////////////////////////////////////////////////////////////
84 // NullOperationBehavior
85 ///////////////////////////////////////////////////////////////////////////////
86 
87 /**
88  * Singleton class to represent an undefined operation behavior.
89  *
90  * All methods cause program abort with an error log message.
91  *
92  */
94 public:
96 
97  virtual bool simulateTrigger(
98  SimValue**,
99  OperationContext& context) const;
100  virtual bool lateResult(
101  SimValue**,
102  OperationContext& context) const;
103 
104 protected:
106 
107 private:
109 
110 };
111 
112 #endif
OperationBehavior::writeOutput
virtual void writeOutput(const char *text) const
Definition: OperationBehavior.cc:110
OperationBehavior::~OperationBehavior
virtual ~OperationBehavior()
Definition: OperationBehavior.cc:66
OperationBehavior::canBeSimulated
virtual bool canBeSimulated() const
Definition: OperationBehavior.cc:162
NullOperationBehavior::lateResult
virtual bool lateResult(SimValue **, OperationContext &context) const
Definition: OperationBehavior.cc:198
NullOperationBehavior::instance_
static NullOperationBehavior instance_
Definition: OperationBehavior.hh:108
OperationContext
Definition: OperationContext.hh:56
OperationBehavior::areValid
virtual bool areValid(const InputOperandVector &inputs, const OperationContext &context) const
Definition: OperationBehavior.cc:96
NullOperationBehavior::NullOperationBehavior
NullOperationBehavior()
Definition: OperationBehavior.hh:105
OperationBehavior::createState
virtual void createState(OperationContext &context) const
Definition: OperationBehavior.cc:127
SimValue
Definition: SimValue.hh:96
OperationBehavior::simulateTrigger
virtual bool simulateTrigger(SimValue **io, OperationContext &context) const =0
Definition: OperationBehavior.cc:83
OperationBehavior::OperationBehavior
OperationBehavior()
Definition: OperationBehavior.cc:52
NullOperationBehavior::simulateTrigger
virtual bool simulateTrigger(SimValue **, OperationContext &context) const
Definition: OperationBehavior.cc:182
OperationBehavior::stateName
virtual const char * stateName() const
Definition: OperationBehavior.cc:152
Operation
Definition: Operation.hh:59
NullOperationBehavior
Definition: OperationBehavior.hh:93
OperationBehavior::InputOperandVector
std::vector< SimValue > InputOperandVector
Input operand type for areValid()
Definition: OperationBehavior.hh:57
OperationBehavior
Definition: OperationBehavior.hh:53
NullOperationBehavior::instance
static NullOperationBehavior & instance()
Definition: OperationBehavior.hh:95
OperationBehavior::deleteState
virtual void deleteState(OperationContext &context) const
Definition: OperationBehavior.cc:141
SimValue.hh
OperationBehavior::parent_
const Operation & parent_
Definition: OperationBehavior.hh:80