00001 /* --------------------------------------------------------------------------- 00002 00003 00004 This file is part of the ``enc.bdd'' package of NuSMV version 2. 00005 Copyright (C) 2004 by FBK-irst. 00006 00007 NuSMV version 2 is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 NuSMV version 2 is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00020 00021 For more information on NuSMV see <http://nusmv.fbk.eu> 00022 or email to <nusmv-users@fbk.eu>. 00023 Please report bugs to <nusmv-users@fbk.eu>. 00024 00025 To contact the NuSMV development board, email to <nusmv@fbk.eu>. 00026 00027 -----------------------------------------------------------------------------*/ 00028 00039 #ifndef __NUSMV_CORE_ENC_BDD_BDD_ENC_PRIVATE_H__ 00040 #define __NUSMV_CORE_ENC_BDD_BDD_ENC_PRIVATE_H__ 00041 00042 00043 #include "nusmv/core/enc/bdd/BddEnc.h" 00044 #include "nusmv/core/enc/bdd/BddEncCache.h" 00045 00046 #include "nusmv/core/enc/base/BoolEncClient.h" 00047 #include "nusmv/core/enc/base/BoolEncClient_private.h" 00048 00049 #include "nusmv/core/utils/array.h" 00050 #include "nusmv/core/utils/utils.h" 00051 00057 #define BDD_ENC_INIT_VAR_NUM 4096 00058 00059 00069 typedef struct BddEnc_TAG 00070 { 00071 /* this MUST stay on the top */ 00072 INHERITS_FROM(BoolEncClient); 00073 00074 /* -------------------------------------------------- */ 00075 /* Private members */ 00076 /* -------------------------------------------------- */ 00077 TypeChecker_ptr type_checker; /* used to get the type of expression */ 00078 00079 VarsHandler_ptr dd_vars_hndr; 00080 DDMgr_ptr dd; /* this field is here only for performances */ 00081 00082 BddEncCache_ptr cache; 00083 00084 /* used for grouping of vars */ 00085 OrdGroups_ptr ord_groups; 00086 hash_ptr layer2groups; 00087 00088 /* used to shuffle the variable ordering */ 00089 array_t* level2index; /* array of int */ 00090 00091 /* used to lock/unlock vars ordering: */ 00092 dd_reorderingtype curr_reord_type; 00093 int reord_status; 00094 int reord_locked_num; 00095 int curr_reorderings; /* number of reorderings so far */ 00096 00097 /* number of variables: */ 00098 int input_vars_num; 00099 int state_vars_num; 00100 int frozen_vars_num; 00101 00102 /* The array of symbolic variable names. Each element i contains the 00103 symbolic name associated to the variable with index i */ 00104 array_t* index2name; /* array of node_ptr */ 00105 hash_ptr name2index; 00106 00107 /* These arrays are used to maintain correspondence between current 00108 and next variables. Position i contains the index of the 00109 corresponding next state variable. They are used to perform forward 00110 and backward shifting respectively */ 00111 array_t* current2next; /* array of int */ 00112 array_t* next2current; /* array of int */ 00113 00114 /* Arrays used to pick up a minterm from a given BDD. These arrays 00115 should contain at least all variables in the support of the BDD 00116 which we want extract a minterm of. When a layer is removed, 00117 these arrays will be compacted, i.e. no gaps are allowed to 00118 exist at any time. 00119 Associtated to each array there is the current frontier. */ 00120 array_t* minterm_input_vars; /* array of bdd_ptr */ 00121 int minterm_input_vars_dim; 00122 00123 /* array sizes are kept explicit here because due to compaction 00124 array size and size can be different */ 00125 00126 array_t* minterm_state_vars; /* array of bdd_ptr */ 00127 int minterm_state_vars_dim; 00128 00129 array_t* minterm_next_state_vars; /* array of bdd_ptr */ 00130 int minterm_next_state_vars_dim; 00131 00132 array_t* minterm_frozen_vars; /* array of bdd_ptr */ 00133 int minterm_frozen_vars_dim; 00134 00135 array_t* minterm_state_frozen_vars; /* array of bdd_ptr */ 00136 int minterm_state_frozen_vars_dim; 00137 00138 array_t* minterm_state_frozen_input_vars; /* array of bdd_ptr */ 00139 int minterm_state_frozen_input_vars_dim; 00140 00141 00142 /* This list is intended to hold the indices of variables there were 00143 removed and are then available for reusing. If this list is empty, 00144 there are no gaps at all, and the next available index will be taken 00145 from the number of currently allocated variables. This list 00146 keeps the indices ordered. */ 00147 NodeList_ptr index_gaps; 00148 00149 /* Contains the maximum index that has been used so far to allocate 00150 new vars. If there are gaps (i.e. removed vars not yet reused), 00151 this value is greater than the number of variables currently 00152 allocated. This index is used to allocate new indices when gaps 00153 are not available for reuse. Notice that index 0 is never used 00154 for variables, as it seems to be reserved by cudds. 00155 00156 DO NOT USE this field directly, call methods 00157 bdd_enc_get_avail_state_var_index and bdd_enc_get_avail_input_var_index 00158 instead. */ 00159 int used_indices_frontier; 00160 00161 /* These are the cubes of input, state current and state next vars. 00162 When a new var is added, only corresponding ADD cubes will be 00163 modified, the construction of the BDD is delayed until the BDD 00164 cube is required: */ 00165 00166 /* 1. The cube of input variables to be used in image forward and 00167 backward */ 00168 add_ptr input_vars_add; 00169 bdd_ptr input_vars_bdd; 00170 00171 /* 2. The cube of state variables to be used in image forward */ 00172 add_ptr state_vars_add; 00173 bdd_ptr state_vars_bdd; 00174 00175 /* 3. The cube of state variables to be used in image backward */ 00176 add_ptr next_state_vars_add; 00177 bdd_ptr next_state_vars_bdd; 00178 00179 /* 4. The cube of frozen variables */ 00180 add_ptr frozen_vars_add; 00181 bdd_ptr frozen_vars_bdd; 00182 00183 /* 5. The cube of current state variables and frozen variables to be 00184 used in image forward. This is computed out of state and frozen 00185 vars cubes */ 00186 bdd_ptr state_frozen_vars_bdd; 00187 00188 /* This is a stack of instances of class BddEncPrintInfo, used 00189 to print Bdds */ 00190 node_ptr print_stack; 00191 00192 /* This variable is used to control the behavior of the 00193 method bdd_enc_eval (specifically the behavior of its subroutine 00194 get_definition). */ 00195 boolean enforce_constant; 00196 00197 00198 /* Masks: */ 00199 add_ptr input_vars_mask_add; 00200 add_ptr state_frozen_vars_mask_add; 00201 add_ptr state_frozen_input_vars_mask_add; 00202 00203 bdd_ptr input_vars_mask_bdd; 00204 bdd_ptr state_frozen_vars_mask_bdd; 00205 bdd_ptr state_frozen_input_vars_mask_bdd; 00206 00207 00208 /* To check failure leaves quickly */ 00209 hash_ptr failures_hash; 00210 00211 /* -------------------------------------------------- */ 00212 /* Virtual methods */ 00213 /* -------------------------------------------------- */ 00214 00215 } BddEnc; 00216 00222 #define BDD_ENC_EVALUATING (ADD_ARRAY(-1)) 00223 00224 00225 /* ---------------------------------------------------------------------- */ 00226 /* Private methods to be used by derivated and friend classes only */ 00227 /* ---------------------------------------------------------------------- */ 00232 void bdd_enc_init(BddEnc_ptr self, 00233 SymbTable_ptr symb_table, 00234 BoolEnc_ptr bool_enc, VarsHandler_ptr dd_vars_hdlr, 00235 OrdGroups_ptr ord_groups); 00236 00241 void bdd_enc_deinit(BddEnc_ptr self); 00242 00243 void bdd_enc_commit_layer(BaseEnc_ptr enc_base, const char* layer_name); 00244 00245 void bdd_enc_remove_layer(BaseEnc_ptr enc_base, const char* layer_name); 00246 00247 00248 /* 00249 Later on this method should be moved to public interface. 00250 At the moment it is used by GAME addon 00251 */ 00256 void bdd_enc_shuffle_variables_order(BddEnc_ptr self, 00257 NodeList_ptr vars); 00258 #endif /* __NUSMV_CORE_ENC_BDD_BDD_ENC_PRIVATE_H__ */