OpenASIP 2.2
Loading...
Searching...
No Matches
ExecutingOperation.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2010 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 ExecutingOperation.hh
26 *
27 * @author Pekka Jääskeläinen 2010 (pjaaskel-no.spam-cs.tut.fi)
28 */
29
30#ifndef TTA_EXECUTING_OPERATION_HH
31#define TTA_EXECUTING_OPERATION_HH
32
33#include <climits>
34#include <vector>
35
36class Operation;
37class PortState;
38class SimValue;
39
40/**
41 * Models an operation executing in the FU pipeline.
42 *
43 * This is a helper class used by MultiCycleOperationExecutor to produce
44 * a more detailed simulation of operations executing in the FUs. Notably,
45 * this model is used in the interface to override operation simulation
46 * models from SystemC simulations (see tce_systemc.hh).
47 */
49public:
50 ExecutingOperation(Operation& op, unsigned stages) :
51 stage_(0), stages_(stages), free_(true), op_(&op) {}
52
53 /**
54 * Returns the value bound to the input or output operand
55 * with the given ID.
56 *
57 * @note operand is the OSAL ID, thus 1 is the first input and
58 * the outputs follow sequentially.
59 */
60
61 SimValue& io(int operand);
62
63 const Operation& operation() const { return *op_; }
64
65 unsigned stage() const { return stage_; }
66
67 /**
68 * Returns true in case the currently simulated stage for the
69 * operation is the last before finishing the execution.
70 *
71 * The next advanceCycle call will push the operation out from
72 * the FU pipeline after which all results are assumed to have
73 * arrived.
74 */
75 bool isLastPipelineStage() const { return stage_ == stages_ - 1; }
76
77 /**
78 * Methods that should not be called from SystemC models.
79 */
80 void start();
81 void stop();
82 void advanceCycle();
83
84 /**
85 * Models the latency of an operation result.
86 *
87 * This is used to make results visible in the output ports of the FU at
88 * the correct time.
89 */
91 PendingResult(SimValue& result, PortState& targetPort, int latency) :
92 result_(&result), target_(&targetPort), cyclesToGo_(latency),
93 resultLatency_(latency) {
94 }
95
96 /**
97 * Signals a cycle advance.
98 *
99 * Makes the result visible to the output port in time.
100 */
101 void advanceCycle();
102 void reset();
103
104 /// The value that will be written to the target after the
105 /// latency has passed.
107 /// The target port to which the result will be written after the
108 /// latency.
110 /// How many cycles to wait until the result will be written to
111 /// the target.
114 };
115
116 void initIOVec() {
117 for (std::size_t i = 0; i < iostorage_.size(); ++i)
118 iovec_.push_back(&iostorage_.at(i));
119 }
120 /* The input and output values of operation, in their OSAL order.
121
122 The execution model can freely modify them duing the operation
123 execution simulation.
124 */
125 std::vector<SimValue> iostorage_;
126 /// OSAL simulateTrigger() compatible I/O vector for fast execution
127 std::vector<SimValue*> iovec_;
128 /* Buffer for results that have latency cycles left. After cycles
129 have passed, the results are removed from the queue.
130 The outputs are made visible to the FU output registers
131 automatically after the ADF declared execution latency. */
132 std::vector<PendingResult> pendingResults_;
133 // the stage of execution the operation is in
135 // how many stage to simulate (the maximum of the result latencies or the
136 // last pipeline resource usage)
138 bool free_;
139 // the OSAL operation being executed
141};
142
143#endif
ExecutingOperation(Operation &op, unsigned stages)
const Operation & operation() const
std::vector< PendingResult > pendingResults_
unsigned stage() const
std::vector< SimValue * > iovec_
OSAL simulateTrigger() compatible I/O vector for fast execution.
SimValue & io(int operand)
const Operation * op_
std::vector< SimValue > iostorage_
bool isLastPipelineStage() const
SimValue * result_
The value that will be written to the target after the latency has passed.
PendingResult(SimValue &result, PortState &targetPort, int latency)
PortState * target_
The target port to which the result will be written after the latency.
int cyclesToGo_
How many cycles to wait until the result will be written to the target.