ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
hopOper.c File Reference
#include "hop.h"
Include dependency graph for hopOper.c:

Go to the source code of this file.

Functions

Hop_Obj_tHop_IthVar (Hop_Man_t *p, int i)
 FUNCTION DEFINITIONS ///.
 
Hop_Obj_tHop_Oper (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type)
 
Hop_Obj_tHop_And (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
 
Hop_Obj_tHop_Exor (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
 
Hop_Obj_tHop_Or (Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
 
Hop_Obj_tHop_Mux (Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
 
Hop_Obj_tHop_Maj (Hop_Man_t *p, Hop_Obj_t *pA, Hop_Obj_t *pB, Hop_Obj_t *pC)
 
Hop_Obj_tHop_Multi_rec (Hop_Man_t *p, Hop_Obj_t **ppObjs, int nObjs, Hop_Type_t Type)
 
Hop_Obj_tHop_Multi (Hop_Man_t *p, Hop_Obj_t **pArgs, int nArgs, Hop_Type_t Type)
 
Hop_Obj_tHop_Miter (Hop_Man_t *p, Vec_Ptr_t *vPairs)
 
Hop_Obj_tHop_CreateAnd (Hop_Man_t *p, int nVars)
 
Hop_Obj_tHop_CreateOr (Hop_Man_t *p, int nVars)
 
Hop_Obj_tHop_CreateExor (Hop_Man_t *p, int nVars)
 

Function Documentation

◆ Hop_And()

Hop_Obj_t * Hop_And ( Hop_Man_t * p,
Hop_Obj_t * p0,
Hop_Obj_t * p1 )

Function*************************************************************

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 104 of file hopOper.c.

105{
106 Hop_Obj_t * pGhost, * pResult;
107// Hop_Obj_t * pFan0, * pFan1;
108 // check trivial cases
109 if ( p0 == p1 )
110 return p0;
111 if ( p0 == Hop_Not(p1) )
112 return Hop_Not(p->pConst1);
113 if ( Hop_Regular(p0) == p->pConst1 )
114 return p0 == p->pConst1 ? p1 : Hop_Not(p->pConst1);
115 if ( Hop_Regular(p1) == p->pConst1 )
116 return p1 == p->pConst1 ? p0 : Hop_Not(p->pConst1);
117 // check if it can be an EXOR gate
118// if ( Hop_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
119// return Hop_Exor( p, pFan0, pFan1 );
120 // check the table
121 pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_AND );
122 if ( (pResult = Hop_TableLookup( p, pGhost )) )
123 return pResult;
124 return Hop_ObjCreate( p, pGhost );
125}
Cube * p
Definition exorList.c:222
Hop_Obj_t * Hop_ObjCreate(Hop_Man_t *p, Hop_Obj_t *pGhost)
Definition hopObj.c:97
@ AIG_AND
Definition hop.h:59
Hop_Obj_t * Hop_TableLookup(Hop_Man_t *p, Hop_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition hopTable.c:71
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_CreateAnd()

Hop_Obj_t * Hop_CreateAnd ( Hop_Man_t * p,
int nVars )

Function*************************************************************

Synopsis [Creates AND function with nVars inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file hopOper.c.

321{
322 Hop_Obj_t * pFunc;
323 int i;
324 pFunc = Hop_ManConst1( p );
325 for ( i = 0; i < nVars; i++ )
326 pFunc = Hop_And( p, pFunc, Hop_IthVar(p, i) );
327 return pFunc;
328}
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition hopOper.c:63
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:104
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_CreateExor()

Hop_Obj_t * Hop_CreateExor ( Hop_Man_t * p,
int nVars )

Function*************************************************************

Synopsis [Creates AND function with nVars inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 362 of file hopOper.c.

363{
364 Hop_Obj_t * pFunc;
365 int i;
366 pFunc = Hop_ManConst0( p );
367 for ( i = 0; i < nVars; i++ )
368 pFunc = Hop_Exor( p, pFunc, Hop_IthVar(p, i) );
369 return pFunc;
370}
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:138
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_CreateOr()

Hop_Obj_t * Hop_CreateOr ( Hop_Man_t * p,
int nVars )

Function*************************************************************

Synopsis [Creates AND function with nVars inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 341 of file hopOper.c.

342{
343 Hop_Obj_t * pFunc;
344 int i;
345 pFunc = Hop_ManConst0( p );
346 for ( i = 0; i < nVars; i++ )
347 pFunc = Hop_Or( p, pFunc, Hop_IthVar(p, i) );
348 return pFunc;
349}
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:171
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_Exor()

Hop_Obj_t * Hop_Exor ( Hop_Man_t * p,
Hop_Obj_t * p0,
Hop_Obj_t * p1 )

Function*************************************************************

Synopsis [Performs canonicization step.]

Description [The argument nodes can be complemented.]

SideEffects []

SeeAlso []

Definition at line 138 of file hopOper.c.

139{
140/*
141 Hop_Obj_t * pGhost, * pResult;
142 // check trivial cases
143 if ( p0 == p1 )
144 return Hop_Not(p->pConst1);
145 if ( p0 == Hop_Not(p1) )
146 return p->pConst1;
147 if ( Hop_Regular(p0) == p->pConst1 )
148 return Hop_NotCond( p1, p0 == p->pConst1 );
149 if ( Hop_Regular(p1) == p->pConst1 )
150 return Hop_NotCond( p0, p1 == p->pConst1 );
151 // check the table
152 pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_EXOR );
153 if ( pResult = Hop_TableLookup( p, pGhost ) )
154 return pResult;
155 return Hop_ObjCreate( p, pGhost );
156*/
157 return Hop_Or( p, Hop_And(p, p0, Hop_Not(p1)), Hop_And(p, Hop_Not(p0), p1) );
158}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_IthVar()

Hop_Obj_t * Hop_IthVar ( Hop_Man_t * p,
int i )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Returns i-th elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file hopOper.c.

64{
65 int v;
66 for ( v = Hop_ManPiNum(p); v <= i; v++ )
68 assert( i < Vec_PtrSize(p->vPis) );
69 return Hop_ManPi( p, i );
70}
Hop_Obj_t * Hop_ObjCreatePi(Hop_Man_t *p)
DECLARATIONS ///.
Definition hopObj.c:45
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_Maj()

Hop_Obj_t * Hop_Maj ( Hop_Man_t * p,
Hop_Obj_t * pA,
Hop_Obj_t * pB,
Hop_Obj_t * pC )

Function*************************************************************

Synopsis [Implements ITE operation.]

Description []

SideEffects []

SeeAlso []

Definition at line 242 of file hopOper.c.

243{
244 return Hop_Or( p, Hop_Or(p, Hop_And(p, pA, pB), Hop_And(p, pA, pC)), Hop_And(p, pB, pC) );
245}
Here is the call graph for this function:

◆ Hop_Miter()

Hop_Obj_t * Hop_Miter ( Hop_Man_t * p,
Vec_Ptr_t * vPairs )

Function*************************************************************

Synopsis [Implements the miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 297 of file hopOper.c.

298{
299 int i;
300 assert( vPairs->nSize > 0 );
301 assert( vPairs->nSize % 2 == 0 );
302 // go through the cubes of the node's SOP
303 for ( i = 0; i < vPairs->nSize; i += 2 )
304 vPairs->pArray[i/2] = Hop_Not( Hop_Exor( p, (Hop_Obj_t *)vPairs->pArray[i], (Hop_Obj_t *)vPairs->pArray[i+1] ) );
305 vPairs->nSize = vPairs->nSize/2;
306 return Hop_Not( Hop_Multi_rec( p, (Hop_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) );
307}
Hop_Obj_t * Hop_Multi_rec(Hop_Man_t *p, Hop_Obj_t **ppObjs, int nObjs, Hop_Type_t Type)
Definition hopOper.c:258
Here is the call graph for this function:

◆ Hop_Multi()

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 279 of file hopOper.c.

280{
281 assert( Type == AIG_AND || Type == AIG_EXOR );
282 assert( nArgs > 0 );
283 return Hop_Multi_rec( p, pArgs, nArgs, Type );
284}
@ AIG_EXOR
Definition hop.h:60
Here is the call graph for this function:

◆ Hop_Multi_rec()

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 258 of file hopOper.c.

259{
260 Hop_Obj_t * pObj1, * pObj2;
261 if ( nObjs == 1 )
262 return ppObjs[0];
263 pObj1 = Hop_Multi_rec( p, ppObjs, nObjs/2, Type );
264 pObj2 = Hop_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
265 return Hop_Oper( p, pObj1, pObj2, Type );
266}
Hop_Obj_t * Hop_Oper(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1, Hop_Type_t Type)
Definition hopOper.c:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_Mux()

Hop_Obj_t * Hop_Mux ( Hop_Man_t * p,
Hop_Obj_t * pC,
Hop_Obj_t * p1,
Hop_Obj_t * p0 )

Function*************************************************************

Synopsis [Implements ITE operation.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file hopOper.c.

188{
189/*
190 Hop_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
191 int Count0, Count1;
192 // consider trivial cases
193 if ( p0 == Hop_Not(p1) )
194 return Hop_Exor( p, pC, p0 );
195 // other cases can be added
196 // implement the first MUX (F = C * x1 + C' * x0)
197
198 // check for constants here!!!
199
200 pTempA1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, p1, AIG_AND) );
201 pTempA2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), p0, AIG_AND) );
202 if ( pTempA1 && pTempA2 )
203 {
204 pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempA1), Hop_Not(pTempA2), AIG_AND) );
205 if ( pTemp ) return Hop_Not(pTemp);
206 }
207 Count0 = (pTempA1 != NULL) + (pTempA2 != NULL);
208 // implement the second MUX (F' = C * x1' + C' * x0')
209 pTempB1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, Hop_Not(p1), AIG_AND) );
210 pTempB2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), Hop_Not(p0), AIG_AND) );
211 if ( pTempB1 && pTempB2 )
212 {
213 pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempB1), Hop_Not(pTempB2), AIG_AND) );
214 if ( pTemp ) return pTemp;
215 }
216 Count1 = (pTempB1 != NULL) + (pTempB2 != NULL);
217 // compare and decide which one to implement
218 if ( Count0 >= Count1 )
219 {
220 pTempA1 = pTempA1? pTempA1 : Hop_And(p, pC, p1);
221 pTempA2 = pTempA2? pTempA2 : Hop_And(p, Hop_Not(pC), p0);
222 return Hop_Or( p, pTempA1, pTempA2 );
223 }
224 pTempB1 = pTempB1? pTempB1 : Hop_And(p, pC, Hop_Not(p1));
225 pTempB2 = pTempB2? pTempB2 : Hop_And(p, Hop_Not(pC), Hop_Not(p0));
226 return Hop_Not( Hop_Or( p, pTempB1, pTempB2 ) );
227*/
228 return Hop_Or( p, Hop_And(p, pC, p1), Hop_And(p, Hop_Not(pC), p0) );
229}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_Oper()

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 []

Definition at line 83 of file hopOper.c.

84{
85 if ( Type == AIG_AND )
86 return Hop_And( p, p0, p1 );
87 if ( Type == AIG_EXOR )
88 return Hop_Exor( p, p0, p1 );
89 assert( 0 );
90 return NULL;
91}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_Or()

Hop_Obj_t * Hop_Or ( Hop_Man_t * p,
Hop_Obj_t * p0,
Hop_Obj_t * p1 )

Function*************************************************************

Synopsis [Implements Boolean OR.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file hopOper.c.

172{
173 return Hop_Not( Hop_And( p, Hop_Not(p0), Hop_Not(p1) ) );
174}
Here is the call graph for this function:
Here is the caller graph for this function: