1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

ip-node: move stream graph to IpNode and add easy-to-use connect interface

This commit is contained in:
Daniel Krebs 2018-06-04 17:28:40 +02:00
parent 00fb0363dd
commit 47bd186f5e
3 changed files with 44 additions and 11 deletions

View file

@ -86,11 +86,6 @@ public:
};
extern StreamGraph streamGraph;
// TODO: reflect on interface that an IpNode exposes and how to design it to
// blend in with VILLASnode software nodes
class IpNode : public IpCore {
public:
@ -102,7 +97,6 @@ public:
};
bool connect(const StreamVertex& from, const StreamVertex& to);
bool disconnect(std::string portName);
const StreamVertex&
getMasterPort(const std::string& name) const
@ -112,6 +106,20 @@ public:
getSlavePort(const std::string& name) const
{ return *portsSlave.at(name); }
// easy-usage assuming that the slave IP to connect to only has one slave
// port and implements the getDefaultSlavePort() function
bool connect(const IpNode& slaveNode)
{ return this->connect(this->getDefaultMasterPort(), slaveNode.getDefaultSlavePort()); }
// used by easy-usage connect, will throw if not implemented by derived node
virtual const StreamVertex&
getDefaultSlavePort() const;
// used by easy-usage connect, will throw if not implemented by derived node
virtual const StreamVertex&
getDefaultMasterPort() const;
bool loopbackPossible() const;
bool connectLoopback();
@ -126,6 +134,8 @@ private:
protected:
std::map<std::string, std::shared_ptr<StreamVertex>> portsMaster;
std::map<std::string, std::shared_ptr<StreamVertex>> portsSlave;
static StreamGraph streamGraph;
};
class IpNodeFactory : public IpCoreFactory {

View file

@ -60,6 +60,14 @@ public:
hasScatterGather() const
{ return hasSG; }
const StreamVertex&
getDefaultSlavePort() const
{ return getSlavePort(s2mmPort); }
const StreamVertex&
getDefaultMasterPort() const
{ return getMasterPort(mm2sPort); }
private:
bool writeSG(const void* buf, size_t len);
bool readSG(void* buf, size_t len);

View file

@ -13,7 +13,8 @@ namespace fpga {
namespace ip {
StreamGraph streamGraph;
StreamGraph
IpNode::streamGraph;
bool
IpNodeFactory::configureJson(IpCore& ip, json_t* json_ip)
@ -55,20 +56,20 @@ IpNodeFactory::configureJson(IpCore& ip, json_t* json_ip)
const bool isMaster = (role == "master" or role == "initiator");
auto thisVertex = streamGraph.getOrCreateStreamVertex(
auto thisVertex = IpNode::streamGraph.getOrCreateStreamVertex(
ip.getInstanceName(),
name_raw,
isMaster);
auto connectedVertex = streamGraph.getOrCreateStreamVertex(
auto connectedVertex = IpNode::streamGraph.getOrCreateStreamVertex(
tokens[0],
tokens[1],
not isMaster);
if(isMaster) {
streamGraph.addDefaultEdge(thisVertex->getIdentifier(),
connectedVertex->getIdentifier());
IpNode::streamGraph.addDefaultEdge(thisVertex->getIdentifier(),
connectedVertex->getIdentifier());
ipNode.portsMaster[name_raw] = thisVertex;
} else /* slave */ {
ipNode.portsSlave[name_raw] = thisVertex;
@ -143,6 +144,20 @@ bool IpNode::connect(const StreamVertex& from, const StreamVertex& to)
return nextHopNodeIp->connect(*nextHopNode, to);
}
const StreamVertex&
IpNode::getDefaultSlavePort() const
{
logger->error("No default slave port available");
throw std::exception();
}
const StreamVertex&
IpNode::getDefaultMasterPort() const
{
logger->error("No default master port available");
throw std::exception();
}
bool
IpNode::loopbackPossible() const
{