00001
00021 #include "ivy.h"
00022
00026
00027 static Ivy_Obj_t * Ivy_TableLookupPair_rec( Ivy_Man_t * p, Ivy_Obj_t * pObj0, Ivy_Obj_t * pObj1, int fCompl0, int fCompl1, Ivy_Type_t Type );
00028
00032
00044 Ivy_Obj_t * Ivy_CanonPair_rec( Ivy_Man_t * p, Ivy_Obj_t * pGhost )
00045 {
00046 Ivy_Obj_t * pResult, * pLat0, * pLat1;
00047 Ivy_Init_t Init, Init0, Init1;
00048 int fCompl0, fCompl1;
00049 Ivy_Type_t Type;
00050 assert( Ivy_ObjIsNode(pGhost) );
00051 assert( Ivy_ObjIsAnd(pGhost) || (!Ivy_ObjFaninC0(pGhost) && !Ivy_ObjFaninC1(pGhost)) );
00052 assert( Ivy_ObjFaninId0(pGhost) != 0 && Ivy_ObjFaninId1(pGhost) != 0 );
00053
00054 if ( !Ivy_ObjIsLatch(Ivy_ObjFanin0(pGhost)) || !Ivy_ObjIsLatch(Ivy_ObjFanin1(pGhost)) )
00055 {
00056 if ( pResult = Ivy_TableLookup( p, pGhost ) )
00057 return pResult;
00058 return Ivy_ObjCreate( p, pGhost );
00059 }
00061 pLat0 = Ivy_ObjFanin0(pGhost);
00062 pLat1 = Ivy_ObjFanin1(pGhost);
00063
00064 Type = Ivy_ObjType(pGhost);
00065 fCompl0 = Ivy_ObjFaninC0(pGhost);
00066 fCompl1 = Ivy_ObjFaninC1(pGhost);
00067
00068 pResult = Ivy_Oper( p, Ivy_NotCond(Ivy_ObjFanin0(pLat0), fCompl0), Ivy_NotCond(Ivy_ObjFanin0(pLat1), fCompl1), Type );
00069
00070 Init0 = Ivy_InitNotCond( Ivy_ObjInit(pLat0), fCompl0 );
00071 Init1 = Ivy_InitNotCond( Ivy_ObjInit(pLat1), fCompl1 );
00072 Init = (Type == IVY_AND)? Ivy_InitAnd(Init0, Init1) : Ivy_InitExor(Init0, Init1);
00073 return Ivy_Latch( p, pResult, Init );
00074 }
00075
00087 Ivy_Obj_t * Ivy_CanonAnd( Ivy_Man_t * p, Ivy_Obj_t * pObj0, Ivy_Obj_t * pObj1 )
00088 {
00089 Ivy_Obj_t * pGhost, * pResult;
00090 pGhost = Ivy_ObjCreateGhost( p, pObj0, pObj1, IVY_AND, IVY_INIT_NONE );
00091 pResult = Ivy_CanonPair_rec( p, pGhost );
00092 return pResult;
00093 }
00094
00106 Ivy_Obj_t * Ivy_CanonExor( Ivy_Man_t * p, Ivy_Obj_t * pObj0, Ivy_Obj_t * pObj1 )
00107 {
00108 Ivy_Obj_t * pGhost, * pResult;
00109 int fCompl = Ivy_IsComplement(pObj0) ^ Ivy_IsComplement(pObj1);
00110 pObj0 = Ivy_Regular(pObj0);
00111 pObj1 = Ivy_Regular(pObj1);
00112 pGhost = Ivy_ObjCreateGhost( p, pObj0, pObj1, IVY_EXOR, IVY_INIT_NONE );
00113 pResult = Ivy_CanonPair_rec( p, pGhost );
00114 return Ivy_NotCond( pResult, fCompl );
00115 }
00116
00128 Ivy_Obj_t * Ivy_CanonLatch( Ivy_Man_t * p, Ivy_Obj_t * pObj, Ivy_Init_t Init )
00129 {
00130 Ivy_Obj_t * pGhost, * pResult;
00131 int fCompl = Ivy_IsComplement(pObj);
00132 pObj = Ivy_Regular(pObj);
00133 pGhost = Ivy_ObjCreateGhost( p, pObj, NULL, IVY_LATCH, Ivy_InitNotCond(Init, fCompl) );
00134 pResult = Ivy_TableLookup( p, pGhost );
00135 if ( pResult == NULL )
00136 pResult = Ivy_ObjCreate( p, pGhost );
00137 return Ivy_NotCond( pResult, fCompl );
00138 }
00139
00143
00144