def build_master_be_fsm(): """ Creates the BE fsm from the Sexpr FSM. Currently the be_enc is a singleton global private variable which is shared between all the BE FSMs. If not previoulsy committed (because a boolean encoder was not available at the time due to the use of coi) the determinization layer will be committed to the be_encoder :raises NuSMVBeEncNotInitializedError: if the global BeEnc singleton is not initialized """ global __be_fsm # raises the exception if necessary be_enc = BeEnc.global_singleton_instance() sym_table = be_enc.symbol_table if _symb_table.SymbTable_get_layer(sym_table._ptr, "inlining") is not None: # commits the determ layer if not previously committed if not _baseenc.BaseEnc_layer_occurs(be_enc._ptr, "determ"): _baseenc.BaseEnc_commit_layer(be_enc._ptr, "determ") # commits the inlining layer if not previously committed # note: I find this a little bit weird, but that's the way NuSMV proceeds if not _baseenc.BaseEnc_layer_occurs(be_enc._ptr, "inlining"): _baseenc.BaseEnc_commit_layer(be_enc._ptr, "inlining") # actual fsm creation __be_fsm = BeFsm.create_from_sexp(be_enc, glob.master_bool_sexp_fsm()) propdb = _prop.PropPkg_get_prop_database() _prop.PropDb_master_set_be_fsm(propdb, __be_fsm._ptr);
def setUp(self): init_nusmv() load_from_file(tests.current_directory(__file__)+"/models/flipflops_trans_invar_fairness.smv") go_bmc() self.fsm = BeFsm.global_master_instance() self.enc = self.fsm.encoding
def setUp(self): init_nusmv() glob.load( tests.current_directory(__file__) + "/models/flipflops_explicit_relation.smv") go_bmc() self._fsm = BeFsm.global_master_instance() self._manager = self._fsm.encoding.manager
def test_master_be_fsm(self): load(self.model()) flatten_hierarchy() encode_variables() build_boolean_model() bmcglob.bmc_setup() # may not provoke C assert failures bmcglob.build_master_be_fsm() self.assertEqual(bmcglob.master_be_fsm(), BeFsm.global_master_instance()) bmcglob.bmc_exit()
def master_be_fsm(): """ :return: the boolean FSM in BE stored in the master prop. :raises NuSMVBeFsmMasterInstanceNotInitializedError: when the global BE FSM is null in the global properties database (ie when coi is enabled). """ global __be_fsm if __be_fsm is None: __be_fsm = BeFsm.global_master_instance() return __be_fsm
def bmc_setup(force=False): """ Initializes the bmc sub-system, and builds the model in a Boolean Expression format. This function must be called before the use of any other bmc-related functionalities. Only one call per session is required. If you don't intend to do anything special, you might consider using `go_bmc` which is a shortcut for the whole bmc initialization process. .. note:: This function is subject to the following requirements: - a model must be loaded (:see:`glob.load`) - hierarchy must already be flattened (:see:`glob.flatten_hierarchy) - encoding must be already built (:see:`glob.encode_variables`) - boolean model must be already built (:see:`glob.build_boolean_model`) except if cone of influence is enabled and force is false :param force: a flag telling whether or not the boolean model must exist despite the cone of influence being enabled :raises NuSMVNeedBooleanModelError: if the boolean model wasn't created """ # enforce preconditions if not _compile.cmp_struct_get_build_bool_model(glob.global_compile_cmps()): if not force and glob.is_cone_of_influence_enabled(): pass else: raise NuSMVNeedBooleanModelError("boolean model must be created") if _compile.cmp_struct_get_bmc_setup(glob.global_compile_cmps()): raise NuSMVBmcAlreadyInitializedError("Bmc sub system already set up") # Build the vars manager, initializes the package and all sub packages, # but only if not previously called. _bmc.Bmc_Init() build_master_be_fsm() be_fsm = BeFsm.global_master_instance() be_enc = be_fsm.encoding bdd_enc = glob.bdd_encoding() complete = _trc_exec.SATCompleteTraceExecutor_create( be_fsm._ptr, be_enc._ptr, bdd_enc._ptr) _trace.TraceManager_register_complete_trace_executor( _trace.TracePkg_get_global_trace_manager(), "sat", "SAT complete trace execution", _trc_exec.SATCompleteTraceExecutor2completeTraceExecutor(complete)) partial_norestart = _trc_exec.SATPartialTraceExecutor_create( be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,False) _trace.TraceManager_register_partial_trace_executor( _trace.TracePkg_get_global_trace_manager(), "sat", "SAT partial trace execution (no restart)", _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_norestart)) partial_restarting= _trc_exec.SATPartialTraceExecutor_create( be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,True) _trace.TraceManager_register_partial_trace_executor( _trace.TracePkg_get_global_trace_manager(), "sat_r", "SAT partial trace execution (restart)", _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_restarting)) _compile.cmp_struct_set_bmc_setup(glob.global_compile_cmps())
def setUp(self): init_nusmv() load(self.model()) go_bmc() self.fsm = BeFsm.global_master_instance()
def setUp(self): init_nusmv() glob.load(tests.current_directory(__file__) + "/models/flipflops_explicit_relation.smv") go_bmc() self._fsm = BeFsm.global_master_instance() self._manager = self._fsm.encoding.manager
def bmc_setup(force=False): """ Initializes the bmc sub-system, and builds the model in a Boolean Expression format. This function must be called before the use of any other bmc-related functionalities. Only one call per session is required. If you don't intend to do anything special, you might consider using `go_bmc` which is a shortcut for the whole bmc initialization process. .. note:: This function is subject to the following requirements: - a model must be loaded (:func:`pynusmv.glob.load`) - hierarchy must already be flattened (:func:`pynusmv.glob.flatten_hierarchy`) - encoding must be already built (:func:`pynusmv.glob.encode_variables`) - boolean model must be already built (:func:`pynusmv.glob.build_boolean_model`) except if cone of influence is enabled and force is false :param force: a flag telling whether or not the boolean model must exist despite the cone of influence being enabled :raises NuSMVNeedBooleanModelError: if the boolean model wasn't created """ # enforce preconditions if not _compile.cmp_struct_get_build_bool_model(glob.global_compile_cmps()): if not force and glob.is_cone_of_influence_enabled(): pass else: raise NuSMVNeedBooleanModelError("boolean model must be created") if _compile.cmp_struct_get_bmc_setup(glob.global_compile_cmps()): raise NuSMVBmcAlreadyInitializedError("Bmc sub system already set up") # Build the vars manager, initializes the package and all sub packages, # but only if not previously called. _bmc.Bmc_Init() build_master_be_fsm() be_fsm = BeFsm.global_master_instance() be_enc = be_fsm.encoding bdd_enc = glob.bdd_encoding() complete = _trc_exec.SATCompleteTraceExecutor_create( be_fsm._ptr, be_enc._ptr, bdd_enc._ptr) _trace.TraceManager_register_complete_trace_executor( _trace.TracePkg_get_global_trace_manager(), "sat", "SAT complete trace execution", _trc_exec.SATCompleteTraceExecutor2completeTraceExecutor(complete)) partial_norestart = _trc_exec.SATPartialTraceExecutor_create( be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,False) _trace.TraceManager_register_partial_trace_executor( _trace.TracePkg_get_global_trace_manager(), "sat", "SAT partial trace execution (no restart)", _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_norestart)) partial_restarting= _trc_exec.SATPartialTraceExecutor_create( be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,True) _trace.TraceManager_register_partial_trace_executor( _trace.TracePkg_get_global_trace_manager(), "sat_r", "SAT partial trace execution (restart)", _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_restarting)) _compile.cmp_struct_set_bmc_setup(glob.global_compile_cmps())