ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraigUtil.c File Reference
#include "fraigInt.h"
#include <limits.h>
Include dependency graph for fraigUtil.c:

Go to the source code of this file.

Functions

Fraig_NodeVec_tFraig_Dfs (Fraig_Man_t *pMan, int fEquiv)
 FUNCTION DEFINITIONS ///.
 
Fraig_NodeVec_tFraig_DfsOne (Fraig_Man_t *pMan, Fraig_Node_t *pNode, int fEquiv)
 
Fraig_NodeVec_tFraig_DfsNodes (Fraig_Man_t *pMan, Fraig_Node_t **ppNodes, int nNodes, int fEquiv)
 
int Fraig_CountNodes (Fraig_Man_t *pMan, int fEquiv)
 
int Fraig_CheckTfi (Fraig_Man_t *pMan, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
int Fraig_CheckTfi2 (Fraig_Man_t *pMan, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
void Fraig_ManMarkRealFanouts (Fraig_Man_t *p)
 
int Fraig_BitStringCountOnes (unsigned *pString, int nWords)
 
int Fraig_ManCheckConsistency (Fraig_Man_t *p)
 
void Fraig_PrintNode (Fraig_Man_t *p, Fraig_Node_t *pNode)
 
void Fraig_PrintBinary (FILE *pFile, unsigned *pSign, int nBits)
 
int Fraig_GetMaxLevel (Fraig_Man_t *pMan)
 
int Fraig_MappingUpdateLevel_rec (Fraig_Man_t *pMan, Fraig_Node_t *pNode, int fMaximum)
 
void Fraig_MappingSetChoiceLevels (Fraig_Man_t *pMan, int fMaximum)
 
void Fraig_ManReportChoices (Fraig_Man_t *pMan)
 
int Fraig_NodeIsExorType (Fraig_Node_t *pNode)
 
int Fraig_NodeIsMuxType (Fraig_Node_t *pNode)
 
int Fraig_NodeIsExor (Fraig_Node_t *pNode)
 
Fraig_Node_tFraig_NodeRecognizeMux (Fraig_Node_t *pNode, Fraig_Node_t **ppNodeT, Fraig_Node_t **ppNodeE)
 
int Fraig_ManCountExors (Fraig_Man_t *pMan)
 
int Fraig_ManCountMuxes (Fraig_Man_t *pMan)
 
int Fraig_NodeSimsContained (Fraig_Man_t *pMan, Fraig_Node_t *pNode1, Fraig_Node_t *pNode2)
 
int Fraig_CountPis (Fraig_Man_t *p, Msat_IntVec_t *vVarNums)
 
int Fraig_ManPrintRefs (Fraig_Man_t *pMan)
 
int Fraig_NodeIsInSupergate (Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
void Fraig_CollectSupergate_rec (Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, int fFirst, int fStopAtMux)
 
Fraig_NodeVec_tFraig_CollectSupergate (Fraig_Node_t *pNode, int fStopAtMux)
 
void Fraig_ManIncrementTravId (Fraig_Man_t *pMan)
 
void Fraig_NodeSetTravIdCurrent (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_NodeIsTravIdCurrent (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_NodeIsTravIdPrevious (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 

Function Documentation

◆ Fraig_BitStringCountOnes()

int Fraig_BitStringCountOnes ( unsigned * pString,
int nWords )

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

Synopsis [Creates the constant 1 node.]

Description []

SideEffects []

SeeAlso []

Definition at line 288 of file fraigUtil.c.

289{
290 unsigned char * pSuppBytes = (unsigned char *)pString;
291 int i, nOnes, nBytes = sizeof(unsigned) * nWords;
292 // count the number of ones in the simulation vector
293 for ( i = nOnes = 0; i < nBytes; i++ )
294 nOnes += bit_count[pSuppBytes[i]];
295 return nOnes;
296}
int nWords
Definition abcNpn.c:127
Here is the caller graph for this function:

◆ Fraig_CheckTfi()

int Fraig_CheckTfi ( Fraig_Man_t * pMan,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew )

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

Synopsis [Returns 1 if pOld is in the TFI of pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file fraigUtil.c.

174{
175 assert( !Fraig_IsComplement(pOld) );
176 assert( !Fraig_IsComplement(pNew) );
177 pMan->nTravIds++;
178 return Fraig_CheckTfi_rec( pMan, pNew, pOld );
179}
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition fraig.h:107
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Fraig_CheckTfi2()

int Fraig_CheckTfi2 ( Fraig_Man_t * pMan,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew )

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

Synopsis [Returns 1 if pOld is in the TFI of pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 226 of file fraigUtil.c.

227{
228 Fraig_NodeVec_t * vNodes;
229 int RetValue;
230 vNodes = Fraig_DfsOne( pMan, pNew, 1 );
231 RetValue = (pOld->TravId == pMan->nTravIds);
232 Fraig_NodeVecFree( vNodes );
233 return RetValue;
234}
Fraig_NodeVec_t * Fraig_DfsOne(Fraig_Man_t *pMan, Fraig_Node_t *pNode, int fEquiv)
Definition fraigUtil.c:80
void Fraig_NodeVecFree(Fraig_NodeVec_t *p)
Definition fraigVec.c:66
struct Fraig_NodeVecStruct_t_ Fraig_NodeVec_t
Definition fraig.h:42
Here is the call graph for this function:

◆ Fraig_CollectSupergate()

Fraig_NodeVec_t * Fraig_CollectSupergate ( Fraig_Node_t * pNode,
int fStopAtMux )

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

Synopsis [Returns the array of nodes to be combined into one multi-input AND-gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 960 of file fraigUtil.c.

961{
962 Fraig_NodeVec_t * vSuper;
963 vSuper = Fraig_NodeVecAlloc( 8 );
964 Fraig_CollectSupergate_rec( pNode, vSuper, 1, fStopAtMux );
965 return vSuper;
966}
void Fraig_CollectSupergate_rec(Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, int fFirst, int fStopAtMux)
Definition fraigUtil.c:933
Fraig_NodeVec_t * Fraig_NodeVecAlloc(int nCap)
DECLARATIONS ///.
Definition fraigVec.c:43
Here is the call graph for this function:

◆ Fraig_CollectSupergate_rec()

void Fraig_CollectSupergate_rec ( Fraig_Node_t * pNode,
Fraig_NodeVec_t * vSuper,
int fFirst,
int fStopAtMux )

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

Synopsis [Returns the array of nodes to be combined into one multi-input AND-gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 933 of file fraigUtil.c.

934{
935 // if the new node is complemented or a PI, another gate begins
936// if ( Fraig_IsComplement(pNode) || Fraig_NodeIsVar(pNode) || Fraig_NodeIsMuxType(pNode) )
937 if ( (!fFirst && Fraig_Regular(pNode)->nRefs > 1) ||
938 Fraig_IsComplement(pNode) || Fraig_NodeIsVar(pNode) ||
939 (fStopAtMux && Fraig_NodeIsMuxType(pNode)) )
940 {
941 Fraig_NodeVecPushUnique( vSuper, pNode );
942 return;
943 }
944 // go through the branches
945 Fraig_CollectSupergate_rec( pNode->p1, vSuper, 0, fStopAtMux );
946 Fraig_CollectSupergate_rec( pNode->p2, vSuper, 0, fStopAtMux );
947}
int Fraig_NodeIsMuxType(Fraig_Node_t *pNode)
Definition fraigUtil.c:591
#define Fraig_Regular(p)
Definition fraig.h:108
int Fraig_NodeVecPushUnique(Fraig_NodeVec_t *p, Fraig_Node_t *Entry)
Definition fraigVec.c:212
int Fraig_NodeIsVar(Fraig_Node_t *p)
Definition fraigApi.c:152
Fraig_Node_t * p2
Definition fraigInt.h:233
Fraig_Node_t * p1
Definition fraigInt.h:232
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_CountNodes()

int Fraig_CountNodes ( Fraig_Man_t * pMan,
int fEquiv )

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 152 of file fraigUtil.c.

153{
154 Fraig_NodeVec_t * vNodes;
155 int RetValue;
156 vNodes = Fraig_Dfs( pMan, fEquiv );
157 RetValue = vNodes->nSize;
158 Fraig_NodeVecFree( vNodes );
159 return RetValue;
160}
Fraig_NodeVec_t * Fraig_Dfs(Fraig_Man_t *pMan, int fEquiv)
FUNCTION DEFINITIONS ///.
Definition fraigUtil.c:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_CountPis()

int Fraig_CountPis ( Fraig_Man_t * p,
Msat_IntVec_t * vVarNums )

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

Synopsis [Count the number of PI variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 817 of file fraigUtil.c.

818{
819 int * pVars, nVars, i, Counter;
820
821 nVars = Msat_IntVecReadSize(vVarNums);
822 pVars = Msat_IntVecReadArray(vVarNums);
823 Counter = 0;
824 for ( i = 0; i < nVars; i++ )
825 Counter += Fraig_NodeIsVar( p->vNodes->pArray[pVars[i]] );
826 return Counter;
827}
Cube * p
Definition exorList.c:222
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition msatVec.c:217
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_Dfs()

Fraig_NodeVec_t * Fraig_Dfs ( Fraig_Man_t * pMan,
int fEquiv )

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file fraigUtil.c.

59{
60 Fraig_NodeVec_t * vNodes;
61 int i;
62 pMan->nTravIds++;
63 vNodes = Fraig_NodeVecAlloc( 100 );
64 for ( i = 0; i < pMan->vOutputs->nSize; i++ )
65 Fraig_Dfs_rec( pMan, Fraig_Regular(pMan->vOutputs->pArray[i]), vNodes, fEquiv );
66 return vNodes;
67}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_DfsNodes()

Fraig_NodeVec_t * Fraig_DfsNodes ( Fraig_Man_t * pMan,
Fraig_Node_t ** ppNodes,
int nNodes,
int fEquiv )

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file fraigUtil.c.

101{
102 Fraig_NodeVec_t * vNodes;
103 int i;
104 pMan->nTravIds++;
105 vNodes = Fraig_NodeVecAlloc( 100 );
106 for ( i = 0; i < nNodes; i++ )
107 Fraig_Dfs_rec( pMan, Fraig_Regular(ppNodes[i]), vNodes, fEquiv );
108 return vNodes;
109}
Here is the call graph for this function:

◆ Fraig_DfsOne()

Fraig_NodeVec_t * Fraig_DfsOne ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode,
int fEquiv )

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file fraigUtil.c.

81{
82 Fraig_NodeVec_t * vNodes;
83 pMan->nTravIds++;
84 vNodes = Fraig_NodeVecAlloc( 100 );
85 Fraig_Dfs_rec( pMan, Fraig_Regular(pNode), vNodes, fEquiv );
86 return vNodes;
87}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_GetMaxLevel()

int Fraig_GetMaxLevel ( Fraig_Man_t * pMan)

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

Synopsis [Sets up the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 428 of file fraigUtil.c.

429{
430 int nLevelMax, i;
431 nLevelMax = 0;
432 for ( i = 0; i < pMan->vOutputs->nSize; i++ )
433 nLevelMax = nLevelMax > Fraig_Regular(pMan->vOutputs->pArray[i])->Level?
434 nLevelMax : Fraig_Regular(pMan->vOutputs->pArray[i])->Level;
435 return nLevelMax;
436}
Here is the caller graph for this function:

◆ Fraig_ManCheckConsistency()

int Fraig_ManCheckConsistency ( Fraig_Man_t * p)

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

Synopsis [Verify one useful property.]

Description [This procedure verifies one useful property. After the FRAIG construction with choice nodes is over, each primary node should have fanins that are primary nodes. The primary nodes is the one that does not have pNode->pRepr set to point to another node.]

SideEffects []

SeeAlso []

Definition at line 312 of file fraigUtil.c.

313{
314 Fraig_Node_t * pNode;
315 Fraig_NodeVec_t * pVec;
316 int i;
317 pVec = Fraig_Dfs( p, 0 );
318 for ( i = 0; i < pVec->nSize; i++ )
319 {
320 pNode = pVec->pArray[i];
321 if ( Fraig_NodeIsVar(pNode) )
322 {
323 if ( pNode->pRepr )
324 printf( "Primary input %d is a secondary node.\n", pNode->Num );
325 }
326 else if ( Fraig_NodeIsConst(pNode) )
327 {
328 if ( pNode->pRepr )
329 printf( "Constant 1 %d is a secondary node.\n", pNode->Num );
330 }
331 else
332 {
333 if ( pNode->pRepr )
334 printf( "Internal node %d is a secondary node.\n", pNode->Num );
335 if ( Fraig_Regular(pNode->p1)->pRepr )
336 printf( "Internal node %d has first fanin %d that is a secondary node.\n",
337 pNode->Num, Fraig_Regular(pNode->p1)->Num );
338 if ( Fraig_Regular(pNode->p2)->pRepr )
339 printf( "Internal node %d has second fanin %d that is a secondary node.\n",
340 pNode->Num, Fraig_Regular(pNode->p2)->Num );
341 }
342 }
343 Fraig_NodeVecFree( pVec );
344 return 1;
345}
int Fraig_NodeIsConst(Fraig_Node_t *p)
Definition fraigApi.c:151
struct Fraig_NodeStruct_t_ Fraig_Node_t
Definition fraig.h:41
Fraig_Node_t * pRepr
Definition fraigInt.h:242
Fraig_Node_t ** pArray
Definition fraigInt.h:267
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManCountExors()

int Fraig_ManCountExors ( Fraig_Man_t * pMan)

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

Synopsis [Counts the number of EXOR type nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 742 of file fraigUtil.c.

743{
744 int i, nExors;
745 nExors = 0;
746 for ( i = 0; i < pMan->vNodes->nSize; i++ )
747 nExors += Fraig_NodeIsExorType( pMan->vNodes->pArray[i] );
748 return nExors;
749
750}
int Fraig_NodeIsExorType(Fraig_Node_t *pNode)
Definition fraigUtil.c:558
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManCountMuxes()

int Fraig_ManCountMuxes ( Fraig_Man_t * pMan)

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

Synopsis [Counts the number of EXOR type nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 763 of file fraigUtil.c.

764{
765 int i, nMuxes;
766 nMuxes = 0;
767 for ( i = 0; i < pMan->vNodes->nSize; i++ )
768 nMuxes += Fraig_NodeIsMuxType( pMan->vNodes->pArray[i] );
769 return nMuxes;
770
771}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManIncrementTravId()

void Fraig_ManIncrementTravId ( Fraig_Man_t * pMan)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 980 of file fraigUtil.c.

981{
982 pMan->nTravIds2++;
983}
Here is the caller graph for this function:

◆ Fraig_ManMarkRealFanouts()

void Fraig_ManMarkRealFanouts ( Fraig_Man_t * p)

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

Synopsis [Sets the number of fanouts (none, one, or many).]

Description [This procedure collects the nodes reachable from the POs of the AIG and sets the type of fanout counter (none, one, or many) for each node. This procedure is useful to determine fanout-free cones of AND-nodes, which is helpful for rebalancing the AIG (see procedure Fraig_ManRebalance, or something like that).]

SideEffects []

SeeAlso []

Definition at line 251 of file fraigUtil.c.

252{
253 Fraig_NodeVec_t * vNodes;
254 Fraig_Node_t * pNodeR;
255 int i;
256 // collect the nodes reachable
257 vNodes = Fraig_Dfs( p, 0 );
258 // clean the fanouts field
259 for ( i = 0; i < vNodes->nSize; i++ )
260 {
261 vNodes->pArray[i]->nFanouts = 0;
262 vNodes->pArray[i]->pData0 = NULL;
263 }
264 // mark reachable nodes by setting the two-bit counter pNode->nFans
265 for ( i = 0; i < vNodes->nSize; i++ )
266 {
267 pNodeR = Fraig_Regular(vNodes->pArray[i]->p1);
268 if ( pNodeR && ++pNodeR->nFanouts == 3 )
269 pNodeR->nFanouts = 2;
270 pNodeR = Fraig_Regular(vNodes->pArray[i]->p2);
271 if ( pNodeR && ++pNodeR->nFanouts == 3 )
272 pNodeR->nFanouts = 2;
273 }
274 Fraig_NodeVecFree( vNodes );
275}
Fraig_Node_t * pData0
Definition fraigInt.h:251
Here is the call graph for this function:

◆ Fraig_ManPrintRefs()

int Fraig_ManPrintRefs ( Fraig_Man_t * pMan)

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

Synopsis [Counts the number of EXOR type nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 842 of file fraigUtil.c.

843{
844 Fraig_NodeVec_t * vPivots;
845 Fraig_Node_t * pNode, * pNode2;
846 int i, k, Counter, nProved;
847 abctime clk;
848
849 vPivots = Fraig_NodeVecAlloc( 1000 );
850 for ( i = 0; i < pMan->vNodes->nSize; i++ )
851 {
852 pNode = pMan->vNodes->pArray[i];
853
854 if ( pNode->nOnes == 0 || pNode->nOnes == (unsigned)pMan->nWordsRand * 32 )
855 continue;
856
857 if ( pNode->nRefs > 5 )
858 {
859 Fraig_NodeVecPush( vPivots, pNode );
860// printf( "Node %6d : nRefs = %2d Level = %3d.\n", pNode->Num, pNode->nRefs, pNode->Level );
861 }
862 }
863 printf( "Total nodes = %d. Referenced nodes = %d.\n", pMan->vNodes->nSize, vPivots->nSize );
864
865clk = Abc_Clock();
866 // count implications
867 Counter = nProved = 0;
868 for ( i = 0; i < vPivots->nSize; i++ )
869 for ( k = i+1; k < vPivots->nSize; k++ )
870 {
871 pNode = vPivots->pArray[i];
872 pNode2 = vPivots->pArray[k];
873 if ( Fraig_NodeSimsContained( pMan, pNode, pNode2 ) )
874 {
875 if ( Fraig_NodeIsImplification( pMan, pNode, pNode2, -1 ) )
876 nProved++;
877 Counter++;
878 }
879 else if ( Fraig_NodeSimsContained( pMan, pNode2, pNode ) )
880 {
881 if ( Fraig_NodeIsImplification( pMan, pNode2, pNode, -1 ) )
882 nProved++;
883 Counter++;
884 }
885 }
886 printf( "Number of candidate pairs = %d. Proved = %d.\n", Counter, nProved );
887//ABC_PRT( "Time", Abc_Clock() - clk );
888 return 0;
889}
ABC_INT64_T abctime
Definition abc_global.h:332
int Fraig_NodeIsImplification(Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit)
Definition fraigSat.c:551
int Fraig_NodeSimsContained(Fraig_Man_t *pMan, Fraig_Node_t *pNode1, Fraig_Node_t *pNode2)
Definition fraigUtil.c:784
void Fraig_NodeVecPush(Fraig_NodeVec_t *p, Fraig_Node_t *Entry)
Definition fraigVec.c:189
Here is the call graph for this function:

◆ Fraig_ManReportChoices()

void Fraig_ManReportChoices ( Fraig_Man_t * pMan)

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

Synopsis [Reports statistics on choice nodes.]

Description [The number of choice nodes is the number of primary nodes, which has pNextE set to a pointer. The number of choices is the number of entries in the equivalent-node lists of the primary nodes.]

SideEffects []

SeeAlso []

Definition at line 520 of file fraigUtil.c.

521{
522 Fraig_Node_t * pNode, * pTemp;
523 int nChoiceNodes, nChoices;
524 int i, LevelMax1, LevelMax2;
525
526 // report the number of levels
527 LevelMax1 = Fraig_GetMaxLevel( pMan );
529 LevelMax2 = Fraig_GetMaxLevel( pMan );
530
531 // report statistics about choices
532 nChoiceNodes = nChoices = 0;
533 for ( i = 0; i < pMan->vNodes->nSize; i++ )
534 {
535 pNode = pMan->vNodes->pArray[i];
536 if ( pNode->pRepr == NULL && pNode->pNextE != NULL )
537 { // this is a choice node = the primary node that has equivalent nodes
538 nChoiceNodes++;
539 for ( pTemp = pNode; pTemp; pTemp = pTemp->pNextE )
540 nChoices++;
541 }
542 }
543 printf( "Maximum level: Original = %d. Reduced due to choices = %d.\n", LevelMax1, LevelMax2 );
544 printf( "Choice stats: Choice nodes = %d. Total choices = %d.\n", nChoiceNodes, nChoices );
545}
int Fraig_GetMaxLevel(Fraig_Man_t *pMan)
Definition fraigUtil.c:428
void Fraig_MappingSetChoiceLevels(Fraig_Man_t *pMan, int fMaximum)
Definition fraigUtil.c:499
Fraig_Node_t * pNextE
Definition fraigInt.h:241
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_MappingSetChoiceLevels()

void Fraig_MappingSetChoiceLevels ( Fraig_Man_t * pMan,
int fMaximum )

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

Synopsis [Resets the levels of the nodes in the choice graph.]

Description [Makes the level of the choice nodes to be equal to the maximum of the level of the nodes in the equivalence class. This way sorting by level leads to the reverse topological order, which is needed for the required time computation.]

SideEffects []

SeeAlso []

Definition at line 499 of file fraigUtil.c.

500{
501 int i;
502 pMan->nTravIds++;
503 for ( i = 0; i < pMan->vOutputs->nSize; i++ )
504 Fraig_MappingUpdateLevel_rec( pMan, Fraig_Regular(pMan->vOutputs->pArray[i]), fMaximum );
505}
int Fraig_MappingUpdateLevel_rec(Fraig_Man_t *pMan, Fraig_Node_t *pNode, int fMaximum)
Definition fraigUtil.c:449
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_MappingUpdateLevel_rec()

int Fraig_MappingUpdateLevel_rec ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode,
int fMaximum )

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

Synopsis [Analyses choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 449 of file fraigUtil.c.

450{
451 Fraig_Node_t * pTemp;
452 int Level1, Level2, LevelE;
453 assert( !Fraig_IsComplement(pNode) );
454 if ( !Fraig_NodeIsAnd(pNode) )
455 return pNode->Level;
456 // skip the visited node
457 if ( pNode->TravId == pMan->nTravIds )
458 return pNode->Level;
459 pNode->TravId = pMan->nTravIds;
460 // compute levels of the children nodes
461 Level1 = Fraig_MappingUpdateLevel_rec( pMan, Fraig_Regular(pNode->p1), fMaximum );
462 Level2 = Fraig_MappingUpdateLevel_rec( pMan, Fraig_Regular(pNode->p2), fMaximum );
463 pNode->Level = 1 + Abc_MaxInt( Level1, Level2 );
464 if ( pNode->pNextE )
465 {
466 LevelE = Fraig_MappingUpdateLevel_rec( pMan, pNode->pNextE, fMaximum );
467 if ( fMaximum )
468 {
469 if ( pNode->Level < LevelE )
470 pNode->Level = LevelE;
471 }
472 else
473 {
474 if ( pNode->Level > LevelE )
475 pNode->Level = LevelE;
476 }
477 // set the level of all equivalent nodes to be the same minimum
478 if ( pNode->pRepr == NULL ) // the primary node
479 for ( pTemp = pNode->pNextE; pTemp; pTemp = pTemp->pNextE )
480 pTemp->Level = pNode->Level;
481 }
482 return pNode->Level;
483}
int Fraig_NodeIsAnd(Fraig_Node_t *p)
Definition fraigApi.c:153
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsExor()

int Fraig_NodeIsExor ( Fraig_Node_t * pNode)

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

Synopsis [Returns 1 if the node is EXOR, 0 if it is NEXOR.]

Description [The node should be EXOR type and not complemented.]

SideEffects []

SeeAlso []

Definition at line 633 of file fraigUtil.c.

634{
635 Fraig_Node_t * pNode1;
636 assert( !Fraig_IsComplement(pNode) );
638 assert( Fraig_IsComplement(pNode->p1) );
639 // get children
640 pNode1 = Fraig_Regular(pNode->p1);
641 return Fraig_IsComplement(pNode1->p1) == Fraig_IsComplement(pNode1->p2);
642}
Here is the call graph for this function:

◆ Fraig_NodeIsExorType()

int Fraig_NodeIsExorType ( Fraig_Node_t * pNode)

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

Synopsis [Returns 1 if the node is the root of EXOR/NEXOR gate.]

Description [The node can be complemented.]

SideEffects []

SeeAlso []

Definition at line 558 of file fraigUtil.c.

559{
560 Fraig_Node_t * pNode1, * pNode2;
561 // make the node regular (it does not matter for EXOR/NEXOR)
562 pNode = Fraig_Regular(pNode);
563 // if the node or its children are not ANDs or not compl, this cannot be EXOR type
564 if ( !Fraig_NodeIsAnd(pNode) )
565 return 0;
566 if ( !Fraig_NodeIsAnd(pNode->p1) || !Fraig_IsComplement(pNode->p1) )
567 return 0;
568 if ( !Fraig_NodeIsAnd(pNode->p2) || !Fraig_IsComplement(pNode->p2) )
569 return 0;
570
571 // get children
572 pNode1 = Fraig_Regular(pNode->p1);
573 pNode2 = Fraig_Regular(pNode->p2);
574 assert( pNode1->Num < pNode2->Num );
575
576 // compare grandchildren
577 return pNode1->p1 == Fraig_Not(pNode2->p1) && pNode1->p2 == Fraig_Not(pNode2->p2);
578}
#define Fraig_Not(p)
Definition fraig.h:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsInSupergate()

int Fraig_NodeIsInSupergate ( Fraig_Node_t * pOld,
Fraig_Node_t * pNew )

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

Synopsis [Checks if pNew exists among the implication fanins of pOld.]

Description [If pNew is an implication fanin of pOld, returns 1. If Fraig_Not(pNew) is an implication fanin of pOld, return -1. Otherwise returns 0.]

SideEffects []

SeeAlso []

Definition at line 905 of file fraigUtil.c.

906{
907 int RetValue1, RetValue2;
908 if ( Fraig_Regular(pOld) == Fraig_Regular(pNew) )
909 return (pOld == pNew)? 1 : -1;
910 if ( Fraig_IsComplement(pOld) || Fraig_NodeIsVar(pOld) )
911 return 0;
912 RetValue1 = Fraig_NodeIsInSupergate( pOld->p1, pNew );
913 RetValue2 = Fraig_NodeIsInSupergate( pOld->p2, pNew );
914 if ( RetValue1 == -1 || RetValue2 == -1 )
915 return -1;
916 if ( RetValue1 == 1 || RetValue2 == 1 )
917 return 1;
918 return 0;
919}
int Fraig_NodeIsInSupergate(Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigUtil.c:905
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsMuxType()

int Fraig_NodeIsMuxType ( Fraig_Node_t * pNode)

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

Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]

Description [The node can be complemented.]

SideEffects []

SeeAlso []

Definition at line 591 of file fraigUtil.c.

592{
593 Fraig_Node_t * pNode1, * pNode2;
594
595 // make the node regular (it does not matter for EXOR/NEXOR)
596 pNode = Fraig_Regular(pNode);
597 // if the node or its children are not ANDs or not compl, this cannot be EXOR type
598 if ( !Fraig_NodeIsAnd(pNode) )
599 return 0;
600 if ( !Fraig_NodeIsAnd(pNode->p1) || !Fraig_IsComplement(pNode->p1) )
601 return 0;
602 if ( !Fraig_NodeIsAnd(pNode->p2) || !Fraig_IsComplement(pNode->p2) )
603 return 0;
604
605 // get children
606 pNode1 = Fraig_Regular(pNode->p1);
607 pNode2 = Fraig_Regular(pNode->p2);
608 assert( pNode1->Num < pNode2->Num );
609
610 // compare grandchildren
611 // node is an EXOR/NEXOR
612 if ( pNode1->p1 == Fraig_Not(pNode2->p1) && pNode1->p2 == Fraig_Not(pNode2->p2) )
613 return 1;
614
615 // otherwise the node is MUX iff it has a pair of equal grandchildren
616 return pNode1->p1 == Fraig_Not(pNode2->p1) ||
617 pNode1->p1 == Fraig_Not(pNode2->p2) ||
618 pNode1->p2 == Fraig_Not(pNode2->p1) ||
619 pNode1->p2 == Fraig_Not(pNode2->p2);
620}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsTravIdCurrent()

int Fraig_NodeIsTravIdCurrent ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1012 of file fraigUtil.c.

1013{
1014 return pNode->TravId2 == pMan->nTravIds2;
1015}
Here is the caller graph for this function:

◆ Fraig_NodeIsTravIdPrevious()

int Fraig_NodeIsTravIdPrevious ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1028 of file fraigUtil.c.

1029{
1030 return pNode->TravId2 == pMan->nTravIds2 - 1;
1031}

◆ Fraig_NodeRecognizeMux()

Fraig_Node_t * Fraig_NodeRecognizeMux ( Fraig_Node_t * pNode,
Fraig_Node_t ** ppNodeT,
Fraig_Node_t ** ppNodeE )

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

Synopsis [Recognizes what nodes are control and data inputs of a MUX.]

Description [If the node is a MUX, returns the control variable C. Assigns nodes T and E to be the then and else variables of the MUX. Node C is never complemented. Nodes T and E can be complemented. This function also recognizes EXOR/NEXOR gates as MUXes.]

SideEffects []

SeeAlso []

Definition at line 658 of file fraigUtil.c.

659{
660 Fraig_Node_t * pNode1, * pNode2;
661 assert( !Fraig_IsComplement(pNode) );
662 assert( Fraig_NodeIsMuxType(pNode) );
663 // get children
664 pNode1 = Fraig_Regular(pNode->p1);
665 pNode2 = Fraig_Regular(pNode->p2);
666 // find the control variable
667 if ( pNode1->p1 == Fraig_Not(pNode2->p1) )
668 {
669 if ( Fraig_IsComplement(pNode1->p1) )
670 { // pNode2->p1 is positive phase of C
671 *ppNodeT = Fraig_Not(pNode2->p2);
672 *ppNodeE = Fraig_Not(pNode1->p2);
673 return pNode2->p1;
674 }
675 else
676 { // pNode1->p1 is positive phase of C
677 *ppNodeT = Fraig_Not(pNode1->p2);
678 *ppNodeE = Fraig_Not(pNode2->p2);
679 return pNode1->p1;
680 }
681 }
682 else if ( pNode1->p1 == Fraig_Not(pNode2->p2) )
683 {
684 if ( Fraig_IsComplement(pNode1->p1) )
685 { // pNode2->p2 is positive phase of C
686 *ppNodeT = Fraig_Not(pNode2->p1);
687 *ppNodeE = Fraig_Not(pNode1->p2);
688 return pNode2->p2;
689 }
690 else
691 { // pNode1->p1 is positive phase of C
692 *ppNodeT = Fraig_Not(pNode1->p2);
693 *ppNodeE = Fraig_Not(pNode2->p1);
694 return pNode1->p1;
695 }
696 }
697 else if ( pNode1->p2 == Fraig_Not(pNode2->p1) )
698 {
699 if ( Fraig_IsComplement(pNode1->p2) )
700 { // pNode2->p1 is positive phase of C
701 *ppNodeT = Fraig_Not(pNode2->p2);
702 *ppNodeE = Fraig_Not(pNode1->p1);
703 return pNode2->p1;
704 }
705 else
706 { // pNode1->p2 is positive phase of C
707 *ppNodeT = Fraig_Not(pNode1->p1);
708 *ppNodeE = Fraig_Not(pNode2->p2);
709 return pNode1->p2;
710 }
711 }
712 else if ( pNode1->p2 == Fraig_Not(pNode2->p2) )
713 {
714 if ( Fraig_IsComplement(pNode1->p2) )
715 { // pNode2->p2 is positive phase of C
716 *ppNodeT = Fraig_Not(pNode2->p1);
717 *ppNodeE = Fraig_Not(pNode1->p1);
718 return pNode2->p2;
719 }
720 else
721 { // pNode1->p2 is positive phase of C
722 *ppNodeT = Fraig_Not(pNode1->p1);
723 *ppNodeE = Fraig_Not(pNode2->p1);
724 return pNode1->p2;
725 }
726 }
727 assert( 0 ); // this is not MUX
728 return NULL;
729}
Here is the call graph for this function:

◆ Fraig_NodeSetTravIdCurrent()

void Fraig_NodeSetTravIdCurrent ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 996 of file fraigUtil.c.

997{
998 pNode->TravId2 = pMan->nTravIds2;
999}
Here is the caller graph for this function:

◆ Fraig_NodeSimsContained()

int Fraig_NodeSimsContained ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2 )

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

Synopsis [Returns 1 if siminfo of Node1 is contained in siminfo of Node2.]

Description []

SideEffects []

SeeAlso []

Definition at line 784 of file fraigUtil.c.

785{
786 unsigned * pUnsigned1, * pUnsigned2;
787 int i;
788
789 // compare random siminfo
790 pUnsigned1 = pNode1->puSimR;
791 pUnsigned2 = pNode2->puSimR;
792 for ( i = 0; i < pMan->nWordsRand; i++ )
793 if ( pUnsigned1[i] & ~pUnsigned2[i] )
794 return 0;
795
796 // compare systematic siminfo
797 pUnsigned1 = pNode1->puSimD;
798 pUnsigned2 = pNode2->puSimD;
799 for ( i = 0; i < pMan->iWordStart; i++ )
800 if ( pUnsigned1[i] & ~pUnsigned2[i] )
801 return 0;
802
803 return 1;
804}
unsigned * puSimR
Definition fraigInt.h:247
unsigned * puSimD
Definition fraigInt.h:248
Here is the caller graph for this function:

◆ Fraig_PrintBinary()

void Fraig_PrintBinary ( FILE * pFile,
unsigned * pSign,
int nBits )

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

Synopsis [Prints the bit string.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file fraigUtil.c.

403{
404 int Remainder, nWords;
405 int w, i;
406
407 Remainder = (nBits%(sizeof(unsigned)*8));
408 nWords = (nBits/(sizeof(unsigned)*8)) + (Remainder>0);
409
410 for ( w = nWords-1; w >= 0; w-- )
411 for ( i = ((w == nWords-1 && Remainder)? Remainder-1: 31); i >= 0; i-- )
412 fprintf( pFile, "%c", '0' + (int)((pSign[w] & (1<<i)) > 0) );
413
414// fprintf( pFile, "\n" );
415}
Here is the caller graph for this function:

◆ Fraig_PrintNode()

void Fraig_PrintNode ( Fraig_Man_t * p,
Fraig_Node_t * pNode )

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

Synopsis [Prints the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 358 of file fraigUtil.c.

359{
360 Fraig_NodeVec_t * vNodes;
361 Fraig_Node_t * pTemp;
362 int fCompl1, fCompl2, i;
363
364 vNodes = Fraig_DfsOne( p, pNode, 0 );
365 for ( i = 0; i < vNodes->nSize; i++ )
366 {
367 pTemp = vNodes->pArray[i];
368 if ( Fraig_NodeIsVar(pTemp) )
369 {
370 printf( "%3d : PI ", pTemp->Num );
371 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimR, 20 );
372 printf( " " );
373 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimD, 20 );
374 printf( " %d\n", pTemp->fInv );
375 continue;
376 }
377
378 fCompl1 = Fraig_IsComplement(pTemp->p1);
379 fCompl2 = Fraig_IsComplement(pTemp->p2);
380 printf( "%3d : %c%3d %c%3d ", pTemp->Num,
381 (fCompl1? '-':'+'), Fraig_Regular(pTemp->p1)->Num,
382 (fCompl2? '-':'+'), Fraig_Regular(pTemp->p2)->Num );
383 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimR, 20 );
384 printf( " " );
385 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimD, 20 );
386 printf( " %d\n", pTemp->fInv );
387 }
388 Fraig_NodeVecFree( vNodes );
389}
void Fraig_PrintBinary(FILE *pFile, unsigned *pSign, int nBits)
Definition fraigUtil.c:402
Here is the call graph for this function: