Skip to content

Commit e891d9b

Browse files
committed
Stashing temp changes
1 parent 833b13a commit e891d9b

24 files changed

+247
-200
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
.idea/
77

88
build/bin*/dpa
9-
build/bin*/reach
9+
build/bin*/reach*
1010
build/bin*/vwn
1111

12+
hwmcc*/
1213
deps/*
1314
output/*
15+
xtras/*/
1416

1517
*.a
1618
*.o

build/avr renamed to avr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enKind="${32}"
3535
bmcKmax="${33}"
3636
createAig="${34}"
3737
parseOnly="${35}"
38+
backendSuffix="${36}"
3839

3940
BM_PATH="$p_dir"
4041
OUT_DIR="$p_out"
@@ -293,7 +294,7 @@ then
293294
exit $avr_exit
294295
fi
295296

296-
$p_bin/reach $OUT_PATH $p_bin > $OUT_PATH/data/reach.output 2>> >(tee -a $OUT_PATH/avr.err >&2) & echo $! > $pidFile
297+
$p_bin/reach_${backendSuffix} $OUT_PATH $p_bin > $OUT_PATH/data/reach.output 2>> >(tee -a $OUT_PATH/avr.err >&2) & echo $! > $pidFile
297298
wait
298299
avr_exit=$?
299300

avr.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@
2323

2424
DEFAULT_TOP="-"
2525
DEFAULT_BIN="build/bin"
26+
DEFAULT_BACKEND="y2"
2627
DEFAULT_NAME="test"
2728
DEFAULT_PROP_SELECT="-"
2829
DEFAULT_INIT_FILE="-"
2930
DEFAULT_OUT="output"
3031
DEFAULT_YOSYS="deps/yosys"
3132
DEFAULT_CLK="clk"
32-
DEFAULT_TIMEOUT=3600
33-
DEFAULT_MEMOUT=64000
33+
DEFAULT_TIMEOUT=3590
34+
DEFAULT_MEMOUT=118000
3435
DEFAULT_MEMORY=False
35-
DEFAULT_SPLIT=True
36+
DEFAULT_SPLIT=False
3637
DEFAULT_GRANULARITY=2
3738
DEFAULT_RANDOM=False
3839
DEFAULT_EFFORT_MININV=0
@@ -64,6 +65,7 @@ def getopts(header):
6465
p.add_argument('-n', '--name', help='<test-name> (default: %s)' % DEFAULT_NAME, type=str, default=DEFAULT_NAME)
6566
p.add_argument('-o', '--out', help='<output-path> (default: %s)' % DEFAULT_OUT, type=str, default=DEFAULT_OUT)
6667
p.add_argument('-b', '--bin', help='binary path (default: %s)' % DEFAULT_BIN, type=str, default=DEFAULT_BIN)
68+
p.add_argument('--backend', help='backend to use: y2, bt, m5 (default: %s)' % DEFAULT_BACKEND, type=str, default=DEFAULT_BACKEND)
6769
p.add_argument('-y', '--yosys', help='path to yosys installation (default: %s)' % DEFAULT_YOSYS, type=str, default=DEFAULT_YOSYS)
6870
p.add_argument('--vmt', help='toggles using vmt frontend (default: %s)' % DEFAULT_EN_VMT, action="count", default=0)
6971
p.add_argument('-j', '--jg', help='toggles using jg frontend (default: %s)' % DEFAULT_EN_JG, action="count", default=0)
@@ -123,14 +125,14 @@ def split_path(name):
123125
def main():
124126
known, opts = getopts(header)
125127
print(short_header)
126-
if not os.path.isfile("build/avr"):
128+
if not os.path.isfile("avr"):
127129
raise Exception("avr: main shell script not found")
128130
if not os.path.isfile(opts.bin + "/vwn"):
129-
raise Exception("avr: vwn binary not found")
131+
raise Exception(f"avr: vwn binary not found in {opts.bin}")
130132
if not os.path.isfile(opts.bin + "/dpa"):
131-
raise Exception("avr: dpa binary not found")
132-
if not os.path.isfile(opts.bin + "/reach"):
133-
raise Exception("avr: reach binary not found")
133+
raise Exception(f"avr: dpa binary not found in {opts.bin}")
134+
if not os.path.isfile(opts.bin + "/reach_" + opts.backend):
135+
raise Exception(f"avr: reach binary not found in {opts.bin}")
134136
if not os.path.exists(opts.out):
135137
os.makedirs(opts.out)
136138

@@ -161,6 +163,8 @@ def main():
161163
en_bt = not DEFAULT_EN_BTOR2
162164

163165
print("\t(output dir: %s/work_%s)" % (opts.out, opts.name))
166+
print("\t(backend: %s)" % opts.backend)
167+
164168
if (en_jg):
165169
print("\t(frontend: jg)")
166170
en_vmt = False
@@ -185,7 +189,7 @@ def main():
185189
opts.yosys = ys_path
186190
print("\t(found yosys in %s)" % opts.yosys)
187191

188-
command = "./build/avr"
192+
command = "./avr"
189193
command = command + " " + f
190194
command = command + " " + str(opts.top)
191195
command = command + " " + path
@@ -266,7 +270,9 @@ def main():
266270
if (opts.parse % 2 == 1):
267271
parse_only = not DEFAULT_PARSE_ONLY
268272
command = command + " " + str(parse_only)
269-
273+
274+
command = command + " " + str(opts.backend)
275+
270276
s = subprocess.call("exec " + command, shell=True)
271277
if (s != 0):
272278
raise Exception("avr ERROR: return code %d" % s)

avr_pr.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
start_time = time.time()
1717

1818
cmdSuffix = ""
19-
maxWorkers = 8
19+
maxWorkers = 16
2020

2121
optSuffix = " "
2222
commands = []
@@ -30,14 +30,14 @@
3030
DEFAULT_NAME="test"
3131
DEFAULT_WORKERS="workers.txt"
3232
#DEFAULT_BIN="bin"
33-
DEFAULT_TIMEOUT=3600
34-
DEFAULT_MEMOUT=16000
33+
DEFAULT_TIMEOUT=3590
34+
DEFAULT_MEMOUT=118000
3535
DEFAULT_PRINT_SMT2=False
36-
DEFAULT_PRINT_WITNESS=True
36+
DEFAULT_PRINT_WITNESS=False
3737

3838
maxTimeSec = DEFAULT_TIMEOUT
3939
maxMemMB = DEFAULT_MEMOUT
40-
maxInitW = 2
40+
maxInitW = 12
4141
resultW = 0
4242
out_path = DEFAULT_OUT + "/" + DEFAULT_NAME
4343

deps/build_deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash -x
22
set -e
33

4-
MATHSATVERSION="5.6.10"
4+
MATHSATVERSION="5.6.11"
55

66
echo "Installing dependencies..."
77

src/Makefile

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
1+
#ENABLE_Y2 := 0
2+
#ENABLE_M5 := 0
3+
#ENABLE_BT := 0
4+
#ENABLE_Z3 := 0
5+
16
REA_LOC = reach
27
DPA_LOC = dpa
38
VWN_LOC = vwn
49

510
all:
6-
$(MAKE) da
7-
$(MAKE) re
811
$(MAKE) vw
12+
$(MAKE) da
13+
ENABLE_Y2=1 $(MAKE) re
14+
ENABLE_BT=1 $(MAKE) re
15+
# ENABLE_M5=1 $(MAKE) re
916

1017
clean:
18+
$(MAKE) vwc
1119
$(MAKE) dac
1220
$(MAKE) rec
13-
$(MAKE) vwc
1421
@echo Cleaning Complete
1522

16-
re:
17-
@cd $(REA_LOC); $(MAKE)
23+
vw:
24+
@cd $(VWN_LOC) ; $(MAKE)
1825
@echo
19-
@echo %%% reach: Compilation Complete.
26+
@echo %%% vwn: Compilation Complete.
2027

2128
da:
2229
@cd $(DPA_LOC); $(MAKE)
2330
@echo
2431
@echo %%% dpa: Compilation Complete.
2532

26-
vw:
27-
@cd $(VWN_LOC) ; $(MAKE)
33+
re:
34+
@cd $(REA_LOC); $(MAKE)
2835
@echo
29-
@echo %%% vwn: Compilation Complete.
36+
@echo %%% reach: Compilation Complete.
3037

31-
rec:
32-
@cd $(REA_LOC); $(MAKE) clean
38+
vwc:
39+
@cd $(VWN_LOC) ; $(MAKE) clean
3340

3441
dac:
3542
@cd $(DPA_LOC); $(MAKE) clean
3643

37-
vwc:
38-
@cd $(VWN_LOC) ; $(MAKE) clean
44+
rec:
45+
@cd $(REA_LOC); $(MAKE) clean

src/dpa/avr_word_netlist.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ class NumInst: public Inst {
623623

624624
// you can't call!
625625
NumInst(unsigned long num, unsigned size, SORT sort) {
626+
if (size == 1)
627+
assert(num == 0 || num == 1);
626628
m_sort = sort;
627629
m_size = size;
628630
m_mpz = mpz_class(num);
@@ -632,6 +634,8 @@ class NumInst: public Inst {
632634
// m_mpz.set_str(snum, base);
633635
// }
634636
NumInst(mpz_class mnum, unsigned size, SORT sort) {
637+
if (size == 1)
638+
assert(mnum.get_si() == 0 || mnum.get_si() == 1);
635639
m_sort = sort;
636640
m_size = size;
637641
m_mpz = mnum;

src/makefile.include

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
STATIC_MODE := 0
22

3-
### enable/disable solver environments
4-
### by default, z3 environment is disabled
5-
### also choose a BACKEND_* flag in src/reach/reach_backend.h
6-
### to change solver backends for different kinds of SMT queries
7-
###
8-
ENABLE_Y2 := 1
9-
ENABLE_M5 := 1
10-
ENABLE_BT := 1
11-
ENABLE_Z3 := 0
12-
133
ENABLE_VMT := 1
144
ENABLE_BTOR2 := 1
155

@@ -27,7 +17,6 @@ STATIC_GMP = -lgmp
2717
STATIC_GMPXX = -lgmpxx
2818

2919
#### reach : reachability computation
30-
REACH_BIN = $(BIN_DIR)/reach
3120
REACH_OBJS = avr_word_netlist.o avr_util.o avr_config.o reach_sa.o reach_backend.o reach_z3.o reach_y2.o \
3221
reach_evaluate.o reach_coi.o reach_simulate.o reach_util.o reach_tsim.o reach_solve.o \
3322
reach_cegar.o reach_core.o reach.o reach_cex.o reach_print.o reach_bmc.o reach_bool.o
@@ -53,7 +42,7 @@ ifeq ($(ENABLE_BTOR2), 1)
5342
VWN_OBJS += btor2_frontend.o btor2_parser.o
5443
endif
5544

56-
GPP=g++ -std=c++11
45+
GPP=g++ -std=c++17
5746

5847
#### flags
5948
CFLAG_OPT = -g -O3

src/reach/Makefile

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@ else
1010
LINK_FLAGS += -pthread -lgmpxx -lgmp -lrt -ldl
1111
endif
1212

13+
Y2_DIR = $(DEPS)/yices2
14+
Y2_LIB = $(Y2_DIR)/build/x86_64-pc-linux-gnu-release/dist/lib/libyices.a
15+
INCLUDE += -I$(Y2_DIR)/build/x86_64-pc-linux-gnu-release/dist/include
16+
LINKLIBS += $(Y2_LIB)
17+
CFLAGS += -D_Y2
1318
ifeq ($(ENABLE_Y2), 1)
14-
Y2_DIR = $(DEPS)/yices2
15-
Y2_LIB = $(Y2_DIR)/build/x86_64-pc-linux-gnu-release/dist/lib/libyices.a
16-
INCLUDE += -I$(Y2_DIR)/build/x86_64-pc-linux-gnu-release/dist/include
17-
LINKLIBS += $(Y2_LIB)
18-
CFLAGS += -D_Y2
19+
CFLAGS += -DBACKEND_Y2
20+
REACH_SUFFIX = y2
1921
endif
2022

21-
ifeq ($(ENABLE_Z3), 1)
22-
Z3_DIR = $(DEPS)/z3
23-
Z3_LIB = $(Z3_DIR)/build/lib/libz3.a
24-
INCLUDE += -I$(Z3_DIR)/build/include
25-
LINKLIBS += $(Z3_LIB)
26-
CFLAGS += -D_Z3
23+
ifeq ($(ENABLE_BT), 1)
24+
BT_DIR = $(DEPS)/boolector
25+
BT_LIB = $(BT_DIR)/build/lib/libboolector.a
26+
BT_LIB += $(BT_DIR)/deps/btor2tools/build/lib/libbtor2parser.a
27+
BT_LIB += $(BT_DIR)/deps/cadical/build/libcadical.a
28+
INCLUDE += -I$(BT_DIR)/src
29+
LINKLIBS += $(BT_LIB)
30+
CFLAGS += -D_BT
31+
CFLAGS += -DBACKEND_BT
32+
REACH_SUFFIX = bt
2733
endif
2834

2935
ifeq ($(ENABLE_M5), 1)
@@ -32,16 +38,17 @@ ifeq ($(ENABLE_M5), 1)
3238
INCLUDE += -I$(MSAT_DIR)/include
3339
LINKLIBS += $(MSAT_LIB)
3440
CFLAGS += -D_M5
41+
CFLAGS += -DBACKEND_M5
42+
REACH_SUFFIX = m5
3543
endif
3644

37-
ifeq ($(ENABLE_BT), 1)
38-
BT_DIR = $(DEPS)/boolector
39-
BT_LIB = $(BT_DIR)/build/lib/libboolector.a
40-
BT_LIB += $(BT_DIR)/deps/btor2tools/build/lib/libbtor2parser.a
41-
BT_LIB += $(BT_DIR)/deps/cadical/build/libcadical.a
42-
INCLUDE += -I$(BT_DIR)/src
43-
LINKLIBS += $(BT_LIB)
44-
CFLAGS += -D_BT
45+
ifeq ($(ENABLE_Z3), 1)
46+
Z3_DIR = $(DEPS)/z3
47+
Z3_LIB = $(Z3_DIR)/build/lib/libz3.a
48+
INCLUDE += -I$(Z3_DIR)/build/include
49+
LINKLIBS += $(Z3_LIB)
50+
CFLAGS += -D_Z3 -DBACKEND_Z3
51+
REACH_SUFFIX = z3
4552
endif
4653

4754
DEPDIR := .d
@@ -51,7 +58,10 @@ DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
5158
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CFLAGS) $(INCLUDE)
5259
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
5360

61+
REACH_BIN = $(BIN_DIR)/reach_$(REACH_SUFFIX)
62+
5463
all:
64+
rm -f *.o
5565
$(MAKE) $(REACH_BIN)
5666

5767
$(REACH_BIN):$(REACH_OBJS)
@@ -65,7 +75,7 @@ $(REACH_BIN):$(REACH_OBJS)
6575

6676
clean:
6777
rm -f *.o
68-
rm -f $(REACH_BIN)
78+
rm -f $(BIN_DIR)/reach*
6979
rm -rf .d/
7080

7181
$(DEPDIR)/%.d: ;

src/reach/avr_word_netlist.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5427,16 +5427,16 @@ void OpInst::calc_size() {
54275427
assert((*cit)->get_type() == Num);
54285428
unsigned width = NumInst::as(*cit)->get_num();
54295429
cit++;
5430+
unsigned sz = NumInst::as(*cit)->get_num();
5431+
cit++;
54305432
assert((*cit)->get_type() == Num);
5431-
m_size = (*cit)->get_size();
5433+
m_size = sz;
54325434
m_sort.sz = m_size;
5433-
unsigned range = m_size;
5434-
assert(range > 0);
54355435

54365436
m_sort.type = arraytype;
54375437
m_sort.args.clear();
54385438
m_sort.args.push_back(SORT(width));
5439-
m_sort.args.push_back(SORT(range));
5439+
m_sort.args.push_back(SORT(m_size));
54405440
assert(m_size > 0);
54415441
assert(m_sort.sz > 0);
54425442
}
@@ -5643,7 +5643,7 @@ unsigned find_size(OpInst::OpType op, InstL& exps)
56435643
second++;
56445644
assert((*first)->get_type() == Num);
56455645
assert((*second)->get_type() == Num);
5646-
size = (*second)->get_size();
5646+
size = NumInst::as(*second)->get_num();
56475647
assert (size > 0);
56485648
}
56495649
break;

src/reach/avr_word_netlist.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,8 @@ class NumInst: public Inst {
21552155

21562156
// you can't call!
21572157
NumInst(unsigned long num, unsigned size, bool fromSystem, SORT sort) {
2158+
if (size == 1)
2159+
assert(num == 0 || num == 1);
21582160
m_sort = sort;
21592161
m_size = size;
21602162
m_mpz = mpz_class(num);
@@ -2188,6 +2190,8 @@ class NumInst: public Inst {
21882190
// m_mpz.set_str(snum, base);
21892191
// }
21902192
NumInst(mpz_class mnum, unsigned size, bool fromSystem, SORT sort) {
2193+
if (size == 1)
2194+
assert(mnum.get_si() == 0 || mnum.get_si() == 1);
21912195
m_sort = sort;
21922196
m_size = size;
21932197
m_mpz = mnum;

src/reach/reach_backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/// Configurations
2727
/// Note: Only one of the below flag should be enabled
2828

29-
#define BACKEND_Y2 // Yices 2 for all queries
29+
// #define BACKEND_Y2 // Yices 2 for all queries
3030
// #define BACKEND_BT // Yices 2 for abstract, Boolector for bv queries
3131
// #define BACKEND_M5 // Yices 2 for abstract, MathSAT 5 for bv queries
3232

0 commit comments

Comments
 (0)