OpenASIP 2.2
Loading...
Searching...
No Matches
FUCollisionMatrixIndex.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 FUCollisionMatrixIndex.cc
26 *
27 * Definition of FUCollisionMatrixIndex class.
28 *
29 * @author Pekka Jääskeläinen 2007 (pekka.jaaskelainen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
34#include "CollisionMatrix.hh"
36#include "FunctionUnit.hh"
37#include "SequenceTools.hh"
38
39/**
40 * Builds collision matrices for all operations in the FU and an empty
41 * collision matrix for the pseudo no-operation.
42 *
43 * Matrices are stored in the order returned by FunctionUnit::operation(),
44 * the NOP matrix is at index FunctionUnit::operationCount().
45 *
46 * @param functionUnit The FU to build the matrices for.
47 */
49 const TTAMachine::FunctionUnit& functionUnit) {
50
51 FUReservationTableIndex tables(functionUnit);
52 int width = 0;
53 int height = 0;
54 for (int i = 0; i < functionUnit.operationCount(); ++i) {
55
56 CollisionMatrix* matrix = new CollisionMatrix(tables, i);
57
58#ifndef NDEBUG
59 if (width == 0 && height == 0) {
60 width = matrix->columnCount();
61 height = matrix->rowCount();
62 } else {
63 // all matrices should be of the same dimension, otherwise there's
64 // a bug somewhere
65 assert(matrix->columnCount() == width);
66 assert(matrix->rowCount() == height);
67 }
68#endif
69 matrices_.push_back(matrix);
70 }
71
72 // The NOP.
73 matrices_.push_back(new CollisionMatrix(width, height, false));
74}
75
76/**
77 * Destructor.
78 */
82
83/**
84 * Returns the collision matrix at the given index.
85 *
86 * @param operation The index of the operat
87 */
90 return *matrices_.at(index);
91}
92
93/**
94 * Returns the count of collision matrices in the index.
95 *
96 * @return Count of collision matrices.
97 */
98int
100 return matrices_.size();
101}
102
#define assert(condition)
int columnCount() const
int rowCount() const
FUCollisionMatrixIndex(const TTAMachine::FunctionUnit &functionUnit)
CollisionMatrix & at(int index)
std::vector< CollisionMatrix * > matrices_
Stores all collision matrices, including one for the pseudo NOP.
static void deleteAllItems(SequenceType &aSequence)
virtual int operationCount() const