#include "hop.h"
Go to the source code of this file.
Functions | |
static int | Hop_ObjIsExorType (Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Obj_t **ppFan0, Hop_Obj_t **ppFan1) |
Hop_Obj_t * | Hop_IthVar (Hop_Man_t *p, int i) |
Hop_Obj_t * | Hop_Oper (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type) |
Hop_Obj_t * | Hop_And (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1) |
Hop_Obj_t * | Hop_Exor (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1) |
Hop_Obj_t * | Hop_Or (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1) |
Hop_Obj_t * | Hop_Mux (Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0) |
Hop_Obj_t * | Hop_Maj (Hop_Man_t *p, Hop_Obj_t *pA, Hop_Obj_t *pB, Hop_Obj_t *pC) |
Hop_Obj_t * | Hop_Multi_rec (Hop_Man_t *p, Hop_Obj_t **ppObjs, int nObjs, Hop_Type_t Type) |
Hop_Obj_t * | Hop_Multi (Hop_Man_t *p, Hop_Obj_t **pArgs, int nArgs, Hop_Type_t Type) |
Hop_Obj_t * | Hop_Miter (Hop_Man_t *p, Vec_Ptr_t *vPairs) |
Hop_Obj_t * | Hop_CreateAnd (Hop_Man_t *p, int nVars) |
Hop_Obj_t * | Hop_CreateOr (Hop_Man_t *p, int nVars) |
Hop_Obj_t * | Hop_CreateExor (Hop_Man_t *p, int nVars) |
Function*************************************************************
Synopsis [Performs canonicization step.]
Description [The argument nodes can be complemented.]
SideEffects []
SeeAlso []
Definition at line 101 of file hopOper.c.
00102 { 00103 Hop_Obj_t * pGhost, * pResult; 00104 // Hop_Obj_t * pFan0, * pFan1; 00105 // check trivial cases 00106 if ( p0 == p1 ) 00107 return p0; 00108 if ( p0 == Hop_Not(p1) ) 00109 return Hop_Not(p->pConst1); 00110 if ( Hop_Regular(p0) == p->pConst1 ) 00111 return p0 == p->pConst1 ? p1 : Hop_Not(p->pConst1); 00112 if ( Hop_Regular(p1) == p->pConst1 ) 00113 return p1 == p->pConst1 ? p0 : Hop_Not(p->pConst1); 00114 // check if it can be an EXOR gate 00115 // if ( Hop_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) ) 00116 // return Hop_Exor( p, pFan0, pFan1 ); 00117 // check the table 00118 pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_AND ); 00119 if ( pResult = Hop_TableLookup( p, pGhost ) ) 00120 return pResult; 00121 return Hop_ObjCreate( p, pGhost ); 00122 }
Function*************************************************************
Synopsis [Creates AND function with nVars inputs.]
Description []
SideEffects []
SeeAlso []
Definition at line 317 of file hopOper.c.
00318 { 00319 Hop_Obj_t * pFunc; 00320 int i; 00321 pFunc = Hop_ManConst1( p ); 00322 for ( i = 0; i < nVars; i++ ) 00323 pFunc = Hop_And( p, pFunc, Hop_IthVar(p, i) ); 00324 return pFunc; 00325 }
Function*************************************************************
Synopsis [Creates AND function with nVars inputs.]
Description []
SideEffects []
SeeAlso []
Definition at line 359 of file hopOper.c.
00360 { 00361 Hop_Obj_t * pFunc; 00362 int i; 00363 pFunc = Hop_ManConst0( p ); 00364 for ( i = 0; i < nVars; i++ ) 00365 pFunc = Hop_Exor( p, pFunc, Hop_IthVar(p, i) ); 00366 return pFunc; 00367 }
Function*************************************************************
Synopsis [Creates AND function with nVars inputs.]
Description []
SideEffects []
SeeAlso []
Definition at line 338 of file hopOper.c.
00339 { 00340 Hop_Obj_t * pFunc; 00341 int i; 00342 pFunc = Hop_ManConst0( p ); 00343 for ( i = 0; i < nVars; i++ ) 00344 pFunc = Hop_Or( p, pFunc, Hop_IthVar(p, i) ); 00345 return pFunc; 00346 }
Function*************************************************************
Synopsis [Performs canonicization step.]
Description [The argument nodes can be complemented.]
SideEffects []
SeeAlso []
Definition at line 135 of file hopOper.c.
00136 { 00137 /* 00138 Hop_Obj_t * pGhost, * pResult; 00139 // check trivial cases 00140 if ( p0 == p1 ) 00141 return Hop_Not(p->pConst1); 00142 if ( p0 == Hop_Not(p1) ) 00143 return p->pConst1; 00144 if ( Hop_Regular(p0) == p->pConst1 ) 00145 return Hop_NotCond( p1, p0 == p->pConst1 ); 00146 if ( Hop_Regular(p1) == p->pConst1 ) 00147 return Hop_NotCond( p0, p1 == p->pConst1 ); 00148 // check the table 00149 pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_EXOR ); 00150 if ( pResult = Hop_TableLookup( p, pGhost ) ) 00151 return pResult; 00152 return Hop_ObjCreate( p, pGhost ); 00153 */ 00154 return Hop_Or( p, Hop_And(p, p0, Hop_Not(p1)), Hop_And(p, Hop_Not(p0), p1) ); 00155 }
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Returns i-th elementary variable.]
Description []
SideEffects []
SeeAlso []
Definition at line 60 of file hopOper.c.
00061 { 00062 int v; 00063 for ( v = Hop_ManPiNum(p); v <= i; v++ ) 00064 Hop_ObjCreatePi( p ); 00065 assert( i < Vec_PtrSize(p->vPis) ); 00066 return Hop_ManPi( p, i ); 00067 }
Function*************************************************************
Synopsis [Implements ITE operation.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis [Implements the miter.]
Description []
SideEffects []
SeeAlso []
Definition at line 294 of file hopOper.c.
00295 { 00296 int i; 00297 assert( vPairs->nSize > 0 ); 00298 assert( vPairs->nSize % 2 == 0 ); 00299 // go through the cubes of the node's SOP 00300 for ( i = 0; i < vPairs->nSize; i += 2 ) 00301 vPairs->pArray[i/2] = Hop_Not( Hop_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) ); 00302 vPairs->nSize = vPairs->nSize/2; 00303 return Hop_Not( Hop_Multi_rec( p, (Hop_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) ); 00304 }
Hop_Obj_t* Hop_Multi | ( | Hop_Man_t * | p, | |
Hop_Obj_t ** | pArgs, | |||
int | nArgs, | |||
Hop_Type_t | Type | |||
) |
Function*************************************************************
Synopsis [Old code.]
Description []
SideEffects []
SeeAlso []
Definition at line 276 of file hopOper.c.
00277 { 00278 assert( Type == AIG_AND || Type == AIG_EXOR ); 00279 assert( nArgs > 0 ); 00280 return Hop_Multi_rec( p, pArgs, nArgs, Type ); 00281 }
Hop_Obj_t* Hop_Multi_rec | ( | Hop_Man_t * | p, | |
Hop_Obj_t ** | ppObjs, | |||
int | nObjs, | |||
Hop_Type_t | Type | |||
) |
Function*************************************************************
Synopsis [Constructs the well-balanced tree of gates.]
Description [Disregards levels and possible logic sharing.]
SideEffects []
SeeAlso []
Definition at line 255 of file hopOper.c.
00256 { 00257 Hop_Obj_t * pObj1, * pObj2; 00258 if ( nObjs == 1 ) 00259 return ppObjs[0]; 00260 pObj1 = Hop_Multi_rec( p, ppObjs, nObjs/2, Type ); 00261 pObj2 = Hop_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type ); 00262 return Hop_Oper( p, pObj1, pObj2, Type ); 00263 }
Function*************************************************************
Synopsis [Implements ITE operation.]
Description []
SideEffects []
SeeAlso []
Definition at line 184 of file hopOper.c.
00185 { 00186 /* 00187 Hop_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp; 00188 int Count0, Count1; 00189 // consider trivial cases 00190 if ( p0 == Hop_Not(p1) ) 00191 return Hop_Exor( p, pC, p0 ); 00192 // other cases can be added 00193 // implement the first MUX (F = C * x1 + C' * x0) 00194 00195 // check for constants here!!! 00196 00197 pTempA1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, p1, AIG_AND) ); 00198 pTempA2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), p0, AIG_AND) ); 00199 if ( pTempA1 && pTempA2 ) 00200 { 00201 pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempA1), Hop_Not(pTempA2), AIG_AND) ); 00202 if ( pTemp ) return Hop_Not(pTemp); 00203 } 00204 Count0 = (pTempA1 != NULL) + (pTempA2 != NULL); 00205 // implement the second MUX (F' = C * x1' + C' * x0') 00206 pTempB1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, Hop_Not(p1), AIG_AND) ); 00207 pTempB2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), Hop_Not(p0), AIG_AND) ); 00208 if ( pTempB1 && pTempB2 ) 00209 { 00210 pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempB1), Hop_Not(pTempB2), AIG_AND) ); 00211 if ( pTemp ) return pTemp; 00212 } 00213 Count1 = (pTempB1 != NULL) + (pTempB2 != NULL); 00214 // compare and decide which one to implement 00215 if ( Count0 >= Count1 ) 00216 { 00217 pTempA1 = pTempA1? pTempA1 : Hop_And(p, pC, p1); 00218 pTempA2 = pTempA2? pTempA2 : Hop_And(p, Hop_Not(pC), p0); 00219 return Hop_Or( p, pTempA1, pTempA2 ); 00220 } 00221 pTempB1 = pTempB1? pTempB1 : Hop_And(p, pC, Hop_Not(p1)); 00222 pTempB2 = pTempB2? pTempB2 : Hop_And(p, Hop_Not(pC), Hop_Not(p0)); 00223 return Hop_Not( Hop_Or( p, pTempB1, pTempB2 ) ); 00224 */ 00225 return Hop_Or( p, Hop_And(p, pC, p1), Hop_And(p, Hop_Not(pC), p0) ); 00226 }
static int Hop_ObjIsExorType | ( | Hop_Obj_t * | p0, | |
Hop_Obj_t * | p1, | |||
Hop_Obj_t ** | ppFan0, | |||
Hop_Obj_t ** | ppFan1 | |||
) | [inline, static] |
CFile****************************************************************
FileName [hopOper.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Minimalistic And-Inverter Graph package.]
Synopsis [AIG operations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - May 11, 2006.]
Revision [
] DECLARATIONS ///
Definition at line 28 of file hopOper.c.
00029 { 00030 if ( !Hop_IsComplement(p0) || !Hop_IsComplement(p1) ) 00031 return 0; 00032 p0 = Hop_Regular(p0); 00033 p1 = Hop_Regular(p1); 00034 if ( !Hop_ObjIsAnd(p0) || !Hop_ObjIsAnd(p1) ) 00035 return 0; 00036 if ( Hop_ObjFanin0(p0) != Hop_ObjFanin0(p1) || Hop_ObjFanin1(p0) != Hop_ObjFanin1(p1) ) 00037 return 0; 00038 if ( Hop_ObjFaninC0(p0) == Hop_ObjFaninC0(p1) || Hop_ObjFaninC1(p0) == Hop_ObjFaninC1(p1) ) 00039 return 0; 00040 *ppFan0 = Hop_ObjChild0(p0); 00041 *ppFan1 = Hop_ObjChild1(p0); 00042 return 1; 00043 }
Hop_Obj_t* Hop_Oper | ( | Hop_Man_t * | p, | |
Hop_Obj_t * | p0, | |||
Hop_Obj_t * | p1, | |||
Hop_Type_t | Type | |||
) |
Function*************************************************************
Synopsis [Perform one operation.]
Description [The argument nodes can be complemented.]
SideEffects []
SeeAlso []