OpenASIP
2.0
|
#include <MachineTester.hh>
Public Member Functions | |
MachineTester (const TTAMachine::Machine &machine) | |
virtual | ~MachineTester () |
virtual bool | canConnect (const TTAMachine::Socket &socket, const TTAMachine::Segment &segment) |
virtual bool | canConnect (const TTAMachine::Socket &socket, const TTAMachine::Port &port) |
virtual bool | canBridge (const TTAMachine::Bus &source, const TTAMachine::Bus &destination) |
virtual bool | canSetDirection (const TTAMachine::Socket &socket, TTAMachine::Socket::Direction direction) |
bool | connectionExists () const |
bool | illegalRegistration () const |
bool | loop () const |
TTAMachine::Bus * | branchedBus () const |
bool | wrongSocketDirection () const |
bool | maxConnections () const |
bool | unknownSocketDirection () const |
bool | noConnections () const |
TTAMachine::Port * | sameDirSocketConnection (TTAMachine::Socket::Direction direction) const |
TTAMachine::Port * | forbiddenSocketDirection (TTAMachine::Socket::Direction direction) const |
bool | registerFilePortAlreadyConnected () const |
Static Public Member Functions | |
static bool | isValidComponentName (const std::string &name) |
Private Member Functions | |
MachineTester (const MachineTester &tester) | |
MachineTester & | operator= (const MachineTester &tester) |
void | clearState () |
bool | legalPortConnections (const TTAMachine::Socket &socket, TTAMachine::Socket::Direction direction) |
Static Private Member Functions | |
static bool | areInSameChain (const TTAMachine::Bus &bus1, const TTAMachine::Bus &bus2) |
Private Attributes | |
const TTAMachine::Machine * | machine_ |
The machine on which the tests are carried out. More... | |
bool | connectionExists_ |
Indicates if the reason for the last test failure is that the tested connection already exists. More... | |
bool | rfPortAlreadyConnected_ |
Indicates if the reason for failure is that a port of register file is already connected to a particular socket. More... | |
bool | illegalRegistration_ |
Indicates if the reason for last test failure was illegal registration. More... | |
bool | loop_ |
Indicates if the reason for failure when trying to bridge two busses is that a loop in the bus chain would be created. More... | |
const TTAMachine::Bus * | branchedBus_ |
If the reason for failure when trying to bridge two busses is that a branch in the bus chain would be created, this is the branched bus. More... | |
bool | wrongSocketDirection_ |
Indicates if the reason for failure when trying to connect a socket to a port was that the direction of the socket is incompatible with the direction of other sockets connected to the port. More... | |
bool | maxConnections_ |
Indicates if the reason for failure when trying to connect a socket to a port was that this connection would exceed the maximum number of connections allowed for a port. More... | |
bool | unknownDir_ |
Indicates if tried to set the socket direction to Socket::UNKNOWN. More... | |
bool | noConnections_ |
Indicates if the reason for failure when tried to set socket direction was that the socket has no segment connections. More... | |
TTAMachine::Port * | sameDirInputSocketConn_ |
If the reason for failure when tried to set socket direction to input was that the socket is connected to a port that already has an input socket connected, this is the port. More... | |
TTAMachine::Port * | sameDirOutputSocketConn_ |
If the reason for failure when tried to set socket direction to output was that the socket is connected to a port that already has an output socket connected, this is the port. More... | |
TTAMachine::Port * | forbiddenInputSocketDir_ |
If the reason for failure when tried to set socket direction to input was the socket is connected to a unit that cannot be connected to an input socket, this is the port of the unit. More... | |
MachineTester is a class that implements all the API needed for diagnostics of machine model.
Definition at line 46 of file MachineTester.hh.
MachineTester::MachineTester | ( | const TTAMachine::Machine & | machine | ) |
Constructor.
machine | The machine on which the tests are done. |
Definition at line 57 of file MachineTester.cc.
References clearState().
|
virtual |
|
private |
|
staticprivate |
Checks if the given buses are in the same bus chain.
bus1 | The first bus. |
bus2 | The second bus. |
Definition at line 521 of file MachineTester.cc.
References TTAMachine::Bus::hasNextBus(), TTAMachine::Bus::hasPreviousBus(), TTAMachine::Bus::nextBus(), and TTAMachine::Bus::previousBus().
Referenced by canBridge().
Bus * MachineTester::branchedBus | ( | ) | const |
If the reason for failure when tried to join two buses by a bridge was a branched bus chain, returns the bus that was going to be branched. Otherwise returns NULL.
Definition at line 380 of file MachineTester.cc.
References branchedBus_.
Referenced by MachineTestReporter::bridgingError().
|
virtual |
Checks if the given source and destination buses can be joined by a new bridge.
If the test has negative outcome, the reason for it can be queried using the following functions: illegalRegistration, loop, connectionExists, branchedBus.
source | The source bus of the bridge. |
destination | The destination bus of the bridge. |
Reimplemented in DummyMachineTester.
Definition at line 203 of file MachineTester.cc.
References areInSameChain(), branchedBus_, TTAMachine::Bus::canWrite(), clearState(), connectionExists_, TTAMachine::Bus::hasNextBus(), TTAMachine::Bus::hasPreviousBus(), illegalRegistration_, loop_, TTAMachine::Component::machine(), machine_, TTAMachine::Bus::nextBus(), and TTAMachine::Bus::previousBus().
Referenced by TTAMachine::Bridge::Bridge(), AddBridgeCmd::Do(), TTAMachine::Bridge::loadState(), BridgeDialog::onInputBus(), BridgeDialog::onOK(), and BridgeDialog::updateBusChoices().
|
virtual |
Checks if the given socket can be connected to the given port.
If false is returned, the reason for the test failure can be queried using the following functions: illegalRegistration, connectionExists, wrongSocketDirection, maxConnections.
socket | The socket. |
port | The port. |
Reimplemented in DummyMachineTester.
Definition at line 127 of file MachineTester.cc.
References assert, clearState(), connectionExists_, TTAMachine::Socket::direction(), illegalRegistration_, TTAMachine::Port::inputSocket(), TTAMachine::Port::isConnectedTo(), TTAMachine::Component::machine(), machine_, maxConnections_, TTAMachine::Port::outputSocket(), TTAMachine::Port::parentUnit(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), rfPortAlreadyConnected_, TTAMachine::Port::socketCount(), TTAMachine::Port::unconnectedSocket(), and wrongSocketDirection_.
|
virtual |
Tests if the given socket can be connected to the given segment.
After calling this function, the reason for a test failure can be queried. Functions for querying the possible reasons are: connectionExists, illegalRegistration, sameDirSocketConnection, forbiddenSocketDirection.
Note that only the first reason encountered is recorded.
socket | The socket. |
segment | The segment. |
Reimplemented in DummyMachineTester.
Definition at line 86 of file MachineTester.cc.
References clearState(), connectionExists_, illegalRegistration_, TTAMachine::Socket::isConnectedTo(), legalPortConnections(), TTAMachine::Component::machine(), machine_, TTAMachine::Segment::parentBus(), and TTAMachine::Socket::segmentCount().
Referenced by TTAMachine::Socket::attachBus(), TTAMachine::Port::attachSocket(), TTAMachine::Segment::attachSocket(), FullyConnectedCheck::attachSocketToAllBusses(), ProDePortEditPolicy::canHandle(), ProDeSegmentEditPolicy::canHandle(), ProDeSocketEditPolicy::canHandle(), RemoveUnconnectedComponents::checkFUPorts(), RemoveUnconnectedComponents::checkRFPorts(), FullyConnectedCheck::connectFUPort(), FullyConnectedCheck::connectIUPort(), FullyConnectedCheck::connectRFPort(), FullyConnectedCheck::connectSpecialRegisterPort(), SocketDialog::onAttach(), FullyConnectedCheck::socketAttachedToAllBusses(), IUPortDialog::updateSocket(), SRPortDialog::updateSockets(), FUPortDialog::updateSockets(), and RFPortDialog::updateSockets().
|
virtual |
Checks if the direction of the given socket can be set to the given value.
Takes into account the ports that are directly connected to the given socket only. The reason for error can be queried for using the following functions: unknownSocketDirection, noConnections, sameDirSocketConnection, forbiddenSocketDirection.
socket | The socket. |
direction | The new direction of the socket. |
Reimplemented in DummyMachineTester.
Definition at line 283 of file MachineTester.cc.
References clearState(), TTAMachine::Socket::direction(), legalPortConnections(), noConnections_, TTAMachine::Socket::segmentCount(), UNKNOWN, and unknownDir_.
Referenced by TTAMachine::Socket::attachBus(), and TTAMachine::Socket::setDirection().
|
private |
Clears the state of the object.
Definition at line 497 of file MachineTester.cc.
References branchedBus_, connectionExists_, forbiddenInputSocketDir_, illegalRegistration_, loop_, maxConnections_, noConnections_, rfPortAlreadyConnected_, sameDirInputSocketConn_, sameDirOutputSocketConn_, unknownDir_, and wrongSocketDirection_.
Referenced by canBridge(), canConnect(), canSetDirection(), and MachineTester().
bool MachineTester::connectionExists | ( | ) | const |
Returns true if the reason for failure of the previous test was that a connection exists already between the components.
Definition at line 342 of file MachineTester.cc.
References connectionExists_.
Referenced by TTAMachine::Port::attachSocket(), MachineTestReporter::bridgingError(), MachineTestReporter::socketPortConnectionError(), and MachineTestReporter::socketSegmentConnectionError().
Port * MachineTester::forbiddenSocketDirection | ( | TTAMachine::Socket::Direction | direction | ) | const |
If the reason for failure when tried to set socket direction was that the socket was connected to a port of a unit that doesn't allow sockets of such direction to be connected, returns the port. Otherwise returns NULL.
direction | The direction that was tried to set. |
Definition at line 471 of file MachineTester.cc.
References forbiddenInputSocketDir_.
Referenced by MachineTestReporter::socketDirectionSettingError(), and MachineTestReporter::socketSegmentConnectionError().
bool MachineTester::illegalRegistration | ( | ) | const |
Returns true if the reason for failure of the previous test was illegal registration of components.
Definition at line 355 of file MachineTester.cc.
References illegalRegistration_.
Referenced by MachineTestReporter::bridgingError(), MachineTestReporter::socketPortConnectionError(), and MachineTestReporter::socketSegmentConnectionError().
|
static |
Checks whether the given string is a valid machine component name.
name | The name to check. |
Definition at line 312 of file MachineTester.cc.
Referenced by TTAMachine::ExecutionPipeline::checkResourceName(), TTAMachine::Component::Component(), TTAMachine::HWOperation::HWOperation(), TTAMachine::Segment::loadStateWithoutReferences(), TTAMachine::Port::loadStateWithoutReferences(), OperationDialog::onAddResource(), BusDialog::onAddSegment(), ImmediateSlotDialog::onAddSlot(), TemplateListDialog::onAddTemplate(), RFPortDialog::onOK(), IUPortDialog::onOK(), RFDialog::onOK(), SRPortDialog::onOK(), FUPortDialog::onOK(), SocketDialog::onOK(), FUDialog::onOK(), IUDialog::onOK(), BusDialog::onOK(), BridgeDialog::onOK(), AddressSpaceDialog::onOK(), OperationDialog::onOK(), GCUDialog::onOK(), TTAMachine::Port::Port(), TTAMachine::Segment::Segment(), TTAMachine::PipelineElement::setName(), TTAMachine::HWOperation::setName(), TTAMachine::Segment::setName(), TTAMachine::Port::setName(), and TTAMachine::Component::setName().
|
private |
Checks if the given socket will have legal connections to ports if its direction is changed to the given value.
socket | The socket to test. |
direction | The direction to test. |
Definition at line 556 of file MachineTester.cc.
References forbiddenInputSocketDir_, TTAMachine::Port::inputSocket(), TTAMachine::Port::outputSocket(), TTAMachine::Port::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), sameDirInputSocketConn_, and sameDirOutputSocketConn_.
Referenced by canConnect(), and canSetDirection().
bool MachineTester::loop | ( | ) | const |
If the reason for failure when tried to join two buses by a bridge was loop in bus chain, returns true. Otherwise returns false.
Definition at line 367 of file MachineTester.cc.
References loop_.
Referenced by MachineTestReporter::bridgingError().
bool MachineTester::maxConnections | ( | ) | const |
Checks if maximum number of connections in port was the reason for failure when tried to attach a port to a socket.
Definition at line 410 of file MachineTester.cc.
References maxConnections_.
Referenced by MachineTestReporter::socketPortConnectionError().
bool MachineTester::noConnections | ( | ) | const |
Returns true if the reason for failure when tried to set socket direction was that the socket has no connections to segments.
Definition at line 437 of file MachineTester.cc.
References noConnections_.
Referenced by MachineTestReporter::socketDirectionSettingError().
|
private |
bool MachineTester::registerFilePortAlreadyConnected | ( | ) | const |
Tells whether the reason for failure when tried to attach a port to a socket was that the parent unit of the port was register file and a port of the register file was already connected to the socket.
Definition at line 488 of file MachineTester.cc.
References rfPortAlreadyConnected_.
Referenced by MachineTestReporter::socketPortConnectionError().
Port * MachineTester::sameDirSocketConnection | ( | TTAMachine::Socket::Direction | direction | ) | const |
If the reason for failure when tried to set socket direction was that the socket was connected to a port that was connected to another socket that has the same direction, returns that port. Otherwise returns NULL.
direction | The direction that was tried to set. |
Definition at line 451 of file MachineTester.cc.
References sameDirInputSocketConn_, and sameDirOutputSocketConn_.
Referenced by MachineTestReporter::socketDirectionSettingError(), and MachineTestReporter::socketSegmentConnectionError().
bool MachineTester::unknownSocketDirection | ( | ) | const |
Returns true if the reason for failure when tried to set socket direction was unknown direction. The direction of socket can never be set to unknown.
Definition at line 424 of file MachineTester.cc.
References unknownDir_.
Referenced by MachineTestReporter::socketDirectionSettingError().
bool MachineTester::wrongSocketDirection | ( | ) | const |
Checks if wrong direction of socket was the reason for failure when tried to attach a port to a socket.
Definition at line 397 of file MachineTester.cc.
References wrongSocketDirection_.
Referenced by MachineTestReporter::socketPortConnectionError().
|
private |
If the reason for failure when trying to bridge two busses is that a branch in the bus chain would be created, this is the branched bus.
Definition at line 109 of file MachineTester.hh.
Referenced by branchedBus(), canBridge(), and clearState().
|
private |
Indicates if the reason for the last test failure is that the tested connection already exists.
Definition at line 97 of file MachineTester.hh.
Referenced by canBridge(), canConnect(), clearState(), and connectionExists().
|
private |
If the reason for failure when tried to set socket direction to input was the socket is connected to a unit that cannot be connected to an input socket, this is the port of the unit.
Definition at line 134 of file MachineTester.hh.
Referenced by clearState(), forbiddenSocketDirection(), and legalPortConnections().
|
private |
Indicates if the reason for last test failure was illegal registration.
Definition at line 103 of file MachineTester.hh.
Referenced by canBridge(), canConnect(), clearState(), and illegalRegistration().
|
private |
Indicates if the reason for failure when trying to bridge two busses is that a loop in the bus chain would be created.
Definition at line 106 of file MachineTester.hh.
Referenced by canBridge(), clearState(), and loop().
|
private |
The machine on which the tests are carried out.
Definition at line 94 of file MachineTester.hh.
Referenced by canBridge(), and canConnect().
|
private |
Indicates if the reason for failure when trying to connect a socket to a port was that this connection would exceed the maximum number of connections allowed for a port.
Definition at line 117 of file MachineTester.hh.
Referenced by canConnect(), clearState(), and maxConnections().
|
private |
Indicates if the reason for failure when tried to set socket direction was that the socket has no segment connections.
Definition at line 122 of file MachineTester.hh.
Referenced by canSetDirection(), clearState(), and noConnections().
|
private |
Indicates if the reason for failure is that a port of register file is already connected to a particular socket.
Definition at line 100 of file MachineTester.hh.
Referenced by canConnect(), clearState(), and registerFilePortAlreadyConnected().
|
private |
If the reason for failure when tried to set socket direction to input was that the socket is connected to a port that already has an input socket connected, this is the port.
Definition at line 126 of file MachineTester.hh.
Referenced by clearState(), legalPortConnections(), and sameDirSocketConnection().
|
private |
If the reason for failure when tried to set socket direction to output was that the socket is connected to a port that already has an output socket connected, this is the port.
Definition at line 130 of file MachineTester.hh.
Referenced by clearState(), legalPortConnections(), and sameDirSocketConnection().
|
private |
Indicates if tried to set the socket direction to Socket::UNKNOWN.
Definition at line 119 of file MachineTester.hh.
Referenced by canSetDirection(), clearState(), and unknownSocketDirection().
|
private |
Indicates if the reason for failure when trying to connect a socket to a port was that the direction of the socket is incompatible with the direction of other sockets connected to the port.
Definition at line 113 of file MachineTester.hh.
Referenced by canConnect(), clearState(), and wrongSocketDirection().