mirror of https://github.com/YosysHQ/yosys.git
Added "shared nodes" feature to the subcircuit library
This commit is contained in:
parent
3ebc365c09
commit
bc8d94b4ae
|
@ -266,7 +266,9 @@ After this code has been executed, the results vector contains all
|
||||||
non-overlapping matches of the three macrocells. The method
|
non-overlapping matches of the three macrocells. The method
|
||||||
clearOverlapHistory() can be used to reset the internal state used
|
clearOverlapHistory() can be used to reset the internal state used
|
||||||
for this feature. The default value for the third argument to solve()
|
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
|
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
|
a positive integer, this integer specifies the maximum number of solutions to
|
||||||
|
|
|
@ -100,7 +100,7 @@ bool SubCircuit::Graph::BitRef::operator < (const BitRef &other) const
|
||||||
return bitIdx < other.bitIdx;
|
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);
|
assert(nodeMap.count(nodeId) == 0);
|
||||||
nodeMap[nodeId] = nodes.size();
|
nodeMap[nodeId] = nodes.size();
|
||||||
|
@ -110,6 +110,7 @@ void SubCircuit::Graph::createNode(std::string nodeId, std::string typeId, void
|
||||||
newNode.nodeId = nodeId;
|
newNode.nodeId = nodeId;
|
||||||
newNode.typeId = typeId;
|
newNode.typeId = typeId;
|
||||||
newNode.userData = userData;
|
newNode.userData = userData;
|
||||||
|
newNode.shared = shared;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubCircuit::Graph::createPort(std::string nodeId, std::string portId, int width, int minWidth)
|
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++)
|
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) {
|
if (verbose) {
|
||||||
my_printf("\nSolution:\n");
|
my_printf("\nSolution:\n");
|
||||||
|
|
|
@ -63,7 +63,8 @@ namespace SubCircuit
|
||||||
std::map<std::string, int> portMap;
|
std::map<std::string, int> portMap;
|
||||||
std::vector<Port> ports;
|
std::vector<Port> ports;
|
||||||
void *userData;
|
void *userData;
|
||||||
Node() : userData(NULL) { };
|
bool shared;
|
||||||
|
Node() : userData(NULL), shared(false) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
bool allExtern;
|
bool allExtern;
|
||||||
|
@ -75,7 +76,7 @@ namespace SubCircuit
|
||||||
Graph() : allExtern(false) { };
|
Graph() : allExtern(false) { };
|
||||||
Graph(const Graph &other, const std::vector<std::string> &otherNodes);
|
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 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, 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);
|
void createConnection(std::string fromNodeId, std::string fromPortId, std::string toNodeId, std::string toPortId);
|
||||||
|
|
|
@ -52,10 +52,10 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constports) {
|
if (constports) {
|
||||||
graph.createNode("$const$0", "$const$0");
|
graph.createNode("$const$0", "$const$0", NULL, true);
|
||||||
graph.createNode("$const$1", "$const$1");
|
graph.createNode("$const$1", "$const$1", NULL, true);
|
||||||
graph.createNode("$const$x", "$const$x");
|
graph.createNode("$const$x", "$const$x", NULL, true);
|
||||||
graph.createNode("$const$z", "$const$z");
|
graph.createNode("$const$z", "$const$z", NULL, true);
|
||||||
graph.createPort("$const$0", "\\Y", 1);
|
graph.createPort("$const$0", "\\Y", 1);
|
||||||
graph.createPort("$const$1", "\\Y", 1);
|
graph.createPort("$const$1", "\\Y", 1);
|
||||||
graph.createPort("$const$x", "\\Y", 1);
|
graph.createPort("$const$x", "\\Y", 1);
|
||||||
|
|
Loading…
Reference in New Issue