96 #define Frc_ManForEachObj( p, pObj, i ) \
97 for ( i = 0; (i < p->nObjData) && (pObj = Frc_ManObj(p,i)); i += Frc_ObjSize(pObj) )
98 #define Frc_ManForEachObjVec( vVec, p, pObj, i ) \
99 for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Frc_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
101 #define Frc_ManForEachNode( p, pObj, i ) \
102 for ( i = 0; (i < p->nObjData) && (pObj = Frc_ManObj(p,i)); i += Frc_ObjSize(pObj) ) if ( Frc_ObjIsTerm(pObj) ) {} else
103 #define Frc_ManForEachCi( p, pObj, i ) \
104 for ( i = 0; (i < Vec_IntSize(p->vCis)) && (pObj = Frc_ManObj(p,Vec_IntEntry(p->vCis,i))); i++ )
105 #define Frc_ManForEachCo( p, pObj, i ) \
106 for ( i = 0; (i < Vec_IntSize(p->vCos)) && (pObj = Frc_ManObj(p,Vec_IntEntry(p->vCos,i))); i++ )
108 #define Frc_ObjForEachFanin( pObj, pNext, i ) \
109 for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Frc_ObjFanin(pObj,i)); i++ )
110 #define Frc_ObjForEachFaninReverse( pObj, pNext, i ) \
111 for ( i = (int)pObj->nFanins - 1; (i >= 0) && (pNext = Frc_ObjFanin(pObj,i)); i-- )
112 #define Frc_ObjForEachFanout( pObj, pNext, i ) \
113 for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Frc_ObjFanout(pObj,i)); i++ )
133 assert( pObj->iFanin < pObj->nFanins );
134 assert( pFanin->iFanout < pFanin->nFanouts );
135 pFanin->Fanios[pFanin->nFanins + pFanin->iFanout++] =
136 pObj->Fanios[pObj->iFanin++] = pObj->hHandle - pFanin->hHandle;
155 int i, nNodes, hHandle = 0;
169 pObjLog->hHandle = hHandle;
170 pObjLog->nFanins = 0;
180 pObj->
Value = hHandle;
183 pObjLog->hHandle = hHandle;
184 pObjLog->nFanins = 0;
196 pObj->
Value = hHandle;
198 pObjLog->hHandle = hHandle;
199 pObjLog->nFanins = 2;
215 pObj->
Value = hHandle;
218 pObjLog->hHandle = hHandle;
219 pObjLog->nFanins = 1;
220 pObjLog->nFanouts = 0;
235 printf(
"Frc_ManStartSimple(): Fatal error in internal representation.\n" );
242 assert( pObjLog->nFanins == pObjLog->iFanin );
243 assert( pObjLog->nFanouts == pObjLog->iFanout );
244 pObjLog->iFanin = pObjLog->iFanout = 0;
434 int nObjs, nFanios, nNodes = 0;
435 int i, k, hHandle = 0;
452 pObjLog->hHandle = hHandle;
453 pObjLog->nFanins = 0;
463 pObj->
Value = hHandle;
466 pObjLog->hHandle = hHandle;
467 pObjLog->nFanins = 0;
487 pObj->
Value = hHandle;
489 pObjLog->hHandle = hHandle;
509 pObj->
Value = hHandle;
512 pObjLog->hHandle = hHandle;
513 pObjLog->nFanins = 1;
514 pObjLog->nFanouts = 0;
531 printf(
"Frc_ManStart(): Fatal error in internal representation.\n" );
538 assert( pObjLog->nFanins == pObjLog->iFanin );
539 assert( pObjLog->nFanouts == pObjLog->iFanout );
540 pObjLog->iFanin = pObjLog->iFanout = 0;
568 printf(
"mem =%5.2f MB", 4.0*p->
nObjData/(1<<20) );
606 assert( pObj->iFanout > 0 );
607 if ( pObj->iFanout-- == pObj->nFanouts )
617 return pObj->iFanout == 0;
633 assert( pObj->iFanout > 0 );
634 if ( pObj->iFanout-- == pObj->nFanouts )
644 return pObj->iFanout == 0;
666 pObj->iFanout = pObj->nFanouts;
725 if ( vOrder != vOrderInit )
747 int i, h, Temp, iNext,
Counter;
749 for ( i = 0; i < p->
nObjs; i++ )
751 for ( i = 0; i < p->
nObjs; i++ )
754 Temp = pPlacement[i];
755 pPlacement[i] = pPlacement[iNext];
756 pPlacement[iNext] = Temp;
760 pThis->pPlace = pPlacement[Counter++];
778 for ( i = 0; i < vArray->nSize; i++ )
781 Temp = vArray->pArray[i];
782 vArray->pArray[i] = vArray->pArray[iNext];
783 vArray->pArray[iNext] = Temp;
800 assert( pObj->iFanout > 0 );
801 if ( pObj->iFanout-- == pObj->nFanouts )
808 pObj->pPlace = (*piPlace)++;
829 pObj->iFanout = pObj->nFanouts;
831 pObj->pPlace = nPlaces++;
837 pObj->pPlace = nPlaces++;
855 int nCutStart1, nCutStart2;
859 if ( nCutStart1 <= nCutStart2 )
863 *piCutSize2 = nCutStart2;
870 *piCutSize2 = nCutStart1;
891 double CostThis, CostPrev;
892 float * pVertX, VertX;
893 int * pPermX, * pHandles;
894 int k, h, Iter, iMinX, iMaxX,
Counter, nCutStart, nCutCur, nCutCur2, nCutPrev;
903 nCutPrev = nCutStart;
906 for ( Iter = 0; Iter < nIters; Iter++ )
912 iMinX = iMaxX = pThis->pPlace;
918 pThis->fEdgeCenter = 0.5 * (iMaxX + iMinX);
919 CostThis += (iMaxX - iMinX);
925 VertX = pThis->fEdgeCenter;
927 VertX += pNext->fEdgeCenter;
929 pHandles[Counter++] = h;
936 assert( pPermX == pHandles );
938 for ( k = 0; k < p->
nObjs; k++ )
955 printf(
"%2d : Span = %e ", Iter+1, CostThis );
956 printf(
"Cut = %6d (%5.2f %%) CutR = %6d ", nCutCur, 100.0*(nCutStart-nCutCur)/nCutStart, nCutCur2 );
1011 pThis->iFanin = Counter++;
1016 pFile = fopen(
"x\\large\\aig\\dg1.g",
"w" );
1021 if ( ~pThis->iFanin && ~pNext->iFanin )
1022 fprintf( pFile,
"%d %d\n", pThis->iFanin, pNext->iFanin );
1070 int i, Size, Exp = 25;
1075 printf(
"2^%d machine words (%d bytes).\n", Exp, (
int)
sizeof(
int) * Size );
1078 for ( i = 0; i < Size; i++ )
1083 pFile = fopen(
"test.txt",
"rb" );
1084 RetValue = fread( pBuffer, 1,
sizeof(
int) * Size, pFile );
1089 pFile = fopen(
"test.txt",
"wb" );
1090 fwrite( pBuffer, 1,
sizeof(
int) * Size, pFile );
#define Frc_ObjForEachFanout(pObj, pNext, i)
void Gia_ManCreateRefs(Gia_Man_t *p)
Frc_Man_t * Frc_ManStartSimple(Gia_Man_t *pGia)
static int Frc_ObjFanoutNum(Frc_Obj_t *pObj)
static int Frc_ObjIsConst0(Frc_Obj_t *pObj)
#define Gia_ManForEachCo(p, pObj, i)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static Frc_Obj_t * Frc_ManObj(Frc_Man_t *p, int hHandle)
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Frc_Man_t * Frc_ManStart(Gia_Man_t *pGia)
static Frc_Obj_t * Frc_ManCo(Frc_Man_t *p, int i)
void Gia_ManCleanMark0(Gia_Man_t *p)
static int Frc_ObjIsCo(Frc_Obj_t *pObj)
int Frc_ManCrossCut2_rec(Frc_Man_t *p, Frc_Obj_t *pObj)
static int Frc_ObjIsNode(Frc_Obj_t *pObj)
void For_ManExperiment(Gia_Man_t *pGia, int nIters, int fClustered, int fVerbose)
static int Gia_ObjValue(Gia_Obj_t *pObj)
void Frc_ManPlaceRandom(Frc_Man_t *p)
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Frc_ManNodeNum(Frc_Man_t *p)
#define ABC_ALLOC(type, num)
#define Frc_ObjForEachFaninReverse(pObj, pNext, i)
void Frc_ManArrayShuffle(Vec_Int_t *vArray)
#define Frc_ObjForEachFanin(pObj, pNext, i)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
#define Gia_ManForEachCoDriver(p, pObj, i)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
static void Vec_IntReverseOrder(Vec_Int_t *p)
int Frc_ManPlaceDfsBoth(Frc_Man_t *p, Vec_Int_t *vCoOrder, int *piCutSize2)
void Gia_ManCleanMark1(Gia_Man_t *p)
void Frc_ManPrintStats(Frc_Man_t *p)
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
void Frc_ManCollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, Vec_Int_t *vVisit)
Vec_Int_t * Frc_ManCollectCos(Frc_Man_t *p)
int Frc_ManCrossCut_rec(Frc_Man_t *p, Frc_Obj_t *pObj)
#define Gia_ManForEachCi(p, pObj, i)
static int Gia_ManAndNum(Gia_Man_t *p)
static int Frc_ObjSize(Frc_Obj_t *pObj)
void Frc_ManPlaceDfs_rec(Frc_Man_t *p, Frc_Obj_t *pObj, int *piPlace)
static int Abc_MinInt(int a, int b)
static Frc_Obj_t * Frc_ManCi(Frc_Man_t *p, int i)
void Gia_ManCheckMark1(Gia_Man_t *p)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
static int Frc_ManCiNum(Frc_Man_t *p)
static int Frc_ManRegNum(Frc_Man_t *p)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Vec_IntEntry(Vec_Int_t *p, int i)
void For_ManFileExperiment()
static int Gia_ObjRefInc(Gia_Man_t *p, Gia_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
void Frc_DumpGraphIntoFile(Frc_Man_t *p)
void Frc_ManCollectSuper_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, Vec_Int_t *vVisit)
#define Gia_ManForEachAnd(p, pObj, i)
#define Frc_ManForEachCo(p, pObj, i)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static Frc_Obj_t * Frc_ObjFanin(Frc_Obj_t *pObj, int i)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Frc_Obj_t_ Frc_Obj_t
DECLARATIONS ///.
void Gia_ManFillValue(Gia_Man_t *p)
static int Frc_ObjIsPo(Frc_Obj_t *pObj)
#define Frc_ManForEachObjVec(vVec, p, pObj, i)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
#define ABC_NAMESPACE_IMPL_START
static int Gia_ObjRefDec(Gia_Man_t *p, Gia_Obj_t *pObj)
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
static int Gia_ManCiNum(Gia_Man_t *p)
int Frc_ObjFanoutsAreCos(Frc_Obj_t *pThis)
static int Vec_IntSize(Vec_Int_t *p)
void Frc_ManPlacementRefine(Frc_Man_t *p, int nIters, int fVerbose)
static int Frc_ManPoNum(Frc_Man_t *p)
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
void Frc_ManCreateRefsSpecial(Gia_Man_t *p)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
#define ABC_CALLOC(type, num)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
int Frc_ManCrossCut(Frc_Man_t *p, Vec_Int_t *vOrder, int fReverse)
#define Frc_ManForEachObj(p, pObj, i)
int * Gia_SortFloats(float *pArray, int *pPerm, int nSize)
static int Frc_ObjIsCi(Frc_Obj_t *pObj)
void Frc_ManStop(Frc_Man_t *p)
static int Frc_ManPiNum(Frc_Man_t *p)
static void Vec_IntFree(Vec_Int_t *p)
static void Vec_IntClear(Vec_Int_t *p)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Frc_ObjFaninNum(Frc_Obj_t *pObj)
static int Frc_ManCoNum(Frc_Man_t *p)
static int Frc_ObjIsTerm(Frc_Obj_t *pObj)
static int Frc_ManObjNum(Frc_Man_t *p)
static int Gia_ManObjNum(Gia_Man_t *p)
void Frc_ManPlaceDfs(Frc_Man_t *p, Vec_Int_t *vCoOrder)
static Frc_Obj_t * Frc_ObjFanout(Frc_Obj_t *pObj, int i)
void Frc_ManCrossCutTest(Frc_Man_t *p, Vec_Int_t *vOrderInit)
static int Frc_ObjIsPi(Frc_Obj_t *pObj)
static int Gia_ManCoNum(Gia_Man_t *p)
void Frc_ObjAddFanin(Frc_Obj_t *pObj, Frc_Obj_t *pFanin)
FUNCTION DEFINITIONS ///.
void Frc_ManTransformRefs(Gia_Man_t *p, int *pnObjs, int *pnFanios)
static int Gia_ManRegNum(Gia_Man_t *p)