ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Fxch.h File Reference
#include "base/abc/abc.h"
#include "misc/vec/vecHsh.h"
#include "misc/vec/vecQue.h"
#include "misc/vec/vecVec.h"
#include "misc/vec/vecWec.h"
Include dependency graph for Fxch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Fxch_SubCube_t_
 STRUCTURES DEFINITIONS ///. More...
 
struct  Fxch_SCHashTable_Entry_t_
 
struct  Fxch_SCHashTable_t_
 
struct  Fxch_Man_t_
 

Typedefs

typedef unsigned int uint32_t
 
typedef struct Fxch_SubCube_t_ Fxch_SubCube_t
 
typedef struct Fxch_SCHashTable_t_ Fxch_SCHashTable_t
 
typedef struct Fxch_SCHashTable_Entry_t_ Fxch_SCHashTable_Entry_t
 

Functions

Vec_Wec_tAbc_NtkFxRetrieve (Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///.
 
void Abc_NtkFxInsert (Abc_Ntk_t *pNtk, Vec_Wec_t *vCubes)
 
int Abc_NtkFxCheck (Abc_Ntk_t *pNtk)
 
int Abc_NtkFxchPerform (Abc_Ntk_t *pNtk, int nMaxDivExt, int fVerbose, int fVeryVerbose)
 
int Fxch_FastExtract (Vec_Wec_t *vCubes, int ObjIdMax, int nMaxDivExt, int fVerbose, int fVeryVerbose)
 
int Fxch_DivCreate (Fxch_Man_t *pFxchMan, Fxch_SubCube_t *pSubCube0, Fxch_SubCube_t *pSubCube1)
 
int Fxch_DivAdd (Fxch_Man_t *pFxchMan, int fUpdate, int fSingleCube, int fBase)
 
int Fxch_DivRemove (Fxch_Man_t *pFxchMan, int fUpdate, int fSingleCube, int fBase)
 
void Fxch_DivSepareteCubes (Vec_Int_t *vDiv, Vec_Int_t *vCube0, Vec_Int_t *vCube1)
 
int Fxch_DivRemoveLits (Vec_Int_t *vCube0, Vec_Int_t *vCube1, Vec_Int_t *vDiv, int *fCompl)
 
void Fxch_DivPrint (Fxch_Man_t *pFxchMan, int iDiv)
 
int Fxch_DivIsNotConstant1 (Vec_Int_t *vDiv)
 
Fxch_Man_tFxch_ManAlloc (Vec_Wec_t *vCubes)
 PUBLIC INTERFACE ///.
 
void Fxch_ManFree (Fxch_Man_t *pFxchMan)
 
void Fxch_ManMapLiteralsIntoCubes (Fxch_Man_t *pFxchMan, int nVars)
 
void Fxch_ManGenerateLitHashKeys (Fxch_Man_t *pFxchMan)
 
void Fxch_ManSCHashTablesInit (Fxch_Man_t *pFxchMan)
 
void Fxch_ManSCHashTablesFree (Fxch_Man_t *pFxchMan)
 
void Fxch_ManDivCreate (Fxch_Man_t *pFxchMan)
 
int Fxch_ManComputeLevelDiv (Fxch_Man_t *pFxchMan, Vec_Int_t *vCubeFree)
 
int Fxch_ManComputeLevelCube (Fxch_Man_t *pFxchMan, Vec_Int_t *vCube)
 
void Fxch_ManComputeLevel (Fxch_Man_t *pFxchMan)
 
void Fxch_ManUpdate (Fxch_Man_t *pFxchMan, int iDiv)
 
void Fxch_ManPrintDivs (Fxch_Man_t *pFxchMan)
 
void Fxch_ManPrintStats (Fxch_Man_t *pFxchMan)
 
Fxch_SCHashTable_tFxch_SCHashTableCreate (Fxch_Man_t *pFxchMan, int nEntries)
 
void Fxch_SCHashTableDelete (Fxch_SCHashTable_t *)
 
int Fxch_SCHashTableInsert (Fxch_SCHashTable_t *pSCHashTable, Vec_Wec_t *vCubes, uint32_t SubCubeID, uint32_t iCube, uint32_t iLit0, uint32_t iLit1, char fUpdate)
 
int Fxch_SCHashTableRemove (Fxch_SCHashTable_t *pSCHashTable, Vec_Wec_t *vCubes, uint32_t SubCubeID, uint32_t iCube, uint32_t iLit0, uint32_t iLit1, char fUpdate)
 
unsigned int Fxch_SCHashTableMemory (Fxch_SCHashTable_t *)
 
void Fxch_SCHashTablePrint (Fxch_SCHashTable_t *)
 

Variables

ABC_NAMESPACE_HEADER_START typedef unsigned char uint8_t
 

Typedef Documentation

◆ Fxch_SCHashTable_Entry_t

Definition at line 40 of file Fxch.h.

◆ Fxch_SCHashTable_t

Definition at line 39 of file Fxch.h.

◆ Fxch_SubCube_t

Definition at line 38 of file Fxch.h.

◆ uint32_t

typedef unsigned int uint32_t

Definition at line 32 of file Fxch.h.

Function Documentation

◆ Abc_NtkFxCheck()

int Abc_NtkFxCheck ( Abc_Ntk_t * pNtk)
extern

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

Synopsis [Makes sure the nodes do not have complemented and duplicated fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file abcFx.c.

284{
285 Abc_Obj_t * pNode;
286 int i;
287// Abc_NtkForEachObj( pNtk, pNode, i )
288// Abc_ObjPrint( stdout, pNode );
289 Abc_NtkForEachNode( pNtk, pNode, i )
290 if ( !Vec_IntCheckUniqueSmall( &pNode->vFanins ) ) {
291 printf( "Fanins of node %d: ", i );
292 Vec_IntPrint( &pNode->vFanins );
293 return 0;
294 }
295 return 1;
296}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
Vec_Int_t vFanins
Definition abc.h:143
Here is the caller graph for this function:

◆ Abc_NtkFxchPerform()

int Abc_NtkFxchPerform ( Abc_Ntk_t * pNtk,
int nMaxDivExt,
int fVerbose,
int fVeryVerbose )

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

Synopsis [ Retrives the necessary information for the fast extract with cube hashing. ]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file Fxch.c.

233{
234 Vec_Wec_t* vCubes;
235
236 assert( Abc_NtkIsSopLogic( pNtk ) );
237
238 if ( !Abc_NtkFxCheck( pNtk ) )
239 {
240 printf( "Abc_NtkFxchPerform(): Nodes have duplicated fanins. FXCH is not performed.\n" );
241 return 0;
242 }
243
244 vCubes = Abc_NtkFxRetrieve( pNtk );
245 if ( Fxch_FastExtract( vCubes, Abc_NtkObjNumMax( pNtk ), nMaxDivExt, fVerbose, fVeryVerbose ) > 0 )
246 {
247 Abc_NtkFxInsert( pNtk, vCubes );
248 Vec_WecFree( vCubes );
249
250 if ( !Abc_NtkCheck( pNtk ) )
251 printf( "Abc_NtkFxchPerform(): The network check has failed.\n" );
252
253 return 1;
254 }
255 else
256 printf( "Warning: The network has not been changed by \"fxch\".\n" );
257
258 Vec_WecFree( vCubes );
259
260 return 0;
261}
int Fxch_FastExtract(Vec_Wec_t *vCubes, int ObjIdMax, int nMaxDivExt, int fVerbose, int fVeryVerbose)
Definition Fxch.c:160
Vec_Wec_t * Abc_NtkFxRetrieve(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcFx.c:140
void Abc_NtkFxInsert(Abc_Ntk_t *pNtk, Vec_Wec_t *vCubes)
Definition abcFx.c:183
int Abc_NtkFxCheck(Abc_Ntk_t *pNtk)
Definition abcFx.c:283
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:

◆ Abc_NtkFxInsert()

void Abc_NtkFxInsert ( Abc_Ntk_t * pNtk,
Vec_Wec_t * vCubes )
extern

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

Synopsis [Inserts SOP information after fast_extract.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file abcFx.c.

184{
185 Vec_Int_t * vCube, * vPres, * vFirst, * vCount;
186 Abc_Obj_t * pNode, * pFanin;
187 char * pCube, * pSop;
188 int i, k, v, Lit, iFanin, iNodeMax = 0;
189 assert( Abc_NtkIsSopLogic(pNtk) );
190 // check that cubes have no gaps and are ordered by first node
191 Lit = -1;
192 Vec_WecForEachLevel( vCubes, vCube, i )
193 {
194 assert( Vec_IntSize(vCube) > 0 );
195 assert( Lit <= Vec_IntEntry(vCube, 0) );
196 Lit = Vec_IntEntry(vCube, 0);
197 }
198 // find the largest index
199 Vec_WecForEachLevel( vCubes, vCube, i )
200 iNodeMax = Abc_MaxInt( iNodeMax, Vec_IntEntry(vCube, 0) );
201 // quit if nothing changes
202 if ( iNodeMax < Abc_NtkObjNumMax(pNtk) )
203 {
204 //printf( "The network is unchanged by fast extract.\n" );
205 return;
206 }
207 // create new nodes
208 for ( i = Abc_NtkObjNumMax(pNtk); i <= iNodeMax; i++ )
209 {
210 pNode = Abc_NtkCreateNode( pNtk );
211 assert( i == (int)Abc_ObjId(pNode) );
212 }
213 // create node fanins
214 vFirst = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
215 vCount = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
216 Vec_WecForEachLevel( vCubes, vCube, i )
217 {
218 iFanin = Vec_IntEntry( vCube, 0 );
219 if ( Vec_IntEntry(vCount, iFanin) == 0 )
220 Vec_IntWriteEntry( vFirst, iFanin, i );
221 Vec_IntAddToEntry( vCount, iFanin, 1 );
222 }
223 // create node SOPs
224 vPres = Vec_IntStartFull( Abc_NtkObjNumMax(pNtk) );
225 Abc_NtkForEachNode( pNtk, pNode, i )
226 {
227// if ( Vec_IntEntry(vCount, i) == 0 ) continue;
228 Abc_ObjRemoveFanins( pNode );
229 // create fanins
230 assert( Vec_IntEntry(vCount, i) > 0 );
231 for ( k = 0; k < Vec_IntEntry(vCount, i); k++ )
232 {
233 vCube = Vec_WecEntry( vCubes, Vec_IntEntry(vFirst, i) + k );
234 assert( Vec_IntEntry( vCube, 0 ) == i );
235 Vec_IntForEachEntryStart( vCube, Lit, v, 1 )
236 {
237 pFanin = Abc_NtkObj(pNtk, Abc_Lit2Var(Lit));
238 if ( Vec_IntEntry(vPres, Abc_ObjId(pFanin)) >= 0 )
239 continue;
240 Vec_IntWriteEntry(vPres, Abc_ObjId(pFanin), Abc_ObjFaninNum(pNode));
241 Abc_ObjAddFanin( pNode, pFanin );
242 }
243 }
244 // create SOP
245 pSop = pCube = Abc_SopStart( (Mem_Flex_t *)pNtk->pManFunc, Vec_IntEntry(vCount, i), Abc_ObjFaninNum(pNode) );
246 for ( k = 0; k < Vec_IntEntry(vCount, i); k++ )
247 {
248 vCube = Vec_WecEntry( vCubes, Vec_IntEntry(vFirst, i) + k );
249 assert( Vec_IntEntry( vCube, 0 ) == i );
250 Vec_IntForEachEntryStart( vCube, Lit, v, 1 )
251 {
252 pFanin = Abc_NtkObj(pNtk, Abc_Lit2Var(Lit));
253 iFanin = Vec_IntEntry(vPres, Abc_ObjId(pFanin));
254 assert( iFanin >= 0 && iFanin < Abc_ObjFaninNum(pNode) );
255 pCube[iFanin] = Abc_LitIsCompl(Lit) ? '0' : '1';
256 }
257 pCube += Abc_ObjFaninNum(pNode) + 3;
258 }
259 // complement SOP if the original one was complemented
260 if ( pNode->pData && Abc_SopIsComplement((char *)pNode->pData) )
261 Abc_SopComplement( pSop );
262 pNode->pData = pSop;
263 // clean fanins
264 Abc_ObjForEachFanin( pNode, pFanin, v )
265 Vec_IntWriteEntry( vPres, Abc_ObjId(pFanin), -1 );
266 }
267 Vec_IntFree( vFirst );
268 Vec_IntFree( vCount );
269 Vec_IntFree( vPres );
270}
ABC_DLL char * Abc_SopStart(Mem_Flex_t *pMan, int nCubes, int nVars)
Definition abcSop.c:82
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL void Abc_SopComplement(char *pSop)
Definition abcSop.c:648
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
Definition abcFanio.c:141
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition abcSop.c:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkFxRetrieve()

Vec_Wec_t * Abc_NtkFxRetrieve ( Abc_Ntk_t * pNtk)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Retrieves SOP information for fast_extract.]

Description []

SideEffects []

SeeAlso []

Definition at line 140 of file abcFx.c.

141{
142 Vec_Wec_t * vCubes;
143 Vec_Int_t * vCube;
144 Abc_Obj_t * pNode;
145 char * pCube, * pSop;
146 int nVars, i, v, Lit;
147 assert( Abc_NtkIsSopLogic(pNtk) );
148 vCubes = Vec_WecAlloc( 1000 );
149 Abc_NtkForEachNode( pNtk, pNode, i )
150 {
151 pSop = (char *)pNode->pData;
152 nVars = Abc_SopGetVarNum(pSop);
153 assert( nVars == Abc_ObjFaninNum(pNode) );
154// if ( nVars < 2 ) continue;
155 Abc_SopForEachCube( pSop, nVars, pCube )
156 {
157 vCube = Vec_WecPushLevel( vCubes );
158 Vec_IntPush( vCube, Abc_ObjId(pNode) );
159 Abc_CubeForEachVar( pCube, Lit, v )
160 {
161 if ( Lit == '0' )
162 Vec_IntPush( vCube, Abc_Var2Lit(Abc_ObjFaninId(pNode, v), 1) );
163 else if ( Lit == '1' )
164 Vec_IntPush( vCube, Abc_Var2Lit(Abc_ObjFaninId(pNode, v), 0) );
165 }
166 Vec_IntSelectSort( Vec_IntArray(vCube) + 1, Vec_IntSize(vCube) - 1 );
167 }
168 }
169 return vCubes;
170}
#define Abc_CubeForEachVar(pCube, Value, i)
Definition abc.h:536
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_DivAdd()

int Fxch_DivAdd ( Fxch_Man_t * pFxchMan,
int fUpdate,
int fSingleCube,
int fBase )

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

Synopsis [ Add a divisor to the divisors hash table. ]

Description [ This functions will try to add the divisor store in vCubeFree to the divisor hash table. If the divisor is already present in the hash table it will just increment its weight, otherwise it will add the divisor and asign an initial weight. ]

SideEffects [ If the fUpdate option is set, the function will also update the divisor priority queue. ]

SeeAlso []

Definition at line 228 of file FxchDiv.c.

232{
233 int iDiv = Hsh_VecManAdd( pFxchMan->pDivHash, pFxchMan->vCubeFree );
234
235 /* Verify if the divisor already exist */
236 if ( iDiv == Vec_FltSize( pFxchMan->vDivWeights ) )
237 {
238 Vec_WecPushLevel( pFxchMan->vDivCubePairs );
239
240 /* Assign initial weight */
241 if ( fSingleCube )
242 {
243 Vec_FltPush( pFxchMan->vDivWeights,
244 -Vec_IntSize( pFxchMan->vCubeFree ) + 0.9
245 -0.001 * Fxch_ManComputeLevelDiv( pFxchMan, pFxchMan->vCubeFree ) );
246 }
247 else
248 {
249 Vec_FltPush( pFxchMan->vDivWeights,
250 -Vec_IntSize( pFxchMan->vCubeFree ) + 0.9
251 -0.0009 * Fxch_ManComputeLevelDiv( pFxchMan, pFxchMan->vCubeFree ) );
252 }
253
254 }
255
256 /* Increment weight */
257 if ( fSingleCube )
258 Vec_FltAddToEntry( pFxchMan->vDivWeights, iDiv, 1 );
259 else
260 Vec_FltAddToEntry( pFxchMan->vDivWeights, iDiv, fBase + Vec_IntSize( pFxchMan->vCubeFree ) - 1 );
261
262 assert( iDiv < Vec_FltSize( pFxchMan->vDivWeights ) );
263
264 if ( fUpdate )
265 if ( pFxchMan->vDivPrio )
266 {
267 if ( Vec_QueIsMember( pFxchMan->vDivPrio, iDiv ) )
268 Vec_QueUpdate( pFxchMan->vDivPrio, iDiv );
269 else
270 Vec_QuePush( pFxchMan->vDivPrio, iDiv );
271 }
272
273 return iDiv;
274}
int Fxch_ManComputeLevelDiv(Fxch_Man_t *pFxchMan, Vec_Int_t *vCubeFree)
Definition FxchMan.c:312
Vec_Flt_t * vDivWeights
Definition Fxch.h:104
Hsh_VecMan_t * pDivHash
Definition Fxch.h:103
Vec_Int_t * vCubeFree
Definition Fxch.h:119
Vec_Que_t * vDivPrio
Definition Fxch.h:105
Vec_Wec_t * vDivCubePairs
Definition Fxch.h:106
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_DivCreate()

int Fxch_DivCreate ( Fxch_Man_t * pFxchMan,
Fxch_SubCube_t * pSubCube0,
Fxch_SubCube_t * pSubCube1 )

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

Synopsis [ Creates a Divisor. ]

Description [ This functions receive as input two sub-cubes and creates a divisor using their information. The divisor is stored in vCubeFree vector of the pFxchMan structure.

It returns the base value, which is the number of elements that the cubes pair used to generate the devisor have in common. ]

SideEffects []

SeeAlso []

Definition at line 112 of file FxchDiv.c.

115{
116 int Base = 0;
117
118 int SC0_Lit0,
119 SC0_Lit1,
120 SC1_Lit0,
121 SC1_Lit1;
122
123 int Cube0Size,
124 Cube1Size;
125
126 Vec_IntClear( pFxchMan->vCubeFree );
127
128 SC0_Lit0 = Fxch_ManGetLit( pFxchMan, pSubCube0->iCube, pSubCube0->iLit0 );
129 SC0_Lit1 = 0;
130 SC1_Lit0 = Fxch_ManGetLit( pFxchMan, pSubCube1->iCube, pSubCube1->iLit0 );
131 SC1_Lit1 = 0;
132
133 if ( pSubCube0->iLit1 == 0 && pSubCube1->iLit1 == 0 )
134 {
135 Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit0 );
136 Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit0 );
137 }
138 else if ( pSubCube0->iLit1 > 0 && pSubCube1->iLit1 > 0 )
139 {
140 int RetValue;
141
142 SC0_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube0->iCube, pSubCube0->iLit1 );
143 SC1_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube1->iCube, pSubCube1->iLit1 );
144
145 if ( SC0_Lit0 < SC1_Lit0 )
146 {
147 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit0, 0 ) );
148 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit0, 1 ) );
149 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit1, 0 ) );
150 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit1, 1 ) );
151 }
152 else
153 {
154 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit0, 0 ) );
155 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit0, 1 ) );
156 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit1, 0 ) );
157 Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit1, 1 ) );
158 }
159
160 RetValue = Fxch_DivNormalize( pFxchMan->vCubeFree );
161 if ( RetValue == -1 )
162 return -1;
163 }
164 else
165 {
166 if ( pSubCube0->iLit1 > 0 )
167 {
168 SC0_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube0->iCube, pSubCube0->iLit1 );
169
170 Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit0 );
171 if ( SC0_Lit0 == Abc_LitNot( SC1_Lit0 ) )
172 Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit1 );
173 else if ( SC0_Lit1 == Abc_LitNot( SC1_Lit0 ) )
174 Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit0 );
175 }
176 else
177 {
178 SC1_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube1->iCube, pSubCube1->iLit1 );
179
180 Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit0 );
181 if ( SC1_Lit0 == Abc_LitNot( SC0_Lit0 ) )
182 Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit1 );
183 else if ( SC1_Lit1 == Abc_LitNot( SC0_Lit0 ) )
184 Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit0 );
185 }
186 }
187
188 if ( Vec_IntSize( pFxchMan->vCubeFree ) == 0 )
189 return -1;
190
191 if ( Vec_IntSize ( pFxchMan->vCubeFree ) == 2 )
192 {
193 Vec_IntSort( pFxchMan->vCubeFree, 0 );
194
195 Vec_IntWriteEntry( pFxchMan->vCubeFree, 0, Abc_Var2Lit( Vec_IntEntry( pFxchMan->vCubeFree, 0 ), 0 ) );
196 Vec_IntWriteEntry( pFxchMan->vCubeFree, 1, Abc_Var2Lit( Vec_IntEntry( pFxchMan->vCubeFree, 1 ), 1 ) );
197 }
198
199 Cube0Size = Vec_IntSize( Fxch_ManGetCube( pFxchMan, pSubCube0->iCube ) );
200 Cube1Size = Vec_IntSize( Fxch_ManGetCube( pFxchMan, pSubCube1->iCube ) );
201 if ( Vec_IntSize( pFxchMan->vCubeFree ) % 2 == 0 )
202 {
203 Base = Abc_MinInt( Cube0Size, Cube1Size )
204 -( Vec_IntSize( pFxchMan->vCubeFree ) / 2) - 1; /* 1 or 2 Lits, 1 SOP NodeID */
205 }
206 else
207 return -1;
208
209 return Base;
210}
uint32_t iLit1
Definition Fxch.h:64
uint32_t iLit0
Definition Fxch.h:63
uint32_t iCube
Definition Fxch.h:62
Here is the caller graph for this function:

◆ Fxch_DivIsNotConstant1()

int Fxch_DivIsNotConstant1 ( Vec_Int_t * vDiv)

Definition at line 470 of file FxchDiv.c.

471{
472 int Lit0 = Abc_Lit2Var( Vec_IntEntry( vDiv, 0 ) ),
473 Lit1 = Abc_Lit2Var( Vec_IntEntry( vDiv, 1 ) );
474
475 if ( ( Vec_IntSize( vDiv ) == 2 ) && ( Lit0 == Abc_LitNot( Lit1 ) ) )
476 return 0;
477
478 return 1;
479}
Here is the caller graph for this function:

◆ Fxch_DivPrint()

void Fxch_DivPrint ( Fxch_Man_t * pFxchMan,
int iDiv )

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

Synopsis [ Print the divisor identified by iDiv. ]

Description []

SideEffects []

SeeAlso []

Definition at line 446 of file FxchDiv.c.

448{
449 Vec_Int_t* vDiv = Hsh_VecReadEntry( pFxchMan->pDivHash, iDiv );
450 int i,
451 Lit;
452
453 printf( "Div %7d : ", iDiv );
454 printf( "Weight %12.5f ", Vec_FltEntry( pFxchMan->vDivWeights, iDiv ) );
455
456 Vec_IntForEachEntry( vDiv, Lit, i )
457 if ( !Abc_LitIsCompl( Lit ) )
458 printf( "%d(1)", Abc_Lit2Var( Lit ) );
459
460 printf( " + " );
461
462 Vec_IntForEachEntry( vDiv, Lit, i )
463 if ( Abc_LitIsCompl( Lit ) )
464 printf( "%d(2)", Abc_Lit2Var( Lit ) );
465
466 printf( " Lits =%7d ", pFxchMan->nLits );
467 printf( "Divs =%8d \n", Hsh_VecSize( pFxchMan->pDivHash ) );
468}
int nLits
Definition plaFxch.c:66
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ Fxch_DivRemove()

int Fxch_DivRemove ( Fxch_Man_t * pFxchMan,
int fUpdate,
int fSingleCube,
int fBase )

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

Synopsis [ Removes a divisor to the divisors hash table. ]

Description [ This function don't effectively removes a divisor from the hash table (the hash table implementation don't support such operation). It only assures its existence and decrement its weight. ]

SideEffects [ If the fUpdate option is set, the function will also update the divisor priority queue. ]

SeeAlso []

Definition at line 291 of file FxchDiv.c.

295{
296 int iDiv = Hsh_VecManAdd( pFxchMan->pDivHash, pFxchMan->vCubeFree );
297
298 assert( iDiv < Vec_FltSize( pFxchMan->vDivWeights ) );
299
300 /* Decrement weight */
301 if ( fSingleCube )
302 Vec_FltAddToEntry( pFxchMan->vDivWeights, iDiv, -1 );
303 else
304 Vec_FltAddToEntry( pFxchMan->vDivWeights, iDiv, -( fBase + Vec_IntSize( pFxchMan->vCubeFree ) - 1 ) );
305
306 if ( fUpdate )
307 if ( pFxchMan->vDivPrio )
308 {
309 if ( Vec_QueIsMember( pFxchMan->vDivPrio, iDiv ) )
310 Vec_QueUpdate( pFxchMan->vDivPrio, iDiv );
311 }
312
313 return iDiv;
314}
Here is the caller graph for this function:

◆ Fxch_DivRemoveLits()

int Fxch_DivRemoveLits ( Vec_Int_t * vCube0,
Vec_Int_t * vCube1,
Vec_Int_t * vDiv,
int * fCompl )

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

Synopsis [ Removes the literals present in the divisor from their original cubes. ]

Description [ This function returns the numeber of removed literals which should be equal to the size of the divisor. ]

SideEffects []

SeeAlso []

Definition at line 380 of file FxchDiv.c.

384{
385 int i,
386 Lit,
387 CountP = 0,
388 CountN = 0,
389 Count = 0,
390 ret = 0;
391
392 Vec_IntForEachEntry( vDiv, Lit, i )
393 if ( Abc_LitIsCompl( Abc_Lit2Var( Lit ) ) )
394 CountN += Vec_IntRemove1( vCube0, Abc_Lit2Var( Lit ) );
395 else
396 CountP += Vec_IntRemove1( vCube0, Abc_Lit2Var( Lit ) );
397
398 Vec_IntForEachEntry( vDiv, Lit, i )
399 Count += Vec_IntRemove1( vCube1, Abc_Lit2Var( Lit ) );
400
401 if ( Vec_IntSize( vDiv ) == 2 )
402 Vec_IntForEachEntry( vDiv, Lit, i )
403 {
404 Vec_IntRemove1( vCube0, Abc_LitNot( Abc_Lit2Var( Lit ) ) );
405 Vec_IntRemove1( vCube1, Abc_LitNot( Abc_Lit2Var( Lit ) ) );
406 }
407
408 ret = Count + CountP + CountN;
409
410 if ( Vec_IntSize( vDiv ) == 4 )
411 {
412 int Lit0 = Abc_Lit2Var( Vec_IntEntry( vDiv, 0 ) ),
413 Lit1 = Abc_Lit2Var( Vec_IntEntry( vDiv, 1 ) ),
414 Lit2 = Abc_Lit2Var( Vec_IntEntry( vDiv, 2 ) ),
415 Lit3 = Abc_Lit2Var( Vec_IntEntry( vDiv, 3 ) );
416
417 if ( Lit0 == Abc_LitNot( Lit1 ) && Lit2 == Abc_LitNot( Lit3 ) && CountN == 1 )
418 *fCompl = 1;
419
420 if ( Lit0 == Abc_LitNot( Lit1 ) && ret == 2 )
421 {
422 *fCompl = 1;
423
424 Vec_IntForEachEntry( vDiv, Lit, i )
425 ret += Vec_IntRemove1( vCube0, ( Abc_Lit2Var( Lit ) ^ (fCompl && i > 1) ) );
426
427 Vec_IntForEachEntry( vDiv, Lit, i )
428 ret += Vec_IntRemove1( vCube1, ( Abc_Lit2Var( Lit ) ^ (fCompl && i > 1) ) );
429 }
430 }
431
432 return ret;
433}

◆ Fxch_DivSepareteCubes()

void Fxch_DivSepareteCubes ( Vec_Int_t * vDiv,
Vec_Int_t * vCube0,
Vec_Int_t * vCube1 )

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

Synopsis [ Separete the cubes in present in a divisor ]

Description [ In this implementation all stored divsors are composed of two cubes.

In order to save space and to be able to use the Vec_Int_t hash table both cubes are stored in the same vector - using a little hack to differentiate which literal belongs to each cube.

This function separetes the two cubes in their own vectors so that they can be added to the cover.

Note* that this also applies to single cube divisors beacuse of the DeMorgan Law: ab = ( a! + !b )! ]

SideEffects []

SeeAlso []

Definition at line 339 of file FxchDiv.c.

342{
343 int* pArray;
344 int i,
345 Lit;
346
347 Vec_IntForEachEntry( vDiv, Lit, i )
348 if ( Abc_LitIsCompl(Lit) )
349 Vec_IntPush( vCube1, Abc_Lit2Var( Lit ) );
350 else
351 Vec_IntPush( vCube0, Abc_Lit2Var( Lit ) );
352
353 if ( ( Vec_IntSize( vDiv ) == 4 ) && ( Vec_IntSize( vCube0 ) == 3 ) )
354 {
355 assert( Vec_IntSize( vCube1 ) == 3 );
356
357 pArray = Vec_IntArray( vCube0 );
358 if ( pArray[1] > pArray[2] )
359 ABC_SWAP( int, pArray[1], pArray[2] );
360
361 pArray = Vec_IntArray( vCube1 );
362 if ( pArray[1] > pArray[2] )
363 ABC_SWAP( int, pArray[1], pArray[2] );
364 }
365}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253

◆ Fxch_FastExtract()

int Fxch_FastExtract ( Vec_Wec_t * vCubes,
int ObjIdMax,
int nMaxDivExt,
int fVerbose,
int fVeryVerbose )

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

Synopsis [ Performs fast extract with cube hashing on a set of covers. ]

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file Fxch.c.

165{
166 abctime TempTime;
167 Fxch_Man_t* pFxchMan = Fxch_ManAlloc( vCubes );
168 int i;
169
170 TempTime = Abc_Clock();
171 Fxch_CubesGruping( pFxchMan );
172 Fxch_ManMapLiteralsIntoCubes( pFxchMan, ObjIdMax );
173 Fxch_ManGenerateLitHashKeys( pFxchMan );
174 Fxch_ManComputeLevel( pFxchMan );
175 Fxch_ManSCHashTablesInit( pFxchMan );
176 Fxch_ManDivCreate( pFxchMan );
177 pFxchMan->timeInit = Abc_Clock() - TempTime;
178
179 if ( fVeryVerbose )
180 Fxch_ManPrintDivs( pFxchMan );
181
182 if ( fVerbose )
183 Fxch_ManPrintStats( pFxchMan );
184
185 TempTime = Abc_Clock();
186
187 for ( i = 0; (!nMaxDivExt || i < nMaxDivExt) && Vec_QueTopPriority( pFxchMan->vDivPrio ) > 0.0; i++ )
188 {
189 int iDiv = Vec_QuePop( pFxchMan->vDivPrio );
190
191 if ( fVeryVerbose )
192 Fxch_DivPrint( pFxchMan, iDiv );
193
194 Fxch_ManUpdate( pFxchMan, iDiv );
195 }
196
197 pFxchMan->timeExt = Abc_Clock() - TempTime;
198
199 if ( fVerbose )
200 {
201 Fxch_ManPrintStats( pFxchMan );
202 Abc_PrintTime( 1, "\n[FXCH] Elapsed Time", pFxchMan->timeInit + pFxchMan->timeExt );
203 Abc_PrintTime( 1, "[FXCH] +-> Init", pFxchMan->timeInit );
204 Abc_PrintTime( 1, "[FXCH] +-> Extr", pFxchMan->timeExt );
205 }
206
207 Fxch_CubesUnGruping( pFxchMan );
208 Fxch_ManSCHashTablesFree( pFxchMan );
209 Fxch_ManFree( pFxchMan );
210
211 Vec_WecRemoveEmpty( vCubes );
212 Vec_WecSortByFirstInt( vCubes, 0 );
213
214 return 1;
215}
ABC_NAMESPACE_IMPL_START void Fxch_CubesGruping(Fxch_Man_t *pFxchMan)
FUNCTION DEFINITIONS ///.
Definition Fxch.c:37
void Fxch_CubesUnGruping(Fxch_Man_t *pFxchMan)
Definition Fxch.c:106
void Fxch_ManSCHashTablesFree(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:283
void Fxch_ManMapLiteralsIntoCubes(Fxch_Man_t *pFxchMan, int nVars)
Definition FxchMan.c:215
void Fxch_ManDivCreate(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:288
Fxch_Man_t * Fxch_ManAlloc(Vec_Wec_t *vCubes)
PUBLIC INTERFACE ///.
Definition FxchMan.c:169
void Fxch_ManPrintStats(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:772
void Fxch_ManFree(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:192
void Fxch_ManComputeLevel(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:338
void Fxch_ManPrintDivs(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:764
void Fxch_DivPrint(Fxch_Man_t *pFxchMan, int iDiv)
Definition FxchDiv.c:446
void Fxch_ManSCHashTablesInit(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:265
void Fxch_ManGenerateLitHashKeys(Fxch_Man_t *pFxchMan)
Definition FxchMan.c:255
ABC_INT64_T abctime
Definition abc_global.h:332
struct Fxch_Man_t_ Fxch_Man_t
TYPEDEF DECLARATIONS ///.
Definition plaFxch.c:42
void Fxch_ManUpdate(Fxch_Man_t *p, int iDiv)
Definition plaFxch.c:617
abctime timeExt
Definition Fxch.h:128
abctime timeInit
Definition Fxch.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_ManAlloc()

Fxch_Man_t * Fxch_ManAlloc ( Vec_Wec_t * vCubes)

PUBLIC INTERFACE ///.

Definition at line 169 of file FxchMan.c.

170{
171 Fxch_Man_t* pFxchMan = ABC_CALLOC( Fxch_Man_t, 1 );
172
173 pFxchMan->vCubes = vCubes;
174 pFxchMan->nCubesInit = Vec_WecSize( vCubes );
175
176 pFxchMan->pDivHash = Hsh_VecManStart( 1024 );
177 pFxchMan->vDivWeights = Vec_FltAlloc( 1024 );
178 pFxchMan->vDivCubePairs = Vec_WecAlloc( 1024 );
179
180 pFxchMan->vCubeFree = Vec_IntAlloc( 4 );
181 pFxchMan->vDiv = Vec_IntAlloc( 4 );
182
183 pFxchMan->vCubesS = Vec_IntAlloc( 128 );
184 pFxchMan->vPairs = Vec_IntAlloc( 128 );
185 pFxchMan->vCubesToUpdate = Vec_IntAlloc( 64 );
186 pFxchMan->vCubesToRemove = Vec_IntAlloc( 64 );
187 pFxchMan->vSCC = Vec_IntAlloc( 64 );
188
189 return pFxchMan;
190}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Vec_Int_t * vSCC
Definition Fxch.h:124
Vec_Wec_t vCubes
Definition plaFxch.c:46
Vec_Wec_t vPairs
Definition plaFxch.c:55
Vec_Int_t vCubesS
Definition plaFxch.c:58
int nCubesInit
Definition Fxch.h:93
Vec_Int_t * vDiv
Definition Fxch.h:120
Vec_Int_t * vCubesToUpdate
Definition Fxch.h:123
Vec_Int_t * vCubesToRemove
Definition Fxch.h:122
Here is the caller graph for this function:

◆ Fxch_ManComputeLevel()

void Fxch_ManComputeLevel ( Fxch_Man_t * pFxchMan)

Definition at line 338 of file FxchMan.c.

339{
340 Vec_Int_t* vCube;
341 int i,
342 iVar,
343 iFirst = 0;
344
345 iVar = Vec_IntEntry( Vec_WecEntry( pFxchMan->vCubes, 0 ), 0 );
346 pFxchMan->vLevels = Vec_IntStart( pFxchMan->nVars );
347
348 Vec_WecForEachLevel( pFxchMan->vCubes, vCube, i )
349 {
350 if ( iVar != Vec_IntEntry( vCube, 0 ) )
351 {
352 Vec_IntAddToEntry( pFxchMan->vLevels, iVar, i - iFirst );
353 iVar = Vec_IntEntry( vCube, 0 );
354 iFirst = i;
355 }
356 Vec_IntUpdateEntry( pFxchMan->vLevels, iVar, Fxch_ManComputeLevelCube( pFxchMan, vCube ) );
357 }
358}
int Fxch_ManComputeLevelCube(Fxch_Man_t *pFxchMan, Vec_Int_t *vCube)
Definition FxchMan.c:325
int nVars
Definition plaFxch.c:65
Vec_Int_t * vLevels
Definition Fxch.h:108
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_ManComputeLevelCube()

int Fxch_ManComputeLevelCube ( Fxch_Man_t * pFxchMan,
Vec_Int_t * vCube )

Definition at line 325 of file FxchMan.c.

327{
328 int k,
329 Lit,
330 Level = 0;
331
332 Vec_IntForEachEntryStart( vCube, Lit, k, 1 )
333 Level = Abc_MaxInt( Level, Vec_IntEntry( pFxchMan->vLevels, Abc_Lit2Var( Lit ) ) );
334
335 return Level;
336}
Here is the caller graph for this function:

◆ Fxch_ManComputeLevelDiv()

int Fxch_ManComputeLevelDiv ( Fxch_Man_t * pFxchMan,
Vec_Int_t * vCubeFree )

Definition at line 312 of file FxchMan.c.

314{
315 int i,
316 Lit,
317 Level = 0;
318
319 Vec_IntForEachEntry( vCubeFree, Lit, i )
320 Level = Abc_MaxInt( Level, Vec_IntEntry( pFxchMan->vLevels, Abc_Lit2Var( Abc_Lit2Var( Lit ) ) ) );
321
322 return Abc_MinInt( Level, 800 );
323}
Here is the caller graph for this function:

◆ Fxch_ManDivCreate()

void Fxch_ManDivCreate ( Fxch_Man_t * pFxchMan)

Definition at line 288 of file FxchMan.c.

289{
290 Vec_Int_t* vCube;
291 float Weight;
292 int fAdd = 1,
293 fUpdate = 0,
294 iCube;
295
296 Vec_WecForEachLevel( pFxchMan->vCubes, vCube, iCube )
297 {
298 Fxch_ManDivSingleCube( pFxchMan, iCube, fAdd, fUpdate );
299 Fxch_ManDivDoubleCube( pFxchMan, iCube, fAdd, fUpdate );
300 }
301
302 pFxchMan->vDivPrio = Vec_QueAlloc( Vec_FltSize( pFxchMan->vDivWeights ) );
303 Vec_QueSetPriority( pFxchMan->vDivPrio, Vec_FltArrayP( pFxchMan->vDivWeights ) );
304 Vec_FltForEachEntry( pFxchMan->vDivWeights, Weight, iCube )
305 {
306 if ( Weight > 0.0 )
307 Vec_QuePush( pFxchMan->vDivPrio, iCube );
308 }
309}
#define Vec_FltForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecFlt.h:54
Here is the caller graph for this function:

◆ Fxch_ManFree()

void Fxch_ManFree ( Fxch_Man_t * pFxchMan)

Definition at line 192 of file FxchMan.c.

193{
194 Vec_WecFree( pFxchMan->vLits );
195 Vec_IntFree( pFxchMan->vLitCount );
196 Vec_IntFree( pFxchMan->vLitHashKeys );
197 Hsh_VecManStop( pFxchMan->pDivHash );
198 Vec_FltFree( pFxchMan->vDivWeights );
199 Vec_QueFree( pFxchMan->vDivPrio );
200 Vec_WecFree( pFxchMan->vDivCubePairs );
201 Vec_IntFree( pFxchMan->vLevels );
202
203 Vec_IntFree( pFxchMan->vCubeFree );
204 Vec_IntFree( pFxchMan->vDiv );
205
206 Vec_IntFree( pFxchMan->vCubesS );
207 Vec_IntFree( pFxchMan->vPairs );
208 Vec_IntFree( pFxchMan->vCubesToUpdate );
209 Vec_IntFree( pFxchMan->vCubesToRemove );
210 Vec_IntFree( pFxchMan->vSCC );
211
212 ABC_FREE( pFxchMan );
213}
#define ABC_FREE(obj)
Definition abc_global.h:267
Vec_Wec_t vLits
Definition plaFxch.c:48
Vec_Int_t * vLitHashKeys
Definition Fxch.h:101
Vec_Int_t * vLitCount
Definition Fxch.h:100
Here is the caller graph for this function:

◆ Fxch_ManGenerateLitHashKeys()

void Fxch_ManGenerateLitHashKeys ( Fxch_Man_t * pFxchMan)

Definition at line 255 of file FxchMan.c.

256{
257 int i;
258 /* Generates the random number which will be used for hashing cubes */
259 Gia_ManRandom( 1 );
260 pFxchMan->vLitHashKeys = Vec_IntAlloc( ( 2 * pFxchMan->nVars ) );
261 for ( i = 0; i < (2 * pFxchMan->nVars); i++ )
262 Vec_IntPush( pFxchMan->vLitHashKeys, Gia_ManRandom(0) & 0x3FFFFFF );
263}
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition giaUtil.c:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_ManMapLiteralsIntoCubes()

void Fxch_ManMapLiteralsIntoCubes ( Fxch_Man_t * pFxchMan,
int nVars )

Definition at line 215 of file FxchMan.c.

217{
218
219 Vec_Int_t* vCube;
220 int i, k,
221 Lit,
222 Count;
223
224 pFxchMan->nVars = 0;
225 pFxchMan->nLits = 0;
226 Vec_WecForEachLevel( pFxchMan->vCubes, vCube, i )
227 {
228 assert( Vec_IntSize(vCube) > 0 );
229 pFxchMan->nVars = Abc_MaxInt( pFxchMan->nVars, Vec_IntEntry( vCube, 0 ) );
230 pFxchMan->nLits += Vec_IntSize(vCube) - 1;
231 Vec_IntForEachEntryStart( vCube, Lit, k, 1 )
232 pFxchMan->nVars = Abc_MaxInt( pFxchMan->nVars, Abc_Lit2Var( Lit ) );
233 }
234
235 assert( pFxchMan->nVars < nVars );
236 pFxchMan->nVars = nVars;
237
238 /* Count the number of time each literal appears on the SOP */
239 pFxchMan->vLitCount = Vec_IntStart( 2 * pFxchMan->nVars );
240 Vec_WecForEachLevel( pFxchMan->vCubes, vCube, i )
241 Vec_IntForEachEntryStart( vCube, Lit, k, 1 )
242 Vec_IntAddToEntry( pFxchMan->vLitCount, Lit, 1 );
243
244 /* Allocate space to the array of arrays wich maps Literals into cubes which uses them */
245 pFxchMan->vLits = Vec_WecStart( 2 * pFxchMan->nVars );
246 Vec_IntForEachEntry( pFxchMan->vLitCount, Count, Lit )
247 Vec_IntGrow( Vec_WecEntry( pFxchMan->vLits, Lit ), Count );
248
249 /* Maps Literals into cubes which uses them */
250 Vec_WecForEachLevel( pFxchMan->vCubes, vCube, i )
251 Vec_IntForEachEntryStart( vCube, Lit, k, 1 )
252 Vec_WecPush( pFxchMan->vLits, Lit, i );
253}
Here is the caller graph for this function:

◆ Fxch_ManPrintDivs()

void Fxch_ManPrintDivs ( Fxch_Man_t * pFxchMan)

Definition at line 764 of file FxchMan.c.

765{
766 int iDiv;
767
768 for ( iDiv = 0; iDiv < Vec_FltSize( pFxchMan->vDivWeights ); iDiv++ )
769 Fxch_DivPrint( pFxchMan, iDiv );
770}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_ManPrintStats()

void Fxch_ManPrintStats ( Fxch_Man_t * pFxchMan)

Definition at line 772 of file FxchMan.c.

773{
774 printf( "Cubes =%8d ", Vec_WecSizeUsed( pFxchMan->vCubes ) );
775 printf( "Lits =%8d ", Vec_WecSizeUsed( pFxchMan->vLits ) );
776 printf( "Divs =%8d ", Hsh_VecSize( pFxchMan->pDivHash ) );
777 printf( "Divs+ =%8d ", Vec_QueSize( pFxchMan->vDivPrio ) );
778 printf( "Extr =%7d \n", pFxchMan->nExtDivs );
779}
int nExtDivs
Definition Fxch.h:133
Here is the caller graph for this function:

◆ Fxch_ManSCHashTablesFree()

void Fxch_ManSCHashTablesFree ( Fxch_Man_t * pFxchMan)

Definition at line 283 of file FxchMan.c.

284{
286}
void Fxch_SCHashTableDelete(Fxch_SCHashTable_t *)
Fxch_SCHashTable_t * pSCHashTable
Definition Fxch.h:97
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_ManSCHashTablesInit()

void Fxch_ManSCHashTablesInit ( Fxch_Man_t * pFxchMan)

Definition at line 265 of file FxchMan.c.

266{
267 Vec_Wec_t* vCubes = pFxchMan->vCubes;
268 Vec_Int_t* vCube;
269 int iCube,
270 nTotalHashed = 0;
271
272 Vec_WecForEachLevel( vCubes, vCube, iCube )
273 {
274 int nLits = Vec_IntSize( vCube ) - 1,
275 nSubCubes = nLits <= 2? nLits + 1: ( nLits * nLits + nLits ) / 2;
276
277 nTotalHashed += nSubCubes + 1;
278 }
279
280 pFxchMan->pSCHashTable = Fxch_SCHashTableCreate( pFxchMan, nTotalHashed );
281}
Fxch_SCHashTable_t * Fxch_SCHashTableCreate(Fxch_Man_t *pFxchMan, int nEntries)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_ManUpdate()

void Fxch_ManUpdate ( Fxch_Man_t * p,
int iDiv )

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

Synopsis [Updates the data-structure when one divisor is selected.]

Description []

SideEffects []

SeeAlso []

Definition at line 617 of file plaFxch.c.

618{
619 Vec_Int_t * vCube1, * vCube2, * vLitP, * vLitN;
620 //int nLitsNew = p->nLits - (int)Vec_FltEntry(&p->vWeights, iDiv);
621 int i, Lit0, Lit1, hCube1, hCube2, iVarNew;
622 //float Diff = Vec_FltEntry(&p->vWeights, iDiv) - (float)((int)Vec_FltEntry(&p->vWeights, iDiv));
623 //assert( Diff > 0.0 && Diff < 1.0 );
624
625 // get the divisor and select pivot variables
626 Vec_IntPush( &p->vRands, Gia_ManRandom(0) & 0x3FFFFFF );
627 Vec_IntPush( &p->vRands, Gia_ManRandom(0) & 0x3FFFFFF );
628 Lit0 = Hash_IntObjData0( p->vHash, iDiv );
629 Lit1 = Hash_IntObjData1( p->vHash, iDiv );
630 assert( Lit0 >= 0 && Lit1 >= 0 && Lit0 < Lit1 );
631 Vec_WrdPush( &p->vDivs, ((word)Lit1 << 32) | (word)Lit0 );
632
633 // if the input cover is not prime, it may happen that we are extracting divisor (x + !x)
634 // although it is not strictly correct, it seems to be fine to just skip such divisors
635// if ( Abc_Lit2Var(Lit0) == Abc_Lit2Var(Lit1) && Vec_IntSize(Hsh_VecReadEntry(p->vHash, iDiv)) == 2 )
636// return;
637
638 // collect single-cube-divisor cubes
639 vLitP = Vec_WecEntry(&p->vLits, Lit0);
640 vLitN = Vec_WecEntry(&p->vLits, Lit1);
641 Fxch_CompressCubes( p, vLitP );
642 Fxch_CompressCubes( p, vLitN );
643// Fxch_CollectSingles( vLitP, vLitN, &p->vCubesS );
644// assert( Vec_IntSize(&p->vCubesS) % 2 == 0 );
645 Vec_IntTwoRemoveCommon( vLitP, vLitN, &p->vCubesS );
646 Fxch_FilterCubes( p, &p->vCubesS, Lit0, Lit1 );
647
648 // collect double-cube-divisor cube pairs
649 Fxch_CollectDoubles( p, Vec_WecEntry(&p->vPairs, iDiv), &p->vCubesD, Abc_LitNot(Lit0), Abc_LitNot(Lit1) );
650 assert( Vec_IntSize(&p->vCubesD) % 2 == 0 );
651 Vec_IntUniqifyPairs( &p->vCubesD );
652 assert( Vec_IntSize(&p->vCubesD) % 2 == 0 );
653
654 // subtract cost of single-cube divisors
655// Vec_IntForEachEntryDouble( &p->vCubesS, hCube1, hCube2, i )
656 Vec_IntForEachEntry( &p->vCubesS, hCube1, i )
657 Fxch_TabSingleDivisors( p, Pla_CubeNum(hCube1), 0 ); // remove - update
658 Vec_IntForEachEntryDouble( &p->vCubesD, hCube1, hCube2, i )
659 Fxch_TabSingleDivisors( p, Pla_CubeNum(hCube1), 0 ), // remove - update
660 Fxch_TabSingleDivisors( p, Pla_CubeNum(hCube2), 0 ); // remove - update
661
662 // subtract cost of double-cube divisors
663// Vec_IntForEachEntryDouble( &p->vCubesS, hCube1, hCube2, i )
664 Vec_IntForEachEntry( &p->vCubesS, hCube1, i )
665 {
666 //printf( "%d ", Pla_CubeNum(hCube1) );
667 Fxch_TabDoubleDivisors( p, Pla_CubeNum(hCube1), 0 ); // remove - update
668 }
669 //printf( "\n" );
670
671 Vec_IntForEachEntryDouble( &p->vCubesD, hCube1, hCube2, i )
672 {
673 //printf( "%d ", Pla_CubeNum(hCube1) );
674 //printf( "%d ", Pla_CubeNum(hCube2) );
675 Fxch_TabDoubleDivisors( p, Pla_CubeNum(hCube1), 0 ), // remove - update
676 Fxch_TabDoubleDivisors( p, Pla_CubeNum(hCube2), 0 ); // remove - update
677 }
678 //printf( "\n" );
679
680 // create new literals
681 p->nLits += 2;
682 iVarNew = Vec_WecSize( &p->vLits ) / 2;
683 vLitP = Vec_WecPushLevel( &p->vLits );
684 vLitN = Vec_WecPushLevel( &p->vLits );
685 vLitP = Vec_WecEntry( &p->vLits, Vec_WecSize(&p->vLits) - 2 );
686 // update single-cube divisor cubes
687// Vec_IntForEachEntryDouble( &p->vCubesS, hCube1, hCube2, i )
688 Vec_IntForEachEntry( &p->vCubesS, hCube1, i )
689 {
690// int Lit0s, Lit1s;
691 vCube1 = Fxch_ManCube( p, hCube1 );
692// Lit0s = Vec_IntEntry(vCube1, Pla_CubeLit(hCube1));
693// Lit1s = Vec_IntEntry(vCube1, Pla_CubeLit(hCube2));
694// assert( Pla_CubeNum(hCube1) == Pla_CubeNum(hCube2) );
695// assert( Vec_IntEntry(vCube1, Pla_CubeLit(hCube1)) == Lit0 );
696// assert( Vec_IntEntry(vCube1, Pla_CubeLit(hCube2)) == Lit1 );
697 Fxch_CompressLiterals( vCube1, Lit0, Lit1 );
698// Vec_IntPush( vLitP, Pla_CubeHandle(Pla_CubeNum(hCube1), Vec_IntSize(vCube1)) );
699 Vec_IntPush( vLitP, Pla_CubeNum(hCube1) );
700 Vec_IntPush( vCube1, Abc_Var2Lit(iVarNew, 0) );
701
702 //if ( Pla_CubeNum(hCube1) == 3 )
703 // printf( "VecSize = %d\n", Vec_IntSize(vCube1) );
704
705 p->nLits--;
706 }
707 // update double-cube divisor cube pairs
708 Vec_IntForEachEntryDouble( &p->vCubesD, hCube1, hCube2, i )
709 {
710 vCube1 = Fxch_ManCube( p, hCube1 );
711 vCube2 = Fxch_ManCube( p, hCube2 );
712 assert( Vec_IntEntry(vCube1, Pla_CubeLit(hCube1)) == Abc_LitNot(Lit0) );
713 assert( Vec_IntEntry(vCube2, Pla_CubeLit(hCube2)) == Abc_LitNot(Lit1) );
714 Fxch_CompressLiterals2( vCube1, Pla_CubeLit(hCube1), -1 );
715// Vec_IntPush( vLitN, Pla_CubeHandle(Pla_CubeNum(hCube1), Vec_IntSize(vCube1)) );
716 Vec_IntPush( vLitN, Pla_CubeNum(hCube1) );
717 Vec_IntPush( vCube1, Abc_Var2Lit(iVarNew, 1) );
718 p->nLits -= Vec_IntSize(vCube2);
719
720 //if ( Pla_CubeNum(hCube1) == 3 )
721 // printf( "VecSize = %d\n", Vec_IntSize(vCube1) );
722
723 // remove second cube
724 Vec_IntClear( vCube2 );
725 }
726 Vec_IntSort( vLitN, 0 );
727 Vec_IntSort( vLitP, 0 );
728
729 // add cost of single-cube divisors
730// Vec_IntForEachEntryDouble( &p->vCubesS, hCube1, hCube2, i )
731 Vec_IntForEachEntry( &p->vCubesS, hCube1, i )
732 Fxch_TabSingleDivisors( p, Pla_CubeNum(hCube1), 1 ); // add - update
733 Vec_IntForEachEntryDouble( &p->vCubesD, hCube1, hCube2, i )
734 Fxch_TabSingleDivisors( p, Pla_CubeNum(hCube1), 1 ); // add - update
735
736 // add cost of double-cube divisors
737// Vec_IntForEachEntryDouble( &p->vCubesS, hCube1, hCube2, i )
738 Vec_IntForEachEntry( &p->vCubesS, hCube1, i )
739 Fxch_TabDoubleDivisors( p, Pla_CubeNum(hCube1), 1 ); // add - update
740 Vec_IntForEachEntryDouble( &p->vCubesD, hCube1, hCube2, i )
741 Fxch_TabDoubleDivisors( p, Pla_CubeNum(hCube1), 1 ); // add - update
742
743 // check predicted improvement: (new SOP lits == old SOP lits - divisor weight)
744 //assert( p->nLits == nLitsNew );
745}
Cube * p
Definition exorList.c:222
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int Fxch_TabDoubleDivisors(Fxch_Man_t *p, int iCube, int fAdd)
Definition plaFxch.c:567
int Fxch_TabSingleDivisors(Fxch_Man_t *p, int iCube, int fAdd)
Definition plaFxch.c:550
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fxch_SCHashTableCreate()

Fxch_SCHashTable_t * Fxch_SCHashTableCreate ( Fxch_Man_t * pFxchMan,
int nEntries )

Definition at line 93 of file FxchSCHashTable.c.

95{
97 int nBits = Abc_Base2Log( nEntries + 1 );
98
99
100 pSCHashTable->pFxchMan = pFxchMan;
101 pSCHashTable->SizeMask = (1 << nBits) - 1;
102 pSCHashTable->pBins = ABC_CALLOC( Fxch_SCHashTable_Entry_t, pSCHashTable->SizeMask + 1 );
103
104 return pSCHashTable;
105}
struct Fxch_SCHashTable_t_ Fxch_SCHashTable_t
Definition Fxch.h:39
struct Fxch_SCHashTable_Entry_t_ Fxch_SCHashTable_Entry_t
Definition Fxch.h:40
Fxch_SCHashTable_Entry_t * pBins
Definition Fxch.h:80
unsigned int SizeMask
Definition Fxch.h:82
Fxch_Man_t * pFxchMan
Definition Fxch.h:78
Here is the caller graph for this function:

◆ Fxch_SCHashTableDelete()

void Fxch_SCHashTableDelete ( Fxch_SCHashTable_t * pSCHashTable)

Definition at line 107 of file FxchSCHashTable.c.

108{
109 unsigned i;
110 for ( i = 0; i <= pSCHashTable->SizeMask; i++ )
111 ABC_FREE( pSCHashTable->pBins[i].vSCData );
112 Vec_IntErase( &pSCHashTable->vSubCube0 );
113 Vec_IntErase( &pSCHashTable->vSubCube1 );
114 ABC_FREE( pSCHashTable->pBins );
115 ABC_FREE( pSCHashTable );
116}
Fxch_SubCube_t * vSCData
Definition Fxch.h:71
Vec_Int_t vSubCube1
Definition Fxch.h:86
Vec_Int_t vSubCube0
Definition Fxch.h:85
Here is the caller graph for this function:

◆ Fxch_SCHashTableInsert()

int Fxch_SCHashTableInsert ( Fxch_SCHashTable_t * pSCHashTable,
Vec_Wec_t * vCubes,
uint32_t SubCubeID,
uint32_t iCube,
uint32_t iLit0,
uint32_t iLit1,
char fUpdate )

Definition at line 179 of file FxchSCHashTable.c.

186{
187 int iNewEntry;
188 int Pairs = 0;
189 uint32_t BinID;
191 Fxch_SubCube_t* pNewEntry;
192 int iEntry;
193
194 MurmurHash3_x86_32( ( void* ) &SubCubeID, sizeof( int ), 0x9747b28c, &BinID);
195 pBin = Fxch_SCHashTableBin( pSCHashTable, BinID );
196
197 if ( pBin->vSCData == NULL )
198 {
199 pBin->vSCData = ABC_CALLOC( Fxch_SubCube_t, 16 );
200 pBin->Size = 0;
201 pBin->Cap = 16;
202 }
203 else if ( pBin->Size == pBin->Cap )
204 {
205 assert(pBin->Cap <= 0xAAAA);
206 pBin->Cap = ( pBin->Cap >> 1 ) * 3;
207 pBin->vSCData = ABC_REALLOC( Fxch_SubCube_t, pBin->vSCData, pBin->Cap );
208 }
209
210 iNewEntry = pBin->Size++;
211 pBin->vSCData[iNewEntry].Id = SubCubeID;
212 pBin->vSCData[iNewEntry].iCube = iCube;
213 pBin->vSCData[iNewEntry].iLit0 = iLit0;
214 pBin->vSCData[iNewEntry].iLit1 = iLit1;
215 pSCHashTable->nEntries++;
216
217 if ( pBin->Size == 1 )
218 return 0;
219
220 pNewEntry = &( pBin->vSCData[iNewEntry] );
221 for ( iEntry = 0; iEntry < (int)pBin->Size - 1; iEntry++ )
222 {
223 Fxch_SubCube_t* pEntry = &( pBin->vSCData[iEntry] );
224 int* pOutputID0 = Vec_IntEntryP( pSCHashTable->pFxchMan->vOutputID, pEntry->iCube * pSCHashTable->pFxchMan->nSizeOutputID );
225 int* pOutputID1 = Vec_IntEntryP( pSCHashTable->pFxchMan->vOutputID, pNewEntry->iCube * pSCHashTable->pFxchMan->nSizeOutputID );
226 int Result = 0;
227 int Base;
228 int iNewDiv = -1, i, z;
229
230 if ( (pEntry->iLit1 != 0 && pNewEntry->iLit1 == 0) || (pEntry->iLit1 == 0 && pNewEntry->iLit1 != 0) )
231 continue;
232
233 if ( !Fxch_SCHashTableEntryCompare( pSCHashTable, vCubes, pEntry, pNewEntry ) )
234 continue;
235
236 if ( ( pEntry->iLit0 == 0 ) || ( pNewEntry->iLit0 == 0 ) )
237 {
238 Vec_Int_t* vCube0 = Fxch_ManGetCube( pSCHashTable->pFxchMan, pEntry->iCube ),
239 * vCube1 = Fxch_ManGetCube( pSCHashTable->pFxchMan, pNewEntry->iCube );
240
241 if ( Vec_IntSize( vCube0 ) > Vec_IntSize( vCube1 ) )
242 {
243 Vec_IntPush( pSCHashTable->pFxchMan->vSCC, pEntry->iCube );
244 Vec_IntPush( pSCHashTable->pFxchMan->vSCC, pNewEntry->iCube );
245 }
246 else
247 {
248 Vec_IntPush( pSCHashTable->pFxchMan->vSCC, pNewEntry->iCube );
249 Vec_IntPush( pSCHashTable->pFxchMan->vSCC, pEntry->iCube );
250 }
251
252 continue;
253 }
254
255 Base = Fxch_DivCreate( pSCHashTable->pFxchMan, pEntry, pNewEntry );
256
257 if ( Base < 0 )
258 continue;
259
260 for ( i = 0; i < pSCHashTable->pFxchMan->nSizeOutputID; i++ )
261 Result += Fxch_CountOnes( pOutputID0[i] & pOutputID1[i] );
262
263 for ( z = 0; z < Result; z++ )
264 iNewDiv = Fxch_DivAdd( pSCHashTable->pFxchMan, fUpdate, 0, Base );
265
266 Vec_WecPush( pSCHashTable->pFxchMan->vDivCubePairs, iNewDiv, pEntry->iCube );
267 Vec_WecPush( pSCHashTable->pFxchMan->vDivCubePairs, iNewDiv, pNewEntry->iCube );
268
269 Pairs++;
270 }
271
272 return Pairs;
273}
int Fxch_DivAdd(Fxch_Man_t *pFxchMan, int fUpdate, int fSingleCube, int fBase)
Definition FxchDiv.c:228
struct Fxch_SubCube_t_ Fxch_SubCube_t
Definition Fxch.h:38
unsigned int uint32_t
Definition Fxch.h:32
int Fxch_DivCreate(Fxch_Man_t *pFxchMan, Fxch_SubCube_t *pSubCube0, Fxch_SubCube_t *pSubCube1)
Definition FxchDiv.c:112
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
Vec_Int_t * vOutputID
Definition Fxch.h:112
int nSizeOutputID
Definition Fxch.h:114
uint32_t Cap
Definition Fxch.h:73
uint32_t Size
Definition Fxch.h:72
unsigned int nEntries
Definition Fxch.h:81
uint32_t Id
Definition Fxch.h:61
Here is the call graph for this function:

◆ Fxch_SCHashTableMemory()

unsigned int Fxch_SCHashTableMemory ( Fxch_SCHashTable_t * pHashTable)

Definition at line 362 of file FxchSCHashTable.c.

363{
364 unsigned int Memory = sizeof ( Fxch_SCHashTable_t );
365
366 Memory += sizeof( Fxch_SubCube_t ) * ( pHashTable->SizeMask + 1 );
367
368 return Memory;
369}
Here is the caller graph for this function:

◆ Fxch_SCHashTablePrint()

void Fxch_SCHashTablePrint ( Fxch_SCHashTable_t * pHashTable)

Definition at line 371 of file FxchSCHashTable.c.

372{
373 int Memory;
374 printf( "SubCube Hash Table at %p\n", ( void* )pHashTable );
375 printf("%20s %20s\n", "nEntries",
376 "Memory Usage (MB)" );
377
378 Memory = Fxch_SCHashTableMemory( pHashTable );
379 printf("%20d %18.2f\n", pHashTable->nEntries,
380 ( ( double ) Memory / 1048576 ) );
381}
unsigned int Fxch_SCHashTableMemory(Fxch_SCHashTable_t *pHashTable)
Here is the call graph for this function:

◆ Fxch_SCHashTableRemove()

int Fxch_SCHashTableRemove ( Fxch_SCHashTable_t * pSCHashTable,
Vec_Wec_t * vCubes,
uint32_t SubCubeID,
uint32_t iCube,
uint32_t iLit0,
uint32_t iLit1,
char fUpdate )

Definition at line 275 of file FxchSCHashTable.c.

282{
283 int iEntry;
284 int Pairs = 0;
285 uint32_t BinID;
287 Fxch_SubCube_t* pEntry;
288 int idx;
289
290 MurmurHash3_x86_32( ( void* ) &SubCubeID, sizeof( int ), 0x9747b28c, &BinID);
291
292 pBin = Fxch_SCHashTableBin( pSCHashTable, BinID );
293
294 if ( pBin->Size == 1 )
295 {
296 pBin->Size = 0;
297 return 0;
298 }
299
300 for ( iEntry = 0; iEntry < (int)pBin->Size; iEntry++ )
301 if ( pBin->vSCData[iEntry].iCube == iCube )
302 break;
303
304 assert( ( iEntry != (int)pBin->Size ) && ( pBin->Size != 0 ) );
305
306 pEntry = &( pBin->vSCData[iEntry] );
307 for ( idx = 0; idx < (int)pBin->Size; idx++ )
308 if ( idx != iEntry )
309 {
310 int Base,
311 iDiv = -1;
312
313 int i, z,
314 iCube0,
315 iCube1;
316
317 Fxch_SubCube_t* pNextEntry = &( pBin->vSCData[idx] );
318 Vec_Int_t* vDivCubePairs;
319 int* pOutputID0 = Vec_IntEntryP( pSCHashTable->pFxchMan->vOutputID, pEntry->iCube * pSCHashTable->pFxchMan->nSizeOutputID );
320 int* pOutputID1 = Vec_IntEntryP( pSCHashTable->pFxchMan->vOutputID, pNextEntry->iCube * pSCHashTable->pFxchMan->nSizeOutputID );
321 int Result = 0;
322
323 if ( (pEntry->iLit1 != 0 && pNextEntry->iLit1 == 0) || (pEntry->iLit1 == 0 && pNextEntry->iLit1 != 0) )
324 continue;
325
326 if ( !Fxch_SCHashTableEntryCompare( pSCHashTable, vCubes, pEntry, pNextEntry )
327 || pEntry->iLit0 == 0
328 || pNextEntry->iLit0 == 0 )
329 continue;
330
331 Base = Fxch_DivCreate( pSCHashTable->pFxchMan, pNextEntry, pEntry );
332
333 if ( Base < 0 )
334 continue;
335
336 for ( i = 0; i < pSCHashTable->pFxchMan->nSizeOutputID; i++ )
337 Result += Fxch_CountOnes( pOutputID0[i] & pOutputID1[i] );
338
339 for ( z = 0; z < Result; z++ )
340 iDiv = Fxch_DivRemove( pSCHashTable->pFxchMan, fUpdate, 0, Base );
341
342 vDivCubePairs = Vec_WecEntry( pSCHashTable->pFxchMan->vDivCubePairs, iDiv );
343 Vec_IntForEachEntryDouble( vDivCubePairs, iCube0, iCube1, i )
344 if ( ( iCube0 == (int)pNextEntry->iCube && iCube1 == (int)pEntry->iCube ) ||
345 ( iCube0 == (int)pEntry->iCube && iCube1 == (int)pNextEntry->iCube ) )
346 {
347 Vec_IntDrop( vDivCubePairs, i+1 );
348 Vec_IntDrop( vDivCubePairs, i );
349 }
350 if ( Vec_IntSize( vDivCubePairs ) == 0 )
351 Vec_IntErase( vDivCubePairs );
352
353 Pairs++;
354 }
355
356 memmove(pBin->vSCData + iEntry, pBin->vSCData + iEntry + 1, (pBin->Size - iEntry - 1) * sizeof(*pBin->vSCData));
357 pBin->Size -= 1;
358
359 return Pairs;
360}
int Fxch_DivRemove(Fxch_Man_t *pFxchMan, int fUpdate, int fSingleCube, int fBase)
Definition FxchDiv.c:291
char * memmove()
Here is the call graph for this function:

Variable Documentation

◆ uint8_t

ABC_NAMESPACE_HEADER_START typedef unsigned char uint8_t

CFile****************************************************************

FileName [ Fxch.h ]

PackageName [ Fast eXtract with Cube Hashing (FXCH) ]

Synopsis [ External declarations of fast extract with cube hashing. ]

Author [ Bruno Schmitt - boschmitt at inf.ufrgs.br ]

Affiliation [ UFRGS ]

Date [ Ver. 1.0. Started - March 6, 2016. ]

Revision []

Definition at line 31 of file Fxch.h.