OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
SocketBusConnCmd Class Reference

#include <SocketBusConnCmd.hh>

Inheritance diagram for SocketBusConnCmd:
Inheritance graph
Collaboration diagram for SocketBusConnCmd:
Collaboration graph

Public Member Functions

 SocketBusConnCmd (TTAMachine::Socket *socket, TTAMachine::Segment *segment)
 
virtual ~SocketBusConnCmd ()
 
virtual bool Do ()
 
- Public Member Functions inherited from ComponentCommand
 ComponentCommand ()
 
virtual ~ComponentCommand ()
 
wxWindow * parentWindow ()
 
void setParentWindow (wxWindow *window)
 

Private Attributes

TTAMachine::Socketsocket_
 Socket to connect. More...
 
TTAMachine::Segmentsegment_
 Bus segment to connect. More...
 

Detailed Description

Command for connecting/disconencting sockets to bus segments.

Definition at line 43 of file SocketBusConnCmd.hh.

Constructor & Destructor Documentation

◆ SocketBusConnCmd()

SocketBusConnCmd::SocketBusConnCmd ( TTAMachine::Socket socket,
TTAMachine::Segment segment 
)

The Constructor.

Parameters
segmentSegment to connect/disconnect.
socketSocket to connect/disconnect.

Definition at line 52 of file SocketBusConnCmd.cc.

52  :
54  socket_(socket), segment_(segment) {
55 }

◆ ~SocketBusConnCmd()

SocketBusConnCmd::~SocketBusConnCmd ( )
virtual

The Destructor.

Definition at line 61 of file SocketBusConnCmd.cc.

61  {
62 }

Member Function Documentation

◆ Do()

bool SocketBusConnCmd::Do ( )
virtual

Executes the command.

Returns
true, if the command was succesfully executed, false otherwise.

Implements ComponentCommand.

Definition at line 71 of file SocketBusConnCmd.cc.

71  {
72 
74  try {
76  } catch (Exception& e) {
77  return false;
78  }
79  } else {
80  try {
81  // If there was no direction before for this socket, let's
82  // try to figure out a better guess for it after connected
83  // to a port.
84  bool resetDirection =
87 
88  if (resetDirection && socket_->portCount() > 0) {
89  if (FUPort *port = dynamic_cast<FUPort*>(socket_->port(0))) {
91  dynamic_cast<FunctionUnit*>(port->parentUnit());
92  for (int i = 0; i < FUnit->operationCount(); ++i) {
93  HWOperation* hwOp = FUnit->operation(i);
94  if (!hwOp->isBound(*port)) continue;
95  int operandId = hwOp->io(*port);
96  OperationPool opPool;
97  Operation& osalOp = opPool.operation(hwOp->name().c_str());
98  if (osalOp.isNull()) break;
99  if (osalOp.operand(operandId).isInput())
100  socket_->setDirection(Socket::INPUT);
101  else
102  socket_->setDirection(Socket::OUTPUT);
103  break;
104  }
105  } else if (RFPort* port =
106  dynamic_cast<RFPort*>(socket_->port(0))) {
107  // RF ports have no other direction clue but the naming, which
108  // is often 'rd' or 'wr'. rd is for a port that is _used for_
109  // reading data (thus OUTPUT). This is probably a better guess
110  // than always assuming one or another.
111  if (port->name().size() > 0 && port->name()[0] == 'r')
112  socket_->setDirection(Socket::OUTPUT);
113  else
114  socket_->setDirection(Socket::INPUT);
115  }
116  }
117  // HERE.
118  } catch (Exception& e) {
119  return false;
120  }
121  }
122 
123  return true;
124 }

References TTAMachine::Socket::attachBus(), TTAMachine::Socket::detachBus(), TTAMachine::Socket::direction(), TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), TTAMachine::Socket::isConnectedTo(), Operand::isInput(), Operation::isNull(), TTAMachine::HWOperation::name(), Operation::operand(), OperationPool::operation(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), segment_, TTAMachine::Socket::setDirection(), socket_, and UNKNOWN.

Here is the call graph for this function:

Member Data Documentation

◆ segment_

TTAMachine::Segment* SocketBusConnCmd::segment_
private

Bus segment to connect.

Definition at line 55 of file SocketBusConnCmd.hh.

Referenced by Do().

◆ socket_

TTAMachine::Socket* SocketBusConnCmd::socket_
private

Socket to connect.

Definition at line 53 of file SocketBusConnCmd.hh.

Referenced by Do().


The documentation for this class was generated from the following files:
OperationPool::operation
Operation & operation(const char *name)
Definition: OperationPool.cc:99
TTAMachine::Socket::port
Port * port(int index) const
Definition: Socket.cc:266
TTAMachine::Socket::portCount
int portCount() const
TTAMachine::HWOperation
Definition: HWOperation.hh:52
ComponentCommand::ComponentCommand
ComponentCommand()
Definition: ComponentCommand.cc:38
TTAMachine::Socket::direction
Direction direction() const
TTAMachine::RFPort
Definition: RFPort.hh:45
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAMachine::HWOperation::io
int io(const FUPort &port) const
Definition: HWOperation.cc:364
TTAMachine::Socket::attachBus
void attachBus(Segment &bus)
Definition: Socket.cc:166
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
TTAMachine::HWOperation::isBound
bool isBound(const FUPort &port) const
Definition: HWOperation.cc:338
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
Exception
Definition: Exception.hh:54
SocketBusConnCmd::socket_
TTAMachine::Socket * socket_
Socket to connect.
Definition: SocketBusConnCmd.hh:53
TTAMachine::Socket::setDirection
void setDirection(Direction direction)
Definition: Socket.cc:130
TTAMachine::Socket::isConnectedTo
bool isConnectedTo(const Bus &bus) const
Definition: Socket.cc:331
Operation
Definition: Operation.hh:59
TTAMachine::Socket::detachBus
void detachBus(Segment &bus)
Definition: Socket.cc:213
Operation::operand
virtual Operand & operand(int id) const
Definition: Operation.cc:541
SocketBusConnCmd::segment_
TTAMachine::Segment * segment_
Bus segment to connect.
Definition: SocketBusConnCmd.hh:55
Operation::isNull
bool isNull() const
UNKNOWN
@ UNKNOWN
Definition: MemoryGenerator.hh:58
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
OperationPool
Definition: OperationPool.hh:52
Operand::isInput
virtual bool isInput() const
Definition: Operand.cc:145