Example #1
0
def go_bmc(force=False):
    """
    Performs all the necessary steps to use loaded model and be able to perform
    bmc related operations on it.
    
    :raises NuSMVNoReadModelError: if no module was read (:see:`glob.load`) 
      before this method was called. 
    """
    cmp = glob.global_compile_cmps() 
    if not _compile.cmp_struct_get_read_model(cmp):
        raise NuSMVNoReadModelError("No read model.")

    # Check cmps and perform what is needed
    if not _compile.cmp_struct_get_flatten_hrc(cmp):
        glob.flatten_hierarchy()
    if not _compile.cmp_struct_get_encode_variables(cmp):
        glob.encode_variables()
    if not _compile.cmp_struct_get_build_bool_model(cmp):
        glob.build_boolean_model(force=force)
    if not _compile.cmp_struct_get_bmc_setup(cmp):
        bmc_setup(force=force)
Example #2
0
def go_bmc(force=False):
    """
    Performs all the necessary steps to use loaded model and be able to perform
    bmc related operations on it.
    
    :raises NuSMVNoReadModelError: if no module was read (:func:`pynusmv.glob.load`) 
      before this method was called. 
    """
    cmp = glob.global_compile_cmps() 
    if not _compile.cmp_struct_get_read_model(cmp):
        raise NuSMVNoReadModelError("No read model.")

    # Check cmps and perform what is needed
    if not _compile.cmp_struct_get_flatten_hrc(cmp):
        glob.flatten_hierarchy()
    if not _compile.cmp_struct_get_encode_variables(cmp):
        glob.encode_variables()
    if not _compile.cmp_struct_get_build_bool_model(cmp):
        glob.build_boolean_model(force=force)
    if not _compile.cmp_struct_get_bmc_setup(cmp):
        bmc_setup(force=force)
Example #3
0
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())
Example #4
0
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())