aboutsummaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-03-03 21:19:55 +0100
committerClifford Wolf <clifford@clifford.at>2013-03-03 21:19:55 +0100
commitbc8d94b4aeb43fd7cc6b77725bb379650a0575a3 (patch)
treeec34178961e33e8b4729eec62de0e9b5141ab212 /libs
parent3ebc365c096ee062516bdbfd903fea14e4aa6185 (diff)
downloadyosys-bc8d94b4aeb43fd7cc6b77725bb379650a0575a3.tar.gz
yosys-bc8d94b4aeb43fd7cc6b77725bb379650a0575a3.tar.bz2
yosys-bc8d94b4aeb43fd7cc6b77725bb379650a0575a3.zip
Added "shared nodes" feature to the subcircuit library
Diffstat (limited to 'libs')
-rw-r--r--libs/subcircuit/README4
-rw-r--r--libs/subcircuit/subcircuit.cc6
-rw-r--r--libs/subcircuit/subcircuit.h5
3 files changed, 10 insertions, 5 deletions
diff --git a/libs/subcircuit/README b/libs/subcircuit/README
index f304d2a53..757a9f540 100644
--- a/libs/subcircuit/README
+++ b/libs/subcircuit/README
@@ -266,7 +266,9 @@ After this code has been executed, the results vector contains all
non-overlapping matches of the three macrocells. The method
clearOverlapHistory() can be used to reset the internal state used
for this feature. The default value for the third argument to solve()
-is true (allow overlapping).
+is true (allow overlapping). The optional boolean fourth argument to the
+Graph::createNode() method can be used to mark a node as shareable even
+in non-overlapping solver mode.
The solve() method also has a fourth optional integer argument. If it is set to
a positive integer, this integer specifies the maximum number of solutions to
diff --git a/libs/subcircuit/subcircuit.cc b/libs/subcircuit/subcircuit.cc
index 73152c3b8..f05aeaa28 100644
--- a/libs/subcircuit/subcircuit.cc
+++ b/libs/subcircuit/subcircuit.cc
@@ -100,7 +100,7 @@ bool SubCircuit::Graph::BitRef::operator < (const BitRef &other) const
return bitIdx < other.bitIdx;
}
-void SubCircuit::Graph::createNode(std::string nodeId, std::string typeId, void *userData)
+void SubCircuit::Graph::createNode(std::string nodeId, std::string typeId, void *userData, bool shared)
{
assert(nodeMap.count(nodeId) == 0);
nodeMap[nodeId] = nodes.size();
@@ -110,6 +110,7 @@ void SubCircuit::Graph::createNode(std::string nodeId, std::string typeId, void
newNode.nodeId = nodeId;
newNode.typeId = typeId;
newNode.userData = userData;
+ newNode.shared = shared;
}
void SubCircuit::Graph::createPort(std::string nodeId, std::string portId, int width, int minWidth)
@@ -1074,7 +1075,8 @@ class SubCircuit::SolverWorker
}
for (int j = 0; j < int(enumerationMatrix.size()); j++)
- haystack.usedNodes[*enumerationMatrix[j].begin()] = true;
+ if (!haystack.graph.nodes[*enumerationMatrix[j].begin()].shared)
+ haystack.usedNodes[*enumerationMatrix[j].begin()] = true;
if (verbose) {
my_printf("\nSolution:\n");
diff --git a/libs/subcircuit/subcircuit.h b/libs/subcircuit/subcircuit.h
index b9399a99d..80eafbc36 100644
--- a/libs/subcircuit/subcircuit.h
+++ b/libs/subcircuit/subcircuit.h
@@ -63,7 +63,8 @@ namespace SubCircuit
std::map<std::string, int> portMap;
std::vector<Port> ports;
void *userData;
- Node() : userData(NULL) { };
+ bool shared;
+ Node() : userData(NULL), shared(false) { };
};
bool allExtern;
@@ -75,7 +76,7 @@ namespace SubCircuit
Graph() : allExtern(false) { };
Graph(const Graph &other, const std::vector<std::string> &otherNodes);
- void createNode(std::string nodeId, std::string typeId, void *userData = NULL);
+ void createNode(std::string nodeId, std::string typeId, void *userData = NULL, bool shared = false);
void createPort(std::string nodeId, std::string portId, int width = 1, int minWidth = -1);
void createConnection(std::string fromNodeId, std::string fromPortId, int fromBit, std::string toNodeId, std::string toPortId, int toBit, int width = 1);
void createConnection(std::string fromNodeId, std::string fromPortId, std::string toNodeId, std::string toPortId);