OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
OperationBindingCheck Class Reference

#include <OperationBindingCheck.hh>

Inheritance diagram for OperationBindingCheck:
Inheritance graph
Collaboration diagram for OperationBindingCheck:
Collaboration graph

Public Member Functions

 OperationBindingCheck ()
 
virtual bool check (const TTAMachine::Machine &mach, MachineCheckResults &results) const
 
- Public Member Functions inherited from MachineCheck
virtual std::string shortDescription () const
 
virtual std::string description () const
 
virtual bool canFix (const TTAMachine::Machine &mach) const
 
virtual std::string fix (TTAMachine::Machine &mach) const
 
virtual ~MachineCheck ()
 

Additional Inherited Members

- Protected Member Functions inherited from MachineCheck
 MachineCheck (const std::string &shortDesc_)
 

Detailed Description

Check that tests port bindings in machine

Definition at line 42 of file OperationBindingCheck.hh.

Constructor & Destructor Documentation

◆ OperationBindingCheck()

OperationBindingCheck::OperationBindingCheck ( )

Definition at line 45 of file OperationBindingCheck.cc.

45 :
46 MachineCheck("Check operation binding, port directions, triggers") {}

Member Function Documentation

◆ check()

bool OperationBindingCheck::check ( const TTAMachine::Machine mach,
MachineCheckResults results 
) const
virtual

Checks that machine's FU's have legal port and trigger bindings

Parameters
machmachine to check
resultsplace where to put detailed error descriptions
Returns
true if everything is ok, false if something is wrong

Implements MachineCheck.

Definition at line 55 of file OperationBindingCheck.cc.

56 {
57
60
61 bool retval = true;
62 bool triggerok = true;
63 for (int i = 0; i < fuNav.count(); i++) {
64 FunctionUnit& fu = *fuNav.item(i);
65
66 // find trigger port
67 FUPort* triggerPort = NULL;
68 for (int j = 0; j < fu.operationPortCount(); j++) {
69 FUPort* port = fu.operationPort(j);
70 if (port->isTriggering()) {
71
72 // check that we do not have multiple trigger ports.
73 if ( triggerPort != NULL) {
74 results.addError(
75 *this, (boost::format("Multiple trigger ports are "
76 "not supported, Used in FU: %s")
77 % fu.name()).str());
78 retval = false;
79 triggerok = false;
80 }
81 else {
82 // check trigger and fu ports are the same
83 triggerPort = port;
84 if (!port->isOpcodeSetting()) {
85 results.addError(
86 *this, (boost::format("Opcode setting and trigger "
87 "port differ in FU: ")
88 % fu.name()).str());
89 retval = false;
90 triggerok = false;
91 }
92 }
93 }
94 }
95 // check that we have a trigger port
96 if ( triggerPort == NULL) {
97 results.addError(
98 *this, (boost::format("Trigger port not found in FU: %s")
99 % fu.name()).str());
100 return false;
101 }
102
103 // check all operations
104 for (int j = 0; j < fu.operationCount(); j++) {
105
106 HWOperation& hwop = *fu.operation(j);
107 bool triggerRead = false;
108
109 // check read port bindins
110 ExecutionPipeline& pipe = *hwop.pipeline();
111 const ExecutionPipeline::OperandSet reads = pipe.readOperands();
112 for (ExecutionPipeline::OperandSet::const_iterator iter =
113 reads.begin(); iter != reads.end(); iter++) {
114 Port* readPort = hwop.port(*iter);
115 if ( readPort->inputSocket() == NULL) {
116 std::string errorMsg =
117 (boost::format(
118 "Operation %s in FU %s reads operand %d which "
119 "is not connected to input socket. "
120 "Check port bindings!")
121 % hwop.name() % fu.name() % *iter).str();
122
123 results.addError(*this, (errorMsg));
124 retval = false;
125 } else {
126 // check if this was read from the trigger
127 if (readPort == triggerPort) {
128 triggerRead = true;
129 }
130 }
131 }
132
133 // was trigger actually read?
134 if ( triggerok && !triggerRead) {
135 std::string errorMsg =
136 (boost::format(
137 "Trigger not bound for operation: %s in FU %s") %
138 hwop.name() % fu.name()).str();
139 results.addError(*this, errorMsg);
140 retval = false;
141 }
142
143 // check write port bidings
144 const ExecutionPipeline::OperandSet writes =
145 pipe.writtenOperands();
146 for (ExecutionPipeline::OperandSet::const_iterator iter =
147 writes.begin(); iter != writes.end(); iter++) {
148 Port* writePort = hwop.port(*iter);
149 if ( writePort->outputSocket() == NULL) {
150 results.addError(
151 *this, (boost::format("Operation %s in FU %s "
152 "writes operand %d"
153 "which is not connected to "
154 "output socket. "
155 "Check port bindings!")
156 % hwop.name() % fu.name() % *iter).str());
157 retval = false;
158 }
159 }
160 }
161 }
162 return retval;
163}
void addError(const MachineCheck &check, const std::string &errorMsg)
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 bool isOpcodeSetting() const
Definition FUPort.cc:195
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual FUPort * operationPort(const std::string &name) const
virtual int operationPortCount() const
ExecutionPipeline * pipeline() const
virtual FUPort * port(int operand) const
const std::string & name() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual Socket * outputSocket() const
Definition Port.cc:281
virtual Socket * inputSocket() const
Definition Port.cc:261

References MachineCheckResults::addError(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Port::inputSocket(), TTAMachine::FUPort::isOpcodeSetting(), TTAMachine::FUPort::isTriggering(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), TTAMachine::Port::outputSocket(), TTAMachine::HWOperation::pipeline(), TTAMachine::HWOperation::port(), TTAMachine::ExecutionPipeline::readOperands(), and TTAMachine::ExecutionPipeline::writtenOperands().

Here is the call graph for this function:

The documentation for this class was generated from the following files: