OpenASIP  2.0
ReservationTable.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 ReservationTable.cc
26  *
27  * Implementation of ReservationTable class.
28  *
29  * @author Pekka Jääskeläinen 2007 (pekka.jaaskelainen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <cmath>
34 #include <sstream>
35 
36 #include "ReservationTable.hh"
37 #include "FunctionUnit.hh"
38 #include "BaseType.hh"
39 #include "HWOperation.hh"
40 #include "PipelineElement.hh"
41 #include "ExecutionPipeline.hh"
42 
43 /**
44  * Builds an empty reservation table of given width for the given function
45  * unit.
46  *
47  * @param fu The function unit of which resources to build the reservation
48  * table of.
49  * @param cycleCount The count of cycle columns.
50  */
52  BitMatrix(
53  fu.maxLatency(),
54  fu.operationPortCount() + fu.pipelineElementCount(),
55  false) {
56 }
57 
58 /**
59  * Builds a reservation table for the given operation.
60  *
61  * Also includes empty resource rows so the reservation table is compatible
62  * with the global reservation table for the whole function unit.
63  *
64  * @param operation The operation of which resources to use.
65  */
67  BitMatrix(
68  operation.parentUnit()->maxLatency(),
69  operation.parentUnit()->operationPortCount() +
70  operation.parentUnit()->pipelineElementCount(), false) {
71 
72  const TTAMachine::FunctionUnit& fu = *operation.parentUnit();
73 
74  // First resource rows represent the input and output ports of the FU.
75  for (int p = 0; p < fu.operationPortCount(); ++p) {
76  for (int cycle = 0; cycle < columnCount(); ++cycle) {
77  setBit(
78  cycle, p, operation.pipeline()->isPortUsed(
79  *fu.operationPort(p), cycle));
80  }
81  }
82  // Rest of the rows are pipeline resources.
83  for (int r = 0; r < fu.pipelineElementCount(); ++r) {
84  for (int cycle = 0; cycle < columnCount(); ++cycle) {
85  setBit(
86  cycle, fu.operationPortCount() + r,
87  operation.pipeline()->isResourceUsed(
88  fu.pipelineElement(r)->name(), cycle));
89  }
90  }
91 }
92 
93 /**
94  * Destructor.
95  */
97 }
BaseType.hh
BitMatrix
Definition: BitMatrix.hh:49
TTAMachine::HWOperation
Definition: HWOperation.hh:52
TTAMachine::ExecutionPipeline::isPortUsed
bool isPortUsed(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:349
ExecutionPipeline.hh
ReservationTable.hh
TTAMachine::PipelineElement::name
const std::string & name() const
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
HWOperation.hh
TTAMachine::FunctionUnit::pipelineElement
virtual PipelineElement * pipelineElement(int index) const
Definition: FunctionUnit.cc:523
TTAMachine::FunctionUnit::operationPortCount
virtual int operationPortCount() const
Definition: FunctionUnit.cc:182
TTAMachine::FunctionUnit::pipelineElementCount
virtual int pipelineElementCount() const
Definition: FunctionUnit.cc:507
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
BitMatrix::columnCount
int columnCount() const
TTAMachine::HWOperation::parentUnit
FunctionUnit * parentUnit() const
Definition: HWOperation.cc:190
ReservationTable::ReservationTable
ReservationTable(const TTAMachine::FunctionUnit &fu)
Definition: ReservationTable.cc:51
PipelineElement.hh
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
BitMatrix::setBit
void setBit(int column, int row, bool value)
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
TTAMachine::ExecutionPipeline::isResourceUsed
bool isResourceUsed(const std::string &name, int cycle) const
Definition: ExecutionPipeline.cc:300
FunctionUnit.hh
ReservationTable::~ReservationTable
virtual ~ReservationTable()
Definition: ReservationTable.cc:96