3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-22 04:12:06 +00:00

Replaced ezDefaultSAT with ezSatPtr

This commit is contained in:
Clifford Wolf 2015-02-21 12:15:41 +01:00
parent f778a4081c
commit 4e6ca7760f
12 changed files with 186 additions and 139 deletions

View file

@ -18,6 +18,8 @@
*/
#include "kernel/yosys.h"
#include "kernel/satgen.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@ -691,6 +693,18 @@ struct EchoPass : public Pass {
log("echo %s\n", echo_mode ? "on" : "off");
}
} EchoPass;
SatSolver *yosys_satsolver_list;
SatSolver *yosys_satsolver;
struct MinisatSatSolver : public SatSolver {
MinisatSatSolver() : SatSolver("minisat") {
yosys_satsolver = this;
}
virtual ezSAT *create() YS_OVERRIDE {
return new ezMiniSAT();
}
} MinisatSatSolver;
YOSYS_NAMESPACE_END

View file

@ -29,7 +29,37 @@
YOSYS_NAMESPACE_BEGIN
typedef ezMiniSAT ezDefaultSAT;
// defined in kernel/register.cc
extern struct SatSolver *yosys_satsolver_list;
extern struct SatSolver *yosys_satsolver;
struct SatSolver
{
string name;
SatSolver *next;
virtual ezSAT *create() = 0;
SatSolver(string name) : name(name) {
next = yosys_satsolver_list;
yosys_satsolver_list = this;
}
virtual ~SatSolver() {
auto p = &yosys_satsolver_list;
while (*p) {
if (*p == this)
*p = next;
else
p = &(*p)->next;
}
if (yosys_satsolver == this)
yosys_satsolver = yosys_satsolver_list;
}
};
struct ezSatPtr : public std::unique_ptr<ezSAT> {
ezSatPtr() : unique_ptr<ezSAT>(yosys_satsolver->create()) { }
};
struct SatGen
{

View file

@ -49,6 +49,7 @@
#include <unordered_set>
#include <initializer_list>
#include <stdexcept>
#include <memory>
#include <sstream>
#include <fstream>