OpenASIP  2.0
CollisionMatrix.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 CollisionMatrix.cc
26  *
27  * Definition of CollisionMatrix class.
28  *
29  * Matrix' value is 1 if and only if the operation represented by the row
30  * cannot be started after the cycle number represented by the column number.
31  * That is, M[O,I] = 1 in case operation O cannot be started I cycles after, 0
32  * otherwise.
33  *
34  * @author Pekka Jääskeläinen 2006 (pekka.jaaskelainen-no.spam-tut.fi)
35  * @note rating: red
36  */
37 
38 #include "CollisionMatrix.hh"
39 #include "Application.hh"
40 #include "FunctionUnit.hh"
41 #include "PipelineElement.hh"
42 #include "FUPort.hh"
43 #include "HWOperation.hh"
44 #include "Conversion.hh"
45 #include "ResourceVector.hh"
46 #include "ResourceVectorSet.hh"
47 #include "ReservationTable.hh"
49 
50 /**
51  * Builds a collision matrix out of a set of reservation tables and an index
52  * that points to a row in the index.
53  *
54  * The first column is included, that is, it is possible to test whether
55  * an operation can be issued at the same cycle than other operation. This
56  * is useful for the scheduler.
57  *
58  * @param reservationTables Reservation tables of all operations in the FU.
59  * @param index Index of reservation table we compute the matrix for.
60  *
61  */
63  FUReservationTableIndex& reservationTables,
64  std::size_t index) :
65  BitMatrix(
66  reservationTables.at(index).columnCount(),
67  reservationTables.size(), false) {
68 
69  ReservationTable& thisOperation = reservationTables.at(index);
70 
71  for (int row = 0; row < rowCount(); ++row) {
72  const ReservationTable& other = reservationTables.at(row);
73 
74  for (int column = 0; column < columnCount(); ++column) {
76  column, row, thisOperation.conflictsWith(other, column));
77  }
78  }
79 }
80 
81 /**
82  * Constructor.
83  *
84  * Builds a collision matrix with given dimensions and with each value the
85  * same.
86  */
88  std::size_t width, std::size_t height, bool value = false) :
89  BitMatrix(width, height, value) {
90 }
91 
92 /**
93  * Destructor.
94  */
96 }
97 
98 /**
99  * Returns the value of the collision matrix at the given location.
100  *
101  * @param row The row number (operation).
102  * @param column The column number (cycle).
103  * @return The value.
104  */
105 bool
106 CollisionMatrix::isCollision(std::size_t row, std::size_t column) const {
107  return BitMatrix::bitAt(column, row);
108 }
109 
ReservationTable::conflictsWith
bool conflictsWith(const ReservationTable &anotherReservationTable, int cycle) const
BitMatrix
Definition: BitMatrix.hh:49
ReservationTable.hh
ResourceVectorSet.hh
FUReservationTableIndex::at
ReservationTable & at(std::size_t operation)
Definition: FUReservationTableIndex.cc:70
BitMatrix::rowCount
int rowCount() const
HWOperation.hh
FUReservationTableIndex
Definition: FUReservationTableIndex.hh:47
Conversion.hh
Application.hh
CollisionMatrix::CollisionMatrix
CollisionMatrix(FUReservationTableIndex &reservationTables, std::size_t index)
Definition: CollisionMatrix.cc:62
ResourceVector.hh
CollisionMatrix::isCollision
virtual bool isCollision(std::size_t row, std::size_t column) const
Definition: CollisionMatrix.cc:106
CollisionMatrix.hh
FUReservationTableIndex.hh
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
FUPort.hh
BitMatrix::columnCount
int columnCount() const
BitMatrix::bitAt
bool bitAt(int column, int row) const
PipelineElement.hh
ReservationTable
Definition: ReservationTable.hh:49
BitMatrix::setBit
void setBit(int column, int row, bool value)
CollisionMatrix::~CollisionMatrix
virtual ~CollisionMatrix()
Definition: CollisionMatrix.cc:95
FunctionUnit.hh