Commit f11a7a3f authored by Daniel Krebs's avatar Daniel Krebs
Browse files

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

parent 28891cd2
...@@ -86,11 +86,6 @@ public: ...@@ -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 { class IpNode : public IpCore {
public: public:
...@@ -102,7 +97,6 @@ public: ...@@ -102,7 +97,6 @@ public:
}; };
bool connect(const StreamVertex& from, const StreamVertex& to); bool connect(const StreamVertex& from, const StreamVertex& to);
bool disconnect(std::string portName);
const StreamVertex& const StreamVertex&
getMasterPort(const std::string& name) const getMasterPort(const std::string& name) const
...@@ -112,6 +106,20 @@ public: ...@@ -112,6 +106,20 @@ public:
getSlavePort(const std::string& name) const getSlavePort(const std::string& name) const
{ return *portsSlave.at(name); } { 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 loopbackPossible() const;
bool connectLoopback(); bool connectLoopback();
...@@ -126,6 +134,8 @@ private: ...@@ -126,6 +134,8 @@ private:
protected: protected:
std::map<std::string, std::shared_ptr<StreamVertex>> portsMaster; std::map<std::string, std::shared_ptr<StreamVertex>> portsMaster;
std::map<std::string, std::shared_ptr<StreamVertex>> portsSlave; std::map<std::string, std::shared_ptr<StreamVertex>> portsSlave;
static StreamGraph streamGraph;
}; };
class IpNodeFactory : public IpCoreFactory { class IpNodeFactory : public IpCoreFactory {
......
...@@ -60,6 +60,14 @@ public: ...@@ -60,6 +60,14 @@ public:
hasScatterGather() const hasScatterGather() const
{ return hasSG; } { return hasSG; }
const StreamVertex&
getDefaultSlavePort() const
{ return getSlavePort(s2mmPort); }
const StreamVertex&
getDefaultMasterPort() const
{ return getMasterPort(mm2sPort); }
private: private:
bool writeSG(const void* buf, size_t len); bool writeSG(const void* buf, size_t len);
bool readSG(void* buf, size_t len); bool readSG(void* buf, size_t len);
......
...@@ -13,7 +13,8 @@ namespace fpga { ...@@ -13,7 +13,8 @@ namespace fpga {
namespace ip { namespace ip {
StreamGraph streamGraph; StreamGraph
IpNode::streamGraph;
bool bool
IpNodeFactory::configureJson(IpCore& ip, json_t* json_ip) IpNodeFactory::configureJson(IpCore& ip, json_t* json_ip)
...@@ -55,20 +56,20 @@ 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"); const bool isMaster = (role == "master" or role == "initiator");
auto thisVertex = streamGraph.getOrCreateStreamVertex( auto thisVertex = IpNode::streamGraph.getOrCreateStreamVertex(
ip.getInstanceName(), ip.getInstanceName(),
name_raw, name_raw,
isMaster); isMaster);
auto connectedVertex = streamGraph.getOrCreateStreamVertex( auto connectedVertex = IpNode::streamGraph.getOrCreateStreamVertex(
tokens[0], tokens[0],
tokens[1], tokens[1],
not isMaster); not isMaster);
if(isMaster) { if(isMaster) {
streamGraph.addDefaultEdge(thisVertex->getIdentifier(), IpNode::streamGraph.addDefaultEdge(thisVertex->getIdentifier(),
connectedVertex->getIdentifier()); connectedVertex->getIdentifier());
ipNode.portsMaster[name_raw] = thisVertex; ipNode.portsMaster[name_raw] = thisVertex;
} else /* slave */ { } else /* slave */ {
ipNode.portsSlave[name_raw] = thisVertex; ipNode.portsSlave[name_raw] = thisVertex;
...@@ -143,6 +144,20 @@ bool IpNode::connect(const StreamVertex& from, const StreamVertex& to) ...@@ -143,6 +144,20 @@ bool IpNode::connect(const StreamVertex& from, const StreamVertex& to)
return nextHopNodeIp->connect(*nextHopNode, 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 bool
IpNode::loopbackPossible() const IpNode::loopbackPossible() const
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment