mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-22 16:45:32 +00:00
Improved sat generator and sat_solve pass
This commit is contained in:
parent
46fbe9d262
commit
56b593b91c
6 changed files with 57 additions and 15 deletions
|
@ -34,6 +34,7 @@ ezSAT::ezSAT()
|
|||
|
||||
cnfConsumed = false;
|
||||
cnfVariableCount = 0;
|
||||
cnfClausesCount = 0;
|
||||
}
|
||||
|
||||
ezSAT::~ezSAT()
|
||||
|
@ -331,6 +332,7 @@ void ezSAT::clear()
|
|||
{
|
||||
cnfConsumed = false;
|
||||
cnfVariableCount = 0;
|
||||
cnfClausesCount = 0;
|
||||
cnfLiteralVariables.clear();
|
||||
cnfExpressionVariables.clear();
|
||||
cnfClauses.clear();
|
||||
|
@ -342,11 +344,13 @@ void ezSAT::assume(int id)
|
|||
int idx = bind(id);
|
||||
cnfClauses.push_back(std::vector<int>(1, idx));
|
||||
cnfAssumptions.insert(id);
|
||||
cnfClausesCount++;
|
||||
}
|
||||
|
||||
void ezSAT::add_clause(const std::vector<int> &args)
|
||||
{
|
||||
cnfClauses.push_back(args);
|
||||
cnfClausesCount++;
|
||||
}
|
||||
|
||||
void ezSAT::add_clause(const std::vector<int> &args, bool argsPolarity, int a, int b, int c)
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
std::vector<std::pair<OpId, std::vector<int>>> expressions;
|
||||
|
||||
bool cnfConsumed;
|
||||
int cnfVariableCount;
|
||||
int cnfVariableCount, cnfClausesCount;
|
||||
std::vector<int> cnfLiteralVariables, cnfExpressionVariables;
|
||||
std::vector<std::vector<int>> cnfClauses;
|
||||
std::set<int> cnfAssumptions;
|
||||
|
@ -137,6 +137,7 @@ public:
|
|||
int bound(int id) const;
|
||||
|
||||
int numCnfVariables() const { return cnfVariableCount; }
|
||||
int numCnfClauses() const { return cnfClausesCount; }
|
||||
const std::vector<std::vector<int>> &cnf() const { return cnfClauses; }
|
||||
|
||||
void consumeCnf();
|
||||
|
|
|
@ -255,7 +255,7 @@ int main()
|
|||
ez.assume(ez.ordered(vecvec[0], vecvec[1]));
|
||||
|
||||
printf("Found and eliminated %d spatial symmetries.\n", int(symmetries.size()));
|
||||
printf("Generated %d clauses over %d variables.\n", ez.numCnfVariables(), int(ez.cnf().size()));
|
||||
printf("Generated %d clauses over %d variables.\n", ez.numCnfClauses(), ez.numCnfVariables());
|
||||
|
||||
std::vector<int> modelExpressions;
|
||||
std::vector<bool> modelValues;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue