2 Copyright (c) 2002-2009 Tampere University.
4 This file is part of TTA-Based Codesign Environment (TCE).
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
25 * @file ReservationTable.icc
27 * Inline implementation of ReservationTable class.
29 * @author Pekka Jääskeläinen 2007 (pekka.jaaskelainen-no.spam-tut.fi)
33 #include "BaseType.hh"
36 * Answers the contention query.
38 * Both reservation tables must be of same size. This implementation is
41 * @param anotherReservationTable The resource table of the issued operation.
42 * @param cycle The column offset at which the another table is matched.
45 ReservationTable::conflictsWith(
46 const ReservationTable& anotherReservationTable, int cycle) const {
48 BitMatrix shifted(*this);
49 for (int i = 0; i < cycle; ++i) {
52 return anotherReservationTable.conflictsWith(shifted);
56 * Issues an operation.
58 * Merges the operation's resource table to this one.
60 * @param anotherReservationTable The resource table of the merged.
63 ReservationTable::issueOperation(ReservationTable& anotherReservationTable) {
64 BitMatrix::orWith(anotherReservationTable);
68 * Advances the simulation cycle count.
70 * The reservation table is shifted left once.
72 * @todo Check if the table is all zeros (idle), thus nothing needs to be done.
75 ReservationTable::advanceCycle() {
76 BitMatrix::shiftLeft();
80 * Checks if the given resource is reserved at the given cycle.
82 * @param resource The resource row.
83 * @param cycle The cycle column.
86 ReservationTable::isReserved(ResourceID resource, int cycle) const {
87 return BitMatrix::bitAt(cycle, resource);