bmcUnroll.c 17.9 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/**CFile****************************************************************

  FileName    [bmcUnroll.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [SAT-based bounded model checking.]

  Synopsis    [Unrolling manager.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

  Revision    [$Id: bmc.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

***********************************************************************/

#include "bmc.h"

ABC_NAMESPACE_IMPL_START

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

Alan Mishchenko committed
29
#define UNR_DIFF_NULL 0x7FFF
Alan Mishchenko committed
30 31 32 33 34 35 36 37 38 39

typedef struct Unr_Obj_t_ Unr_Obj_t; // 24 bytes + (RankMax-1) * 4 bytes
struct Unr_Obj_t_
{
    unsigned              hFan0;        // address of the fanin
    unsigned              hFan1;        // address of the fanin
    unsigned              fCompl0 :  1; // complemented bit
    unsigned              fCompl1 :  1; // complemented bit
    unsigned              uRDiff0 : 15; // rank diff of the fanin
    unsigned              uRDiff1 : 15; // rank diff of the fanin
40 41 42 43
    unsigned              fItIsPi :  1; // remember attributes
    unsigned              fItIsPo :  1; // remember attributes
    unsigned              RankMax : 15; // max rank diff between node and its fanout
    unsigned              RankCur : 15; // cur rank of the node
Alan Mishchenko committed
44 45 46 47 48 49 50 51
    unsigned              OrigId;       // original object ID
    unsigned              Res[1];       // RankMax entries
};

struct Unr_Man_t_
{
    // input data
    Gia_Man_t *           pGia;           // the user's AIG manager
52
    Gia_Man_t *           pFrames;        // unrolled manager
Alan Mishchenko committed
53 54 55 56 57 58 59 60 61 62 63
    int                   nObjs;          // the number of objects
    // intermediate data
    Vec_Int_t *           vOrder;         // ordering of GIA objects
    Vec_Int_t *           vOrderLim;      // beginning of each time frame
    Vec_Int_t *           vTents;         // tents of GIA objects
    Vec_Int_t *           vRanks;         // ranks of GIA objects
    // unrolling data
    int *                 pObjs;          // storage for unroling objects
    int *                 pEnd;           // end of storage
    Vec_Int_t *           vObjLim;        // handle of the first object in each frame
    Vec_Int_t *           vCiMap;         // mapping of GIA CIs into unrolling objects
64
    Vec_Int_t *           vCoMap;         // mapping of GIA POs into unrolling objects
65
    Vec_Int_t *           vPiLits;        // storage for PI literals
Alan Mishchenko committed
66 67
};

68
static inline Unr_Obj_t * Unr_ManObj( Unr_Man_t * p, int h )  { assert( h >= 0 && h < p->pEnd - p->pObjs ); return (Unr_Obj_t *)(p->pObjs + h);  }
69 70 71
static inline int         Unr_ObjSizeInt( int Rank )          { return 0xFFFFFFFE & (sizeof(Unr_Obj_t) / sizeof(int) + Rank);                    }
static inline int         Unr_ObjSize( Unr_Obj_t * pObj )     { return Unr_ObjSizeInt(pObj->RankMax);                                            }

Alan Mishchenko committed
72 73 74 75
static inline int Unr_ManFanin0Value( Unr_Man_t * p, Unr_Obj_t * pObj )
{
    Unr_Obj_t * pFanin = Unr_ManObj( p, pObj->hFan0 );
    int Index = (pFanin->RankCur + pFanin->RankMax - pObj->uRDiff0) % pFanin->RankMax;
76 77
    assert( pFanin->RankCur < pFanin->RankMax );
    assert( pObj->uRDiff0 < pFanin->RankMax );
Alan Mishchenko committed
78 79 80 81 82 83
    return Abc_LitNotCond( pFanin->Res[Index], pObj->fCompl0 );
}
static inline int Unr_ManFanin1Value( Unr_Man_t * p, Unr_Obj_t * pObj )
{
    Unr_Obj_t * pFanin = Unr_ManObj( p, pObj->hFan1 );
    int Index = (pFanin->RankCur + pFanin->RankMax - pObj->uRDiff1) % pFanin->RankMax;
84 85
    assert( pFanin->RankCur < pFanin->RankMax );
    assert( pObj->uRDiff1 < pFanin->RankMax );
Alan Mishchenko committed
86 87
    return Abc_LitNotCond( pFanin->Res[Index], pObj->fCompl1 );
}
88
static inline int Unr_ManObjReadValue( Unr_Obj_t * pObj )
Alan Mishchenko committed
89
{
90 91 92 93 94
    assert( pObj->RankCur >= 0 && pObj->RankCur < pObj->RankMax );
    return pObj->Res[ pObj->RankCur ];
}
static inline void Unr_ManObjSetValue( Unr_Obj_t * pObj, int Value )
{
95 96
    assert( Value >= 0 );
    pObj->RankCur = (UNR_DIFF_NULL & (pObj->RankCur + 1)) % pObj->RankMax;
Alan Mishchenko committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    pObj->Res[ pObj->RankCur ] = Value;
}

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
static inline void Vec_IntWriteMaxEntry( Vec_Int_t * p, int i, int Entry )
{
    assert( i >= 0 && i < p->nSize );
    p->pArray[i] = Abc_MaxInt( p->pArray[i], Entry );
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Unr_ManProfileRanks( Vec_Int_t * vRanks )
{
    int RankMax = Vec_IntFindMax( vRanks );
    Vec_Int_t * vCounts = Vec_IntStart( RankMax+1 );
    int i, Rank, Count, nExtras = 0;
    Vec_IntForEachEntry( vRanks, Rank, i )
        Vec_IntAddToEntry( vCounts, Rank, 1 );
    Vec_IntForEachEntry( vCounts, Count, i )
    {
141 142
        if ( Count == 0 )
            continue;
Alan Mishchenko committed
143 144 145
        printf( "%2d : %8d  (%6.2f %%)\n", i, Count, 100.0 * Count / Vec_IntSize(vRanks) );
        nExtras += Count * i;
    }
146
    printf( "Extra space = %d (%6.2f %%)  ", nExtras, 100.0 * nExtras / Vec_IntSize(vRanks) );
Alan Mishchenko committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
    Vec_IntFree( vCounts );
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Unr_ManSetup_rec( Unr_Man_t * p, int iObj, int iTent, Vec_Int_t * vRoots )
{
    Gia_Obj_t * pObj;
    int iFanin;
    if ( Vec_IntEntry(p->vTents, iObj) >= 0 )
        return;
    Vec_IntWriteEntry(p->vTents, iObj, iTent);
    pObj = Gia_ManObj( p->pGia, iObj );
    if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
    {
        Unr_ManSetup_rec( p, (iFanin = Gia_ObjFaninId0(pObj, iObj)), iTent, vRoots );
172
        Vec_IntWriteMaxEntry( p->vRanks, iFanin, Abc_MaxInt(0, iTent - Vec_IntEntry(p->vTents, iFanin) - 1) );
Alan Mishchenko committed
173 174 175 176
    }
    if ( Gia_ObjIsAnd(pObj) )
    {
        Unr_ManSetup_rec( p, (iFanin = Gia_ObjFaninId1(pObj, iObj)), iTent, vRoots );
177
        Vec_IntWriteMaxEntry( p->vRanks, iFanin, Abc_MaxInt(0, iTent - Vec_IntEntry(p->vTents, iFanin) - 1) );
Alan Mishchenko committed
178 179 180 181
    }
    else if ( Gia_ObjIsRo(p->pGia, pObj) )
    {
        Vec_IntPush( vRoots, (iFanin = Gia_ObjId(p->pGia, Gia_ObjRoToRi(p->pGia, pObj))) );
182
        Vec_IntWriteMaxEntry( p->vRanks, iFanin, 0 );
Alan Mishchenko committed
183 184 185
    }
    Vec_IntPush( p->vOrder, iObj );
}
186
void Unr_ManSetup( Unr_Man_t * p, int fVerbose )
Alan Mishchenko committed
187 188 189
{
    Vec_Int_t * vRoots, * vRoots2, * vMap;
    Unr_Obj_t * pUnrObj;
190
    Gia_Obj_t * pObj;
191
    int i, k, t, iObj, nInts, * pInts;
192
    abctime clk = Abc_Clock();
Alan Mishchenko committed
193 194 195 196 197 198 199
    // create zero rank
    assert( Vec_IntSize(p->vOrder) == 0 );
    Vec_IntPush( p->vOrder, 0 );
    Vec_IntPush( p->vOrderLim, Vec_IntSize(p->vOrder) );
    Vec_IntWriteEntry( p->vTents, 0, 0 );
    Vec_IntWriteEntry( p->vRanks, 0, 0 );
    // start from the POs
200 201
    vRoots  = Vec_IntAlloc( 100 );
    vRoots2 = Vec_IntAlloc( 100 );
Alan Mishchenko committed
202 203
    Gia_ManForEachPo( p->pGia, pObj, i )
        Unr_ManSetup_rec( p, Gia_ObjId(p->pGia, pObj), 0, vRoots );
204
    // collect tents
Alan Mishchenko committed
205 206 207 208 209 210 211 212 213 214 215 216
    while ( Vec_IntSize(vRoots) > 0 )
    {
        Vec_IntPush( p->vOrderLim, Vec_IntSize(p->vOrder) );
        Vec_IntClear( vRoots2 );
        Vec_IntForEachEntry( vRoots, iObj, i )
            Unr_ManSetup_rec( p, iObj, Vec_IntSize(p->vOrderLim)-1, vRoots2 );
        ABC_SWAP( Vec_Int_t *, vRoots, vRoots2 );
    }
    Vec_IntPush( p->vOrderLim, Vec_IntSize(p->vOrder) );
    Vec_IntFree( vRoots );
    Vec_IntFree( vRoots2 );
    // allocate memory
217 218 219
    nInts = 0;
    Vec_IntForEachEntry( p->vOrder, iObj, i )
        nInts += Unr_ObjSizeInt( Vec_IntEntry(p->vRanks, iObj) + 1 );
Alan Mishchenko committed
220 221 222 223
    p->pObjs = pInts = ABC_CALLOC( int, nInts );
    p->pEnd = p->pObjs + nInts;
    // create const0 node
    pUnrObj = Unr_ManObj( p, pInts - p->pObjs );
224
    pUnrObj->RankMax = Vec_IntEntry(p->vRanks, 0) + 1;
Alan Mishchenko committed
225
    pUnrObj->uRDiff0 = pUnrObj->uRDiff1 = UNR_DIFF_NULL;
Alan Mishchenko committed
226
    pUnrObj->Res[0]  = 0; // const0
227 228 229 230
    // map the objects
    vMap = Vec_IntStartFull( p->nObjs );
    Vec_IntWriteEntry( vMap, 0, pInts - p->pObjs );
    pInts += Unr_ObjSize(pUnrObj);
Alan Mishchenko committed
231 232 233 234 235 236
    // mark up the entries
    assert( Vec_IntSize(p->vObjLim) == 0 );
    for ( t = Vec_IntSize(p->vOrderLim) - 2; t >= 0; t-- )
    {
        int Beg = Vec_IntEntry(p->vOrderLim, t);
        int End = Vec_IntEntry(p->vOrderLim, t+1);
237
        Vec_IntPush( p->vObjLim, pInts - p->pObjs );
Alan Mishchenko committed
238 239 240 241
        Vec_IntForEachEntryStartStop( p->vOrder, iObj, i, Beg, End )
        {
            pObj = Gia_ManObj( p->pGia, iObj );
            pUnrObj = Unr_ManObj( p, pInts - p->pObjs );
Alan Mishchenko committed
242
            pUnrObj->uRDiff0 = pUnrObj->uRDiff1 = UNR_DIFF_NULL;
Alan Mishchenko committed
243
            if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
244
                pUnrObj->uRDiff0 = Abc_MaxInt(0, Vec_IntEntry(p->vTents, iObj) - Vec_IntEntry(p->vTents, Gia_ObjFaninId0(pObj, iObj)) - 1);
Alan Mishchenko committed
245
            if ( Gia_ObjIsAnd(pObj) )
246
                pUnrObj->uRDiff1 = Abc_MaxInt(0, Vec_IntEntry(p->vTents, iObj) - Vec_IntEntry(p->vTents, Gia_ObjFaninId1(pObj, iObj)) - 1);
Alan Mishchenko committed
247
            else if ( Gia_ObjIsRo(p->pGia, pObj) )
248
                pUnrObj->uRDiff0 = 0;
Alan Mishchenko committed
249
            pUnrObj->RankMax = Vec_IntEntry(p->vRanks, iObj) + 1;
250
            pUnrObj->RankCur = UNR_DIFF_NULL;
Alan Mishchenko committed
251 252 253
            pUnrObj->OrigId  = iObj;
            for ( k = 0; k < (int)pUnrObj->RankMax; k++ )
                pUnrObj->Res[k] = -1;
254
            assert( ((pInts - p->pObjs) & 1) == 0 ); // align for 64-bits
Alan Mishchenko committed
255
            Vec_IntWriteEntry( vMap, iObj, pInts - p->pObjs );
256
            pInts += Unr_ObjSize( pUnrObj );
Alan Mishchenko committed
257 258
        }
    }
259
    assert( pInts - p->pObjs == nInts );
260 261 262 263 264 265 266 267 268 269
    // label the objects
    Gia_ManForEachObj( p->pGia, pObj, i )
    {
        if ( Vec_IntEntry(vMap, i) == -1 )
            continue;
        pUnrObj = Unr_ManObj( p, Vec_IntEntry(vMap, i) );
        if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
        {
            pUnrObj->hFan0   = Vec_IntEntry( vMap, Gia_ObjFaninId0(pObj, i) );
            pUnrObj->fCompl0 = Gia_ObjFaninC0(pObj);
270
            pUnrObj->fItIsPo = Gia_ObjIsPo(p->pGia, pObj);
271 272 273 274 275 276 277 278 279 280 281
        }
        if ( Gia_ObjIsAnd(pObj) )
        {
            pUnrObj->hFan1   = Vec_IntEntry( vMap, Gia_ObjFaninId1(pObj, i) );
            pUnrObj->fCompl1 = Gia_ObjFaninC1(pObj);
        }
        else if ( Gia_ObjIsRo(p->pGia, pObj) )
        {
            pUnrObj->hFan0   = Vec_IntEntry( vMap, Gia_ObjId(p->pGia, Gia_ObjRoToRi(p->pGia, pObj)) );
            pUnrObj->fCompl0 = 0;
        }
282 283 284 285 286 287
        else if ( Gia_ObjIsPi(p->pGia, pObj) )
        {
            pUnrObj->hFan0   = Gia_ObjCioId(pObj);           // remember CIO id
            pUnrObj->hFan1   = Vec_IntEntry(p->vTents, i);   // remember tent
            pUnrObj->fItIsPi = 1;
        }
288
    }
Alan Mishchenko committed
289 290 291
    // store CI/PO objects;
    Gia_ManForEachCi( p->pGia, pObj, i )
        Vec_IntPush( p->vCiMap, Vec_IntEntry(vMap, Gia_ObjId(p->pGia, pObj)) );
292 293
    Gia_ManForEachCo( p->pGia, pObj, i )
        Vec_IntPush( p->vCoMap, Vec_IntEntry(vMap, Gia_ObjId(p->pGia, pObj)) );
Alan Mishchenko committed
294
    Vec_IntFreeP( &vMap );
295 296 297 298 299 300 301 302 303 304 305
    // print stats
    if ( fVerbose )
    {
        Unr_ManProfileRanks( p->vRanks );
        printf( "Memory usage = %6.2f MB  ", 4.0 * nInts / (1<<20) );
        Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
    }
    Vec_IntFreeP( &p->vOrder );
    Vec_IntFreeP( &p->vOrderLim );
    Vec_IntFreeP( &p->vRanks );
    Vec_IntFreeP( &p->vTents );
Alan Mishchenko committed
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
}



/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Unr_Man_t * Unr_ManAlloc( Gia_Man_t * pGia )
{
    Unr_Man_t * p;
    p = ABC_CALLOC( Unr_Man_t, 1 );
    p->pGia      = pGia;
    p->nObjs     = Gia_ManObjNum(pGia);
    p->vOrder    = Vec_IntAlloc( p->nObjs );
    p->vOrderLim = Vec_IntAlloc( 100 );
    p->vTents    = Vec_IntStartFull( p->nObjs );
    p->vRanks    = Vec_IntStart( p->nObjs );
    p->vObjLim   = Vec_IntAlloc( 100 );
    p->vCiMap    = Vec_IntAlloc( Gia_ManCiNum(pGia) );
333
    p->vCoMap    = Vec_IntAlloc( Gia_ManCoNum(pGia) );
334 335 336 337
    p->vPiLits   = Vec_IntAlloc( 10000 );
    p->pFrames   = Gia_ManStart( 10000 );
    p->pFrames->pName = Abc_UtilStrsav( pGia->pName );
    Gia_ManHashStart( p->pFrames );
Alan Mishchenko committed
338 339 340 341
    return p;
}
void Unr_ManFree( Unr_Man_t * p )
{
342
    Gia_ManStop( p->pFrames );
Alan Mishchenko committed
343 344 345 346 347 348 349 350
    // intermediate data
    Vec_IntFreeP( &p->vOrder );
    Vec_IntFreeP( &p->vOrderLim );
    Vec_IntFreeP( &p->vTents );
    Vec_IntFreeP( &p->vRanks );
    // unrolling data
    Vec_IntFreeP( &p->vObjLim );
    Vec_IntFreeP( &p->vCiMap );
351
    Vec_IntFreeP( &p->vCoMap );
352
    Vec_IntFreeP( &p->vPiLits );
Alan Mishchenko committed
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
    ABC_FREE( p->pObjs );
    ABC_FREE( p );
}

/**Function*************************************************************

  Synopsis    [Perform smart unrolling.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
368
Unr_Man_t * Unr_ManUnrollStart( Gia_Man_t * pGia, int fVerbose )
Alan Mishchenko committed
369
{
370
    int i, iHandle;
371 372 373
    Unr_Man_t * p;
    p = Unr_ManAlloc( pGia );
    Unr_ManSetup( p, fVerbose );
Alan Mishchenko committed
374
    for ( i = 0; i < Gia_ManRegNum(p->pGia); i++ )
375 376
        if ( (iHandle = Vec_IntEntry(p->vCoMap, Gia_ManPoNum(p->pGia) + i)) != -1 )
            Unr_ManObjSetValue( Unr_ManObj(p, iHandle), 0 );
377
    return p;
378
}
379
Gia_Man_t * Unr_ManUnrollFrame( Unr_Man_t * p, int f )
380 381 382 383 384 385
{
    int i, iLit, iLit0, iLit1, hStart;
    for ( i = 0; i < Gia_ManPiNum(p->pGia); i++ )
        Vec_IntPush( p->vPiLits, Gia_ManAppendCi(p->pFrames) );
    hStart = Vec_IntEntry( p->vObjLim, Abc_MaxInt(0, Vec_IntSize(p->vObjLim)-1-f) );
    while ( p->pObjs + hStart < p->pEnd )
Alan Mishchenko committed
386
    {
387 388 389 390 391 392 393 394 395
        Unr_Obj_t * pUnrObj = Unr_ManObj( p, hStart );
        if ( pUnrObj->uRDiff0 != UNR_DIFF_NULL && pUnrObj->uRDiff1 != UNR_DIFF_NULL ) // AND node
        {
            iLit0 = Unr_ManFanin0Value( p, pUnrObj );
            iLit1 = Unr_ManFanin1Value( p, pUnrObj );
            iLit  = Gia_ManHashAnd( p->pFrames, iLit0, iLit1 );
            Unr_ManObjSetValue( pUnrObj, iLit );
        }
        else if ( pUnrObj->uRDiff0 != UNR_DIFF_NULL && pUnrObj->uRDiff1 == UNR_DIFF_NULL ) // PO/RI/RO
Alan Mishchenko committed
396
        {
397 398 399 400
            iLit  = Unr_ManFanin0Value( p, pUnrObj );
            Unr_ManObjSetValue( pUnrObj, iLit );
            if ( pUnrObj->fItIsPo )
                Gia_ManAppendCo( p->pFrames, iLit );
Alan Mishchenko committed
401
        }
402
        else // PI  (pUnrObj->hFan0 is CioId; pUnrObj->hFan1 is tent)
403
        {
404 405 406
            assert( pUnrObj->fItIsPi && f >= (int)pUnrObj->hFan1 );
            iLit = Vec_IntEntry( p->vPiLits, Gia_ManPiNum(p->pGia) * (f - pUnrObj->hFan1) + pUnrObj->hFan0 );
            Unr_ManObjSetValue( pUnrObj, iLit );
407
        }
408
        hStart += Unr_ObjSize( pUnrObj );
Alan Mishchenko committed
409
    }
410
    assert( p->pObjs + hStart == p->pEnd );
411
    assert( Gia_ManPoNum(p->pFrames) == (f + 1) * Gia_ManPoNum(p->pGia) );
412
    return p->pFrames;
413
}
414
Gia_Man_t * Unr_ManUnroll( Gia_Man_t * pGia, int nFrames )
415
{
416 417
    Unr_Man_t * p;
    Gia_Man_t * pFrames;
418
    int f;
419
    p = Unr_ManUnrollStart( pGia, 1 );
420 421
    for ( f = 0; f < nFrames; f++ )
        Unr_ManUnrollFrame( p, f );
422 423 424
    pFrames = Gia_ManCleanup( p->pFrames );
    Unr_ManFree( p );
    return pFrames;
Alan Mishchenko committed
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
}

/**Function*************************************************************

  Synopsis    [Perform naive unrolling.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Gia_Man_t * Unr_ManUnrollSimple( Gia_Man_t * pGia, int nFrames )
{
    Gia_Man_t * pFrames;
    Gia_Obj_t * pObj, * pObjRi;
442 443
    int f, i; 
    pFrames = Gia_ManStart( 10000 );
Alan Mishchenko committed
444 445 446 447 448 449 450 451 452 453 454 455
    pFrames->pName = Abc_UtilStrsav( pGia->pName );
    Gia_ManHashAlloc( pFrames );
    Gia_ManConst0(pGia)->Value = 0;
    Gia_ManForEachRi( pGia, pObj, i )
        pObj->Value = 0;
    for ( f = 0; f < nFrames; f++ )
    {
        Gia_ManForEachPi( pGia, pObj, i )
            pObj->Value = Gia_ManAppendCi(pFrames);
        Gia_ManForEachRiRo( pGia, pObjRi, pObj, i )
            pObj->Value = pObjRi->Value;
        Gia_ManForEachAnd( pGia, pObj, i )
456
            pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
Alan Mishchenko committed
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
        Gia_ManForEachCo( pGia, pObj, i )
            pObj->Value = Gia_ObjFanin0Copy(pObj);
        Gia_ManForEachPo( pGia, pObj, i )
            Gia_ManAppendCo( pFrames, pObj->Value );
    }
    Gia_ManHashStop( pFrames );
    Gia_ManSetRegNum( pFrames, 0 );
    pFrames = Gia_ManCleanup( pGia = pFrames );
    Gia_ManStop( pGia );
    return pFrames;
}

/**Function*************************************************************

  Synopsis    [Perform evaluation.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
480
void Unr_ManTest( Gia_Man_t * pGia, int nFrames )
Alan Mishchenko committed
481
{
482 483
    Gia_Man_t * pFrames0, * pFrames1;
    abctime clk = Abc_Clock();
484
    pFrames0 = Unr_ManUnroll( pGia, nFrames );
485 486 487 488 489
    Abc_PrintTime( 1, "Unroll ", Abc_Clock() - clk );
    clk = Abc_Clock();
    pFrames1 = Unr_ManUnrollSimple( pGia, nFrames );
    Abc_PrintTime( 1, "UnrollS", Abc_Clock() - clk );

490 491
Gia_ManPrintStats( pFrames0, NULL );
Gia_ManPrintStats( pFrames1, NULL );
492 493
Gia_AigerWrite( pFrames0, "frames0.aig", 0, 0 );
Gia_AigerWrite( pFrames1, "frames1.aig", 0, 0 );
494

495 496
    Gia_ManStop( pFrames0 );
    Gia_ManStop( pFrames1 );
Alan Mishchenko committed
497 498 499 500 501 502 503 504 505
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


ABC_NAMESPACE_IMPL_END