27
27
from select import select
28
28
from time import monotonic , localtime , sleep , strftime
29
29
from sby_design import SbyProperty , SbyModule , design_hierarchy
30
+ from sby_status import SbyStatusDb
30
31
31
32
all_procs_running = []
32
33
@@ -674,20 +675,41 @@ def engine_summary(self, engine_idx):
674
675
self .engine_summaries [engine_idx ] = SbyEngineSummary (engine_idx )
675
676
return self .engine_summaries [engine_idx ]
676
677
677
- def add_event (self , * args , ** kwargs ):
678
+ def add_event (self , * args , update_status = True , ** kwargs ):
678
679
event = SbySummaryEvent (* args , ** kwargs )
680
+
681
+ engine = self .engine_summary (event .engine_idx )
682
+
683
+ if update_status :
684
+ status_metadata = dict (source = "summary_event" , engine = engine .engine )
685
+
679
686
if event .prop :
680
687
if event .type == "$assert" :
681
688
event .prop .status = "FAIL"
682
689
if event .path :
683
690
event .prop .tracefiles .append (event .path )
691
+ if update_status :
692
+ self .task .status_db .add_task_property_data (
693
+ event .prop ,
694
+ "trace" ,
695
+ data = dict (path = event .path , step = event .step , ** status_metadata ),
696
+ )
684
697
if event .prop :
685
698
if event .type == "$cover" :
686
699
event .prop .status = "PASS"
687
700
if event .path :
688
701
event .prop .tracefiles .append (event .path )
689
-
690
- engine = self .engine_summary (event .engine_idx )
702
+ if update_status :
703
+ self .task .status_db .add_task_property_data (
704
+ event .prop ,
705
+ "trace" ,
706
+ data = dict (path = event .path , step = event .step , ** status_metadata ),
707
+ )
708
+ if event .prop and update_status :
709
+ self .task .status_db .set_task_property_status (
710
+ event .prop ,
711
+ data = status_metadata
712
+ )
691
713
692
714
if event .trace not in engine .traces :
693
715
engine .traces [event .trace ] = SbyTraceSummary (event .trace , path = event .path , engine_case = event .engine_case )
@@ -1041,6 +1063,10 @@ def instance_hierarchy_callback(retcode):
1041
1063
if self .design == None :
1042
1064
with open (f"{ self .workdir } /model/design.json" ) as f :
1043
1065
self .design = design_hierarchy (f )
1066
+ self .status_db .create_task_properties ([
1067
+ prop for prop in self .design .properties_by_path .values ()
1068
+ if not prop .type .assume_like
1069
+ ])
1044
1070
1045
1071
def instance_hierarchy_error_callback (retcode ):
1046
1072
self .precise_prop_status = False
@@ -1186,8 +1212,13 @@ def proc_failed(self, proc):
1186
1212
self .status = "ERROR"
1187
1213
self .terminate ()
1188
1214
1215
+ def pass_unknown_asserts (self , data ):
1216
+ for prop in self .design .pass_unknown_asserts ():
1217
+ self .status_db .set_task_property_status (prop , data = data )
1218
+
1189
1219
def update_status (self , new_status ):
1190
1220
assert new_status in ["PASS" , "FAIL" , "UNKNOWN" , "ERROR" ]
1221
+ self .status_db .set_task_status (new_status )
1191
1222
1192
1223
if new_status == "UNKNOWN" :
1193
1224
return
@@ -1199,7 +1230,7 @@ def update_status(self, new_status):
1199
1230
assert self .status != "FAIL"
1200
1231
self .status = "PASS"
1201
1232
if self .opt_mode in ("bmc" , "prove" ) and self .design :
1202
- self .design . pass_unknown_asserts ()
1233
+ self .pass_unknown_asserts (dict ( source = "task_status" ) )
1203
1234
1204
1235
elif new_status == "FAIL" :
1205
1236
assert self .status != "PASS"
@@ -1258,6 +1289,19 @@ def handle_non_engine_options(self):
1258
1289
1259
1290
self .handle_bool_option ("assume_early" , True )
1260
1291
1292
+ def setup_status_db (self , status_path = None ):
1293
+ if hasattr (self , 'status_db' ):
1294
+ return
1295
+
1296
+ if status_path is None :
1297
+ try :
1298
+ with open (f"{ self .workdir } /status.path" , "r" ) as status_path_file :
1299
+ status_path = f"{ self .workdir } /{ status_path_file .read ().rstrip ()} "
1300
+ except FileNotFoundError :
1301
+ status_path = f"{ self .workdir } /status.sqlite"
1302
+
1303
+ self .status_db = SbyStatusDb (status_path , self )
1304
+
1261
1305
def setup_procs (self , setupmode ):
1262
1306
self .handle_non_engine_options ()
1263
1307
if self .opt_smtc is not None :
@@ -1285,6 +1329,8 @@ def setup_procs(self, setupmode):
1285
1329
self .retcode = 0
1286
1330
return
1287
1331
1332
+ self .setup_status_db ()
1333
+
1288
1334
if self .opt_make_model is not None :
1289
1335
for name in self .opt_make_model .split ("," ):
1290
1336
self .model (name .strip ())
0 commit comments