VIS
|
00001 00018 #include "tblInt.h" 00019 #include "baig.h" 00020 00021 static char rcsid[] UNUSED = "$Id: tblAigUtil.c,v 1.3 2005/04/17 14:37:23 awedh Exp $"; 00022 00025 /*---------------------------------------------------------------------------*/ 00026 /* Static function prototypes */ 00027 /*---------------------------------------------------------------------------*/ 00028 00029 00033 /*---------------------------------------------------------------------------*/ 00034 /* Definition of exported functions */ 00035 /*---------------------------------------------------------------------------*/ 00036 00054 MvfAig_Function_t * 00055 Tbl_TableBuildNonDetConstantMvfAig( 00056 Tbl_Table_t *table, 00057 int outIndex, 00058 int mAigId, 00059 mAig_Manager_t *manager) 00060 { 00061 00062 lsGen gen; 00063 Tbl_Entry_t *entry; 00064 Tbl_Range_t *range; 00065 int value, rowNum, colNum; 00066 mAigEdge_t x; 00067 MvfAig_Function_t *function; 00068 00069 assert(Tbl_TableReadNumInputs(table) ==0); 00070 00071 value = Var_VariableReadNumValues(Tbl_TableReadIndexVar(table, outIndex, 1)); 00072 function = MvfAig_FunctionAlloc(value); 00073 Tbl_TableForEachOutputEntry(table,rowNum,colNum,entry) { 00074 if (colNum == outIndex) { 00075 assert(entry->type == Tbl_EntryNormal_c); 00076 Tbl_EntryForEachValue(entry,value,gen,range) { 00077 x = mAig_EquC(manager, mAigId, value); 00078 MvfAig_FunctionAddMintermsToComponent(manager, function, value, x); 00079 } 00080 } 00081 } 00082 return function; 00083 } 00084 00085 00104 MvfAig_Function_t * 00105 Tbl_TableBuildMvfAigFromFanins( 00106 Tbl_Table_t * table, 00107 int outIndex, 00108 array_t * faninArray, 00109 mAig_Manager_t *manager) 00110 { 00111 00112 lsGen gen; 00113 Tbl_Entry_t *entry, *equalEntry, *inputEntry; 00114 Tbl_Range_t *range; 00115 int value, rowNum, colNum, rowColNum, i; 00116 mAigEdge_t x, result, temp; 00117 MvfAig_Function_t *function, *mvf1, *mvf2; 00118 00119 00120 x = mAig_NULL; 00121 value = Var_VariableReadNumValues(Tbl_TableReadIndexVar(table,outIndex,1)); 00122 function = MvfAig_FunctionAlloc(value); 00123 00124 Tbl_TableForEachOutputEntry(table,rowNum,colNum,entry) { 00125 if (colNum == outIndex) { 00126 if (entry->type == Tbl_EntryNormal_c) { 00127 result = mAig_One; 00128 Tbl_RowForEachInputEntry(table,rowNum,inputEntry,rowColNum) { 00129 if (inputEntry->type == Tbl_EntryNormal_c) { 00130 mvf1 = array_fetch(MvfAig_Function_t*,faninArray,rowColNum); 00131 x = TblEntryNormalConstructAig(manager, inputEntry, mvf1); 00132 } 00133 else if (inputEntry->type == Tbl_EntryUniverse_c) { 00134 x = mAig_One; 00135 } 00136 else if (inputEntry->type == Tbl_EntryEqual_c) { 00137 value =Tbl_EntryReadVarIndex(inputEntry); 00138 mvf1 = array_fetch(MvfAig_Function_t*,faninArray,rowColNum); 00139 mvf2 = array_fetch(MvfAig_Function_t*,faninArray,value); 00140 x = MvfAig_FunctionsComputeEquivalentSet(manager, mvf1,mvf2); 00141 } 00142 temp = result; 00143 result = mAig_And(manager, x,temp); 00144 } 00145 /* add the result to each value of the output */ 00146 Tbl_EntryForEachValue(entry,value,gen,range) { 00147 MvfAig_FunctionAddMintermsToComponent(manager, function, value,result); 00148 } 00149 00150 } /* output is not Normal */ 00151 else if (entry->type == Tbl_EntryEqual_c) { 00152 value = Tbl_EntryReadVarIndex(entry); 00153 if (value == -1) { 00154 fail("Failure: Not equal to any input var in this table\n"); 00155 } 00156 00157 /* must be equal to an input */ 00158 00159 equalEntry = Tbl_TableReadEntry(table,rowNum,value,0); 00160 result = mAig_One; 00161 Tbl_RowForEachInputEntry(table,rowNum,inputEntry,rowColNum) { 00162 if (inputEntry->type == Tbl_EntryNormal_c) { 00163 /* Don't include this input if the output is set be equal to it 00164 */ 00165 if ( inputEntry == equalEntry){ 00166 continue; 00167 } 00168 mvf1 = array_fetch(MvfAig_Function_t*,faninArray,rowColNum); 00169 x = TblEntryNormalConstructAig(manager, inputEntry, mvf1); 00170 } 00171 else if (inputEntry->type == Tbl_EntryUniverse_c) { 00172 x = mAig_One; 00173 } 00174 else if (inputEntry->type == Tbl_EntryEqual_c) { 00175 value =Tbl_EntryReadVarIndex(inputEntry); 00176 mvf1 = array_fetch(MvfAig_Function_t*,faninArray,rowColNum); 00177 mvf2 = array_fetch(MvfAig_Function_t*,faninArray,value); 00178 x = MvfAig_FunctionsComputeEquivalentSet(manager, mvf1,mvf2); 00179 } 00180 temp = result; 00181 result = mAig_And(manager, x, temp); 00182 } 00183 00184 temp = result; 00185 rowColNum = Tbl_EntryReadVarIndex(entry); 00186 mvf1 = array_fetch(MvfAig_Function_t*, faninArray, rowColNum); 00187 00188 if (equalEntry->type == Tbl_EntryNormal_c) { 00189 /* add the result to each value of the equal input */ 00190 Tbl_EntryForEachValue(equalEntry, value, gen, range) { 00191 x = MvfAig_FunctionReadComponent(mvf1, value); 00192 result = mAig_And(manager, temp, x); 00193 MvfAig_FunctionAddMintermsToComponent(manager, function, value, result); 00194 } 00195 }else { /* Add Minterms for all vlaues */ 00196 value = Var_VariableReadNumValues(Tbl_EntryReadActualVar(table, equalEntry)); 00197 for(i=0; i< value; i++) { 00198 x = MvfAig_FunctionReadComponent(mvf1,i); 00199 result = mAig_And(manager, temp, x); 00200 MvfAig_FunctionAddMintermsToComponent(manager, function, i,result); 00201 } 00202 } 00203 } 00204 } 00205 } 00206 00207 /* accounting for the defaults */ 00208 entry = Tbl_TableDefaultReadEntry(table,outIndex); 00209 if (entry != NIL(Tbl_Entry_t)) { 00210 temp = MvfAig_FunctionComputeDomain(manager, function); 00211 result = mAig_Not(temp); 00212 00213 if (entry->type == Tbl_EntryNormal_c) { 00214 Tbl_EntryForEachValue(entry,value,gen,range) { 00215 MvfAig_FunctionAddMintermsToComponent(manager, function, value, result); 00216 } 00217 } 00218 else { 00219 value = Tbl_EntryReadVarIndex(entry); 00220 if (value == -1) { 00221 fail("Failure: Not equal to any input var in this table\n"); 00222 } 00223 mvf1 = array_fetch(MvfAig_Function_t*, faninArray, value); 00224 00225 MvfAig_FunctionForEachComponent(mvf1, i, x) { 00226 temp = mAig_And(manager, x, result); 00227 MvfAig_FunctionAddMintermsToComponent(manager, function, i ,temp); 00228 } 00229 } 00230 00231 } 00232 00233 return function; 00234 } 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245