OpenASIP  2.0
RFPortCheck.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 RFPortCheck.hh
26  *
27  * Implementation of RFPortCheck class.
28  *
29  * @author Pekka Jääskeläinen 2008 (pekka.jaaskelainen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include <boost/format.hpp>
35 
36 #include "MachineCheck.hh"
37 #include "RFPortCheck.hh"
38 #include "RegisterFile.hh"
39 #include "Machine.hh"
40 #include "MachineCheckResults.hh"
41 
42 using namespace TTAMachine;
43 
44 /**
45  * The constructor.
46  */
47 RFPortCheck::RFPortCheck() : MachineCheck("Sanity checks for RF ports.") {
48 }
49 
50 /**
51  * The destructor.
52  */
54 }
55 
56 /**
57  * Sanity checks the RF ports of the target machine.
58  *
59  * @param mach Machine to be checked.
60  * @param results Check results.
61  * @return True if the check passed
62  */
63 bool
65  const TTAMachine::Machine& mach,
66  MachineCheckResults& results) const {
67 
68  bool checksOk = true;
70  for (int i = 0; i < RFs.count(); i++) {
71  const TTAMachine::RegisterFile& rf = *RFs.item(i);
72  int inputPorts = 0;
73  const int ports = rf.portCount();
74  for (int p = 0; p < ports; ++p) {
75  const TTAMachine::RFPort* port = rf.port(p);
76  if (port->isInput()) {
77  ++inputPorts;
78  break;
79  }
80  }
81  if (inputPorts == 0) {
82  results.addError(
83  *this,
84  (boost::format(
85  "Register file '%s' does not have any input ports.").
86  str()));
87  checksOk = false;
88  }
89  }
90 
91  /// @todo Check if there is no read ports and the register file has
92  /// at least one register which is not a predicate reg (read by GCU).
93 
94  return checksOk;
95 }
96 
RFPortCheck::RFPortCheck
RFPortCheck()
Definition: RFPortCheck.cc:47
RFPortCheck::check
virtual bool check(const TTAMachine::Machine &mach, MachineCheckResults &results) const
Definition: RFPortCheck.cc:64
MachineCheckResults::addError
void addError(const MachineCheck &check, const std::string &errorMsg)
Definition: MachineCheckResults.cc:85
TTAMachine::Machine::Navigator::count
int count() const
TTAMachine::RFPort
Definition: RFPort.hh:45
RFPortCheck.hh
RFPortCheck::~RFPortCheck
virtual ~RFPortCheck()
Definition: RFPortCheck.cc:53
MachineCheck.hh
MachineCheckResults
Definition: MachineCheckResults.hh:46
Machine.hh
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
MachineCheckResults.hh
TTAMachine::BaseRegisterFile::port
virtual RFPort * port(const std::string &name) const
Definition: BaseRegisterFile.cc:129
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
RegisterFile.hh
TTAMachine::Port::isInput
virtual bool isInput() const
Definition: Port.cc:298
MachineCheck
Definition: MachineCheck.hh:50
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine
Definition: Assembler.hh:48
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::Machine
Definition: Machine.hh:73