OpenASIP 2.2
Loading...
Searching...
No Matches
FUValidator.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 FUValidator.cc
26 *
27 * Implementation of FUValidator class.
28 *
29 * @author Lasse Laasonen 2006 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <boost/format.hpp>
34
35#include "FUValidator.hh"
36#include "MachineValidator.hh"
38
39#include "FunctionUnit.hh"
40#include "ExecutionPipeline.hh"
41#include "HWOperation.hh"
42#include "FUPort.hh"
43
44using namespace TTAMachine;
45
46/**
47 * Checks that the operands used in the operations of the given FU are
48 * bound to some port.
49 *
50 * @param fu The function unit.
51 * @param results Results of the validation are added to the given instance.
52 */
53void
56 MachineValidatorResults& results) {
57
58 for (int i = 0; i < fu.operationCount(); i++) {
59 HWOperation* operation = fu.operation(i);
60 ExecutionPipeline* pLine = operation->pipeline();
62 for (int i = 0; i < pLine->latency(); i++) {
64 pLine->readOperands(i);
65 ExecutionPipeline::OperandSet writtenOperands =
66 pLine->writtenOperands(i);
67 usedOperands.insert(
68 readOperands.begin(), readOperands.end());
69 usedOperands.insert(
70 writtenOperands.begin(), writtenOperands.end());
71 }
72
73
74 for (ExecutionPipeline::OperandSet::const_iterator iter =
75 usedOperands.begin();
76 iter != usedOperands.end(); iter++) {
77 int io = *iter;
78 FUPort* port = operation->port(io);
79 if (port == NULL) {
80 boost::format errorMsg(
81 "IO number %1% is not bound to any port in "
82 "operation %2% in FU %3%.");
83 errorMsg % io % operation->name() % fu.name();
84 results.addError(
86 }
87 }
88 }
89}
90
91
92/**
93 * Checks that the FU has at least one operation which is valid, i.e.
94 * has at least one triggering input port
95 *
96 * @param fu The function unit.
97 * @param results Results of the validation are added to the given instance.
98 */
99void
101 const TTAMachine::FunctionUnit& fu,
102 MachineValidatorResults& results) {
103
104 for (int i = 0; i < fu.operationCount(); i++) {
105 HWOperation* operation = fu.operation(i);
106 ExecutionPipeline* pLine = operation->pipeline();
108 for (int i = 0; i < pLine->latency(); i++) {
109 ExecutionPipeline::OperandSet readOperands =
110 pLine->readOperands(i);
111 for (ExecutionPipeline::OperandSet::const_iterator iter =
112 readOperands.begin(); iter != readOperands.end(); iter++) {
113 FUPort* port = operation->port(*iter);
114 if (port != NULL && port->isTriggering()) {
115 return;
116 }
117 }
118 }
119 }
120
121 boost::format errorMsg("FU %1% has no valid operations.");
122 errorMsg % fu.name();
123 results.addError(MachineValidator::FU_NO_VALID_OPERATIONS, errorMsg.str());
124}
static void checkOperations(const TTAMachine::FunctionUnit &fu, MachineValidatorResults &results)
static void checkOperandBindings(const TTAMachine::FunctionUnit &fu, MachineValidatorResults &results)
void addError(MachineValidator::ErrorCode code, const std::string &errorMsg)
@ USED_IO_NOT_BOUND
Pipeline uses an IO which is not bound.
@ FU_NO_VALID_OPERATIONS
FU has no operations with a trigger.
virtual TCEString name() const
OperandSet writtenOperands(int cycle) const
OperandSet readOperands(int cycle) const
std::set< int > OperandSet
Set for operand indexes.
virtual bool isTriggering() const
Definition FUPort.cc:182
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
ExecutionPipeline * pipeline() const
virtual FUPort * port(int operand) const
const std::string & name() const