OpenASIP 2.2
Loading...
Searching...
No Matches
CostDBEntryStatsRF.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 CostDBEntryStatsRF.cc
26 *
27 * Implementation of CostDBEntryStatsRF class.
28 *
29 * @author Tommi Rantanen 2003 (tommi.rantanen-no.spam-tut.fi)
30 * @author Jari Mäntyneva 2005 (jari.mantyneva-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#include <map>
35
36#include "CostDBEntryStatsRF.hh"
37#include "Application.hh"
38#include "Conversion.hh"
39
40using std::string;
41using std::map;
42
43
44/**
45 * Constructor.
46 *
47 * @param areaData area.
48 * @param delayData delay.
49 */
50CostDBEntryStatsRF::CostDBEntryStatsRF(double areaData, double delayData):
51 CostDBEntryStats(areaData, delayData) {
52}
53
54/**
55 * Constructor.
56 *
57 * Combines two statistics into one using coefficient as a weighting
58 * factor on interpolating the statistics. For example, if weighting
59 * factor is 0.4, the first area 100 and the second 200, area of new
60 * statistics will be 140. delay and energy will be handled similarly.
61 *
62 * @param stats1 First statistics.
63 * @param stats2 Second statistics.
64 * @param coefficient Weighting factor.
65 */
67 const CostDBEntryStatsRF& stats1,
68 const CostDBEntryStatsRF& stats2,
69 double coefficient):
70 CostDBEntryStats(stats1, stats2, coefficient) {
71}
72
73
74/**
75 * Destructor.
76 */
79
80
81
82/**
83 * Create correct type of statistics.
84 *
85 * @return Correct type of statistics.
86 */
89
90 return new CostDBEntryStatsRF(area(), delay());
91}
92
93/**
94 * Returns the energy of an entry in an active cycle.
95 *
96 * The function will fail since register files do not have unambiguous
97 * energy for the whole unit but separately for each access pairs.
98 *
99 * @return The energy of an entry in an active cycle.
100 * @exception WrongSubclass An illegal function was called for this
101 * instance.
102 * @exception KeyNotFound Never thown by this function.
103 */
104double
106 throw WrongSubclass(__FILE__, __LINE__,
107 "CostDBEntryStatsRF::energyActive");
108 return 0.0; // stupid return statement to make compiler quiet
109}
110
111/**
112 * Returns the read energy of an entry.
113 *
114 * @return The read energy of an entry.
115 * @exception WrongSubclass Never thrown by this function.
116 * @exception KeyNotFound Throws if read energy is not set.
117 */
118double
122
123/**
124 * Returns the write energy of an entry.
125 *
126 * @return The write energy of an entry.
127 * @exception WrongSubclass Never thrown by this function.
128 * @exception KeyNotFound Throws if write energy is not set.
129 */
130double
134
135/**
136 * Returns the reads and writes energy of an entry.
137 *
138 * @param reads The number of simultaneus reads done for the unit.
139 * @param writes The number of simultaneus writes done for the unit.
140 * @return The reads and writes energy of an entry.
141 * @exception WrongSubclass Never thrown by this function.
142 * @exception KeyNotFound Throws if the requested energy is not found.
143 */
144double
145CostDBEntryStatsRF::energyReadWrite(int reads, int writes) const {
146 return findEnergy(generateReadWriteString(reads, writes));
147}
148
149/**
150 * Set the energy of an entry in an active cycle.
151 *
152 * The function will fail since function units do not have unambiguous
153 * energy for the whole unit but separately for each operation.
154 *
155 * @param energy The energy of an entry in an active cycle.
156 * @exception WrongSubclass An illegal function was called for this
157 * instance.
158 */
159void
161 throw WrongSubclass(__FILE__, __LINE__,
162 "CostDBEntryStatsRF::setEnergyActive");
163}
164
165/**
166 * Set the read energy of an entry.
167 *
168 * @param energy The read energy of an entry.
169 * @exception WrongSubclass An illegal function was called for this instance.
170 */
171void
173 addEnergy(ENERGY_READ, energy);
174}
175
176/**
177 * Set the write energy of an entry.
178 *
179 * @param energy The write energy of an entry.
180 * @exception WrongSubclass Never thrown by this function.
181 */
182void
186
187/**
188 * Set the reads and writes energy of an entry.
189 *
190 * @param energy The reads and writes energy of an entry.
191 * @param reads The number of reads of the unit.
192 * @param writes The number of writes of the unit.
193 * @exception WrongSubclass Never thrown by this function.
194 */
195void
196CostDBEntryStatsRF::setEnergyReadWrite(int reads, int writes, double energy) {
197 addEnergy(generateReadWriteString(reads, writes), energy);
198}
199
200/**
201 * Returns a string corresponding to given (read,write) combination in
202 * internal format.
203 *
204 * @param reads Number of simultaneous reads.
205 * @param writes Number of simultaneous writes.
206 * @return String corresponding to given (read,write) combination in
207 * internal format.
208 */
209std::string
211
212 return ENERGY_READ_WRITE + "_" +
213 Conversion::toString(reads) + "_" +
214 Conversion::toString(writes);
215}
static std::string toString(const T &source)
virtual double energyActive() const
virtual double energyWrite() const
virtual void setEnergyRead(double energy)
CostDBEntryStatsRF(double areaData, double delayData)
virtual double energyReadWrite(int reads, int writes) const
static std::string generateReadWriteString(int reads, int writes)
virtual void setEnergyActive(double energy)
virtual CostDBEntryStats * createStats() const
virtual void setEnergyReadWrite(int reads, int writes, double energy)
virtual double energyRead() const
virtual void setEnergyWrite(double energy)
static const std::string ENERGY_READ_WRITE
String for reads and writes energy.
virtual double findEnergy(const std::string &key) const
virtual double delay() const
static const std::string ENERGY_READ
String for read energy.
static const std::string ENERGY_WRITE
String for write energy.
virtual void addEnergy(const std::string &name, double energy)
virtual double area() const