aboutsummaryrefslogtreecommitdiffstats
path: root/backends/smt2/smtio.py
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2016-09-03 14:26:00 +0200
committerClifford Wolf <clifford@clifford.at>2016-09-03 14:26:00 +0200
commitfa5565b606bf58de1e1150c937afe014fcd928b6 (patch)
tree702758be0493b2928ef5f554d1c9af1909066c57 /backends/smt2/smtio.py
parentd2eba7631ff8bfb897db72f787ca365003176ca1 (diff)
downloadyosys-fa5565b606bf58de1e1150c937afe014fcd928b6.tar.gz
yosys-fa5565b606bf58de1e1150c937afe014fcd928b6.tar.bz2
yosys-fa5565b606bf58de1e1150c937afe014fcd928b6.zip
Added boolector support to yosys-smtbmc
Diffstat (limited to 'backends/smt2/smtio.py')
-rw-r--r--backends/smt2/smtio.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/backends/smt2/smtio.py b/backends/smt2/smtio.py
index dad63e567..9c4a0225e 100644
--- a/backends/smt2/smtio.py
+++ b/backends/smt2/smtio.py
@@ -17,8 +17,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
-import sys
-import subprocess
+import sys, subprocess, re
from select import select
from time import time
@@ -84,6 +83,10 @@ class SmtIo:
if self.solver == "mathsat":
popen_vargs = ['mathsat']
+ if self.solver == "boolector":
+ self.declared_sorts = list()
+ popen_vargs = ['boolector', '--smt2', '-i']
+
self.p = subprocess.Popen(popen_vargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.start_time = time()
@@ -104,11 +107,21 @@ class SmtIo:
def write(self, stmt):
stmt = stmt.strip()
+
+ if self.solver == "boolector":
+ if stmt.startswith("(declare-sort"):
+ self.declared_sorts.append(stmt.split()[1])
+ return
+ for n in self.declared_sorts:
+ stmt = stmt.replace(n, "(_ BitVec 16)")
+
if self.debug_print:
print("> %s" % stmt)
+
if self.debug_file:
print(stmt, file=self.debug_file)
self.debug_file.flush()
+
self.p.stdin.write(bytes(stmt + "\n", "ascii"))
self.p.stdin.flush()