OpenASIP
2.0
src
applibs
Simulator
ExecutingOperation.cc
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.cc
26
*
27
* @author Pekka Jääskeläinen 2010 (pjaaskel-no.spam-cs.tut.fi)
28
*/
29
30
#include "
ExecutingOperation.hh
"
31
#include "
PortState.hh
"
32
33
/**
34
* Returns the value bound to the input or output operand
35
* with the given ID.
36
*
37
* @note operand is the OSAL ID, thus 1 is the first input and
38
* the outputs follow sequentially.
39
*/
40
SimValue
&
41
ExecutingOperation::io
(
int
operand) {
42
return
iostorage_
[operand - 1];
43
}
44
45
/**
46
* Sets the operation execution to be started.
47
*
48
* Should be called at the beginning of a single operation's simulation.
49
*/
50
void
51
ExecutingOperation::start
() {
52
for
(std::size_t i = 0; i <
pendingResults_
.size(); ++i)
53
pendingResults_
[i].reset();
54
free_
=
false
;
55
stage_
= 0;
56
}
57
58
/**
59
* Sets the operation execution to be stopped.
60
*
61
* Should be called at the end of a single operation's simulation. This
62
* sets the object to be reusable for other operation execution.
63
*/
64
void
65
ExecutingOperation::stop
() {
66
free_
=
true
;
67
}
68
69
/**
70
* Should be called at the end of a simulation cycle.
71
*/
72
void
73
ExecutingOperation::advanceCycle
() {
74
for
(std::size_t i = 0; i <
pendingResults_
.size(); ++i)
75
pendingResults_
[i].
advanceCycle
();
76
++
stage_
;
77
}
78
79
///////////////////////////////////////////////////////////////////////////////
80
// PendingResult
81
///////////////////////////////////////////////////////////////////////////////
82
83
/**
84
* Signals a cycle advance.
85
*
86
* Makes the result visible to the output port in time.
87
*/
88
void
89
ExecutingOperation::PendingResult::advanceCycle
() {
90
if
(--
cyclesToGo_
== 0) {
91
target_
->
setValue
(*
result_
);
92
cyclesToGo_
= INT_MAX;
93
}
94
}
95
96
void
97
ExecutingOperation::PendingResult::reset
() {
98
cyclesToGo_ = resultLatency_;
99
}
ExecutingOperation::stage_
int stage_
Definition:
ExecutingOperation.hh:134
ExecutingOperation::iostorage_
std::vector< SimValue > iostorage_
Definition:
ExecutingOperation.hh:125
ExecutingOperation::free_
bool free_
Definition:
ExecutingOperation.hh:138
ExecutingOperation::PendingResult::reset
void reset()
Definition:
ExecutingOperation.cc:97
SimValue
Definition:
SimValue.hh:96
ExecutingOperation::PendingResult::advanceCycle
void advanceCycle()
Definition:
ExecutingOperation.cc:89
ExecutingOperation::PendingResult::cyclesToGo_
int cyclesToGo_
How many cycles to wait until the result will be written to the target.
Definition:
ExecutingOperation.hh:112
ExecutingOperation.hh
ExecutingOperation::io
SimValue & io(int operand)
Definition:
ExecutingOperation.cc:41
ExecutingOperation::PendingResult::target_
PortState * target_
The target port to which the result will be written after the latency.
Definition:
ExecutingOperation.hh:109
ExecutingOperation::stop
void stop()
Definition:
ExecutingOperation.cc:65
ExecutingOperation::PendingResult::result_
SimValue * result_
The value that will be written to the target after the latency has passed.
Definition:
ExecutingOperation.hh:106
ExecutingOperation::advanceCycle
void advanceCycle()
Definition:
ExecutingOperation.cc:73
ExecutingOperation::pendingResults_
std::vector< PendingResult > pendingResults_
Definition:
ExecutingOperation.hh:132
PortState.hh
ExecutingOperation::start
void start()
Definition:
ExecutingOperation.cc:51
RegisterState::setValue
virtual void setValue(const SimValue &value)
Definition:
RegisterState.cc:80
Generated by
1.8.17