OpenASIP  2.0
ExecutionPipelineResourceTable.icc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 ExecutionPipelineResourceTable.icc
26  *
27  * Inline definitions for ExecutionPipelineResourceTable class.
28  *
29  * @author Heikki Kultala 2009 (heikki.kultala-no.spam-tut.fi)
30  * @note rating: red
31  */
32 #include "MapTools.hh"
33 
34 unsigned int ExecutionPipelineResourceTable::pipelineSize() const {
35  return operationPipelines_.size();
36 }
37 
38 unsigned int ExecutionPipelineResourceTable::numberOfResources() const {
39  return numberOfResources_;
40 }
41 
42 unsigned int ExecutionPipelineResourceTable::maximalLatency() const {
43  return maximalLatency_;
44 }
45 
46 /**
47  * Returns whether given pipeline resource is used for some operation
48  *
49  * @param op OperationIndex for operation
50  * @param cycle Cycle of the operation.
51  * @param res resource which to query
52  */
53 bool ExecutionPipelineResourceTable:: operationPipeline(
54  int op, int cycle, int res) const {
55  return operationPipelines_[op][cycle][res];
56 }
57 
58 /**
59  * Returns whether the given operation is supported by this FU.
60  */
61 bool ExecutionPipelineResourceTable::hasOperation(
62  const std::string& opName) const {
63  return MapTools::containsKey(operationSupported_, opName);
64 }
65 
66 /**
67  * Gets the index of given operation in the FU.
68  *
69  * If none found , throws Exception
70  */
71 int ExecutionPipelineResourceTable::operationIndex(
72  const std::string& opName) const {
73 
74  if (MapTools::containsKey(operationSupported_, opName)) {
75  return MapTools::valueForKey<int>(operationSupported_, opName);
76  } else {
77  std::string msg = "Operation " + opName ;
78  msg += " is not implemented in " + name() + "!";
79  throw KeyNotFound(__FILE__, __LINE__, __func__, msg);
80  }
81 }
82 
83 /**
84  * Returns the operation latencies for all outputs of an operation.
85  *
86  * @param operationIndex index of the operation.
87  */
88 const std::map<int,int>& ExecutionPipelineResourceTable::operationLatency(
89  unsigned int operationIndex) const {
90  return operationLatencies_[operationIndex];
91 }
92 
93 const std::string& ExecutionPipelineResourceTable::name() const {
94  return name_;
95 }