00001
00019 #include "reo.h"
00020
00024
00028
00040 reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F )
00041 {
00042 DdManager * dd = p->dd;
00043 reo_unit * pUnit;
00044 int HKey, fComp;
00045
00046 fComp = Cudd_IsComplement(F);
00047 F = Cudd_Regular(F);
00048
00049
00050 if ( F->ref != 1 )
00051 {
00052
00053 for ( HKey = hashKey2(p->Signature,F,p->nTableSize); p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize )
00054 if ( p->HTable[HKey].Arg1 == (reo_unit *)F )
00055 {
00056 pUnit = p->HTable[HKey].Arg2;
00057 assert( pUnit );
00058
00059 pUnit->n++;
00060 return Unit_NotCond( pUnit, fComp );
00061 }
00062 }
00063
00064
00065
00066 pUnit = reoUnitsGetNextUnit( p );
00067 pUnit->n = 1;
00068 if ( cuddIsConstant(F) )
00069 {
00070 pUnit->lev = REO_CONST_LEVEL;
00071 pUnit->pE = (reo_unit*)((int)(cuddV(F)));
00072 pUnit->pT = NULL;
00073
00074 if ( F != dd->one )
00075 p->fThisIsAdd = 1;
00076
00077 reoUnitsAddUnitToPlane( &(p->pPlanes[p->nSupp]), pUnit );
00078 }
00079 else
00080 {
00081 pUnit->lev = p->pMapToPlanes[F->index];
00082 pUnit->pE = reoTransferNodesToUnits_rec( p, cuddE(F) );
00083 pUnit->pT = reoTransferNodesToUnits_rec( p, cuddT(F) );
00084
00085 reoUnitsAddUnitToPlane( &(p->pPlanes[pUnit->lev]), pUnit );
00086 }
00087
00088
00089 if ( F->ref != 1 )
00090 {
00091
00092
00093
00094 for ( ; p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize );
00095 p->HTable[HKey].Sign = p->Signature;
00096 p->HTable[HKey].Arg1 = (reo_unit *)F;
00097 p->HTable[HKey].Arg2 = pUnit;
00098 }
00099
00100
00101 p->nNodesCur++;
00102 return Unit_NotCond( pUnit, fComp );
00103 }
00104
00116 DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit )
00117 {
00118 DdManager * dd = p->dd;
00119 DdNode * bRes, * E, * T;
00120 int HKey, fComp;
00121
00122 fComp = Cudd_IsComplement(pUnit);
00123 pUnit = Unit_Regular(pUnit);
00124
00125
00126 if ( pUnit->n != 1 )
00127 {
00128 for ( HKey = hashKey2(p->Signature,pUnit,p->nTableSize); p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize )
00129 if ( p->HTable[HKey].Arg1 == pUnit )
00130 {
00131 bRes = (DdNode*) p->HTable[HKey].Arg2;
00132 assert( bRes );
00133 return Cudd_NotCond( bRes, fComp );
00134 }
00135 }
00136
00137
00138 if ( Unit_IsConstant(pUnit) )
00139 {
00140 bRes = cuddUniqueConst( dd, ((double)((int)(pUnit->pE))) );
00141 cuddRef( bRes );
00142 }
00143 else
00144 {
00145
00146 E = reoTransferUnitsToNodes_rec( p, pUnit->pE );
00147 if ( E == NULL )
00148 return NULL;
00149 cuddRef(E);
00150
00151 T = reoTransferUnitsToNodes_rec( p, pUnit->pT );
00152 if ( T == NULL )
00153 {
00154 Cudd_RecursiveDeref(dd, E);
00155 return NULL;
00156 }
00157 cuddRef(T);
00158
00159
00160 assert( E != T );
00161 assert( !Cudd_IsComplement(T) );
00162
00163 bRes = cuddUniqueInter( dd, p->pMapToDdVarsFinal[pUnit->lev], T, E );
00164 if ( bRes == NULL )
00165 {
00166 Cudd_RecursiveDeref(dd,E);
00167 Cudd_RecursiveDeref(dd,T);
00168 return NULL;
00169 }
00170 cuddRef( bRes );
00171 cuddDeref( E );
00172 cuddDeref( T );
00173 }
00174
00175
00176 if ( pUnit->n != 1 )
00177 {
00178
00179
00180 for ( ; p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize );
00181 p->HTable[HKey].Sign = p->Signature;
00182 p->HTable[HKey].Arg1 = pUnit;
00183 p->HTable[HKey].Arg2 = (reo_unit *)bRes;
00184
00185
00186 p->pRefNodes[p->nRefNodes++] = bRes; Cudd_Ref( bRes );
00187
00188
00189 }
00190
00191 p->nNodesCur++;
00192 cuddDeref( bRes );
00193 return Cudd_NotCond( bRes, fComp );
00194 }
00195
00199