abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaFrames.c File Reference
#include "gia.h"

Go to the source code of this file.

Data Structures

struct  Gia_ManFra_t_
 
struct  Gia_ManUnr_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Gia_ManFra_t_ 
Gia_ManFra_t
 DECLARATIONS ///. More...
 
typedef struct Gia_ManUnr_t_ Gia_ManUnr_t
 

Functions

void Gia_ManUnrollDup_rec (Gia_Man_t *pNew, Gia_Obj_t *pObj, int Id)
 FUNCTION DEFINITIONS ///. More...
 
Gia_Man_tGia_ManUnrollDup (Gia_Man_t *p, Vec_Int_t *vLimit)
 
Vec_Ptr_tGia_ManUnrollAbs (Gia_Man_t *p, int nFrames)
 
Gia_ManUnr_tGia_ManUnrStart (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
void Gia_ManUnrollStop (void *pMan)
 
static void Gia_ObjUnrWrite (Gia_ManUnr_t *p, int Id, int Entry)
 
static int Gia_ObjUnrRead (Gia_ManUnr_t *p, int Id, int Degree)
 
static int Gia_ObjUnrReadCopy0 (Gia_ManUnr_t *p, Gia_Obj_t *pObj, int Id)
 
static int Gia_ObjUnrReadCopy1 (Gia_ManUnr_t *p, Gia_Obj_t *pObj, int Id)
 
static int Gia_ObjUnrReadCi (Gia_ManUnr_t *p, int Id, int f, Gia_Man_t *pNew)
 
void * Gia_ManUnrollStart (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
void * Gia_ManUnrollAdd (void *pMan, int fMax)
 
int Gia_ManUnrollLastLit (void *pMan)
 
Gia_Man_tGia_ManUnroll (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
Gia_Man_tGia_ManFrames2 (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
void Gia_ManFraSetDefaultParams (Gia_ParFra_t *p)
 
Gia_ManFra_tGia_ManFraStart (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
void Gia_ManFraStop (Gia_ManFra_t *p)
 
void Gia_ManFraSupports (Gia_ManFra_t *p)
 
Gia_Man_tGia_ManFramesInit (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
Gia_Man_tGia_ManFrames (Gia_Man_t *pAig, Gia_ParFra_t *pPars)
 
Gia_Man_tGia_ManFramesInitSpecial (Gia_Man_t *pAig, int nFrames, int fVerbose)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Gia_ManFra_t_ Gia_ManFra_t

DECLARATIONS ///.

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

FileName [giaFrames.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Timeframe unrolling.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
giaFrames.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file giaFrames.c.

typedef struct Gia_ManUnr_t_ Gia_ManUnr_t

Definition at line 41 of file giaFrames.c.

Function Documentation

Gia_Man_t* Gia_ManFrames ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 840 of file giaFrames.c.

841 {
842  Gia_Man_t * pFrames, * pTemp;
843  Gia_Obj_t * pObj;
844  Vec_Int_t * vPoLits = NULL;
845  int i, f;
846  assert( Gia_ManRegNum(pAig) > 0 );
847  assert( pPars->nFrames > 0 );
848  if ( pPars->fInit )
849  return Gia_ManFramesInit( pAig, pPars );
850  if ( pPars->fOrPos )
851  vPoLits = Vec_IntStart( Gia_ManPoNum(pAig) );
852  pFrames = Gia_ManStart( pPars->nFrames * Gia_ManObjNum(pAig) );
853  pFrames->pName = Abc_UtilStrsav( pAig->pName );
854  pFrames->pSpec = Abc_UtilStrsav( pAig->pSpec );
855  if ( !pPars->fDisableSt )
856  Gia_ManHashAlloc( pFrames );
857  Gia_ManConst0(pAig)->Value = 0;
858  // create primary inputs
859  for ( f = 0; f < pPars->nFrames; f++ )
860  Gia_ManForEachPi( pAig, pObj, i )
861  pObj->Value = Gia_ManAppendCi( pFrames );
862  // add internal nodes for each timeframe
863  for ( f = 0; f < pPars->nFrames; f++ )
864  {
865  if ( f == 0 )
866  {
867  Gia_ManForEachRo( pAig, pObj, i )
868  pObj->Value = Gia_ManAppendCi( pFrames );
869  }
870  else
871  {
872  Gia_ManForEachRo( pAig, pObj, i )
873  pObj->Value = Gia_ObjRoToRi( pAig, pObj )->Value;
874  }
875  Gia_ManForEachPi( pAig, pObj, i )
876  pObj->Value = Gia_Obj2Lit( pFrames, Gia_ManPi(pFrames, f * Gia_ManPiNum(pAig) + i) );
877  if ( !pPars->fDisableSt )
878  Gia_ManForEachAnd( pAig, pObj, i )
879  pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
880  else
881  Gia_ManForEachAnd( pAig, pObj, i )
882  pObj->Value = Gia_ManAppendAnd2( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
883  if ( vPoLits )
884  {
885  if ( !pPars->fDisableSt )
886  Gia_ManForEachPo( pAig, pObj, i )
887  Vec_IntWriteEntry( vPoLits, i, Gia_ManHashOr(pFrames, Vec_IntEntry(vPoLits, i), Gia_ObjFanin0Copy(pObj)) );
888  else
889  Gia_ManForEachPo( pAig, pObj, i )
891  }
892  else
893  {
894  Gia_ManForEachPo( pAig, pObj, i )
895  pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
896  }
897  if ( f == pPars->nFrames - 1 )
898  {
899  if ( vPoLits )
900  Gia_ManForEachPo( pAig, pObj, i )
901  pObj->Value = Gia_ManAppendCo( pFrames, Vec_IntEntry(vPoLits, i) );
902  Gia_ManForEachRi( pAig, pObj, i )
903  pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
904  }
905  else
906  {
907  Gia_ManForEachRi( pAig, pObj, i )
908  pObj->Value = Gia_ObjFanin0Copy(pObj);
909  }
910  }
911  Vec_IntFreeP( &vPoLits );
912  if ( !pPars->fDisableSt )
913  Gia_ManHashStop( pFrames );
914  Gia_ManSetRegNum( pFrames, Gia_ManRegNum(pAig) );
915  if ( Gia_ManCombMarkUsed(pFrames) < Gia_ManAndNum(pFrames) )
916  {
917  pFrames = Gia_ManDupMarked( pTemp = pFrames );
918  if ( pPars->fVerbose )
919  printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
920  Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) );
921  Gia_ManStop( pTemp );
922  }
923  else if ( pPars->fVerbose )
924  printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
925  Gia_ManAndNum(pFrames), Gia_ManAndNum(pFrames) );
926  return pFrames;
927 }
Gia_Man_t * Gia_ManDupMarked(Gia_Man_t *p)
Definition: giaDup.c:975
int nFrames
Definition: gia.h:227
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int fOrPos
Definition: gia.h:231
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
Definition: gia.h:75
Gia_Man_t * Gia_ManFramesInit(Gia_Man_t *pAig, Gia_ParFra_t *pPars)
Definition: giaFrames.c:727
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
int Gia_ManCombMarkUsed(Gia_Man_t *p)
Definition: giaScl.c:60
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
Definition: gia.h:405
char * pName
Definition: gia.h:97
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
int fVerbose
Definition: gia.h:232
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
char * pSpec
Definition: gia.h:98
else
Definition: sparse_int.h:55
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Gia_ManAppendAnd2(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:627
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
int fInit
Definition: gia.h:228
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:611
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
int fDisableSt
Definition: gia.h:230
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Gia_ManFrames2 ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis [Computes init/non-init unrolling without flops.]

Description []

SideEffects []

SeeAlso [] Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 608 of file giaFrames.c.

609 {
610  Gia_Man_t * pNew;
611  abctime clk = Abc_Clock();
612  pNew = Gia_ManUnroll( pAig, pPars );
613  if ( pPars->fVerbose )
614  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
615  return pNew;
616 }
Gia_Man_t * Gia_ManUnroll(Gia_Man_t *pAig, Gia_ParFra_t *pPars)
Definition: giaFrames.c:507
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int fVerbose
Definition: gia.h:232
Definition: gia.h:95
ABC_INT64_T abctime
Definition: abc_global.h:278
Gia_Man_t* Gia_ManFramesInit ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 727 of file giaFrames.c.

728 {
729  int fUseAllPis = 1;
730  Gia_Man_t * pFrames, * pTemp;
731  Gia_ManFra_t * p;
732  Gia_Obj_t * pObj;
733  Vec_Int_t * vIns, * vAnds, * vOuts;
734  int i, f;
735  p = Gia_ManFraStart( pAig, pPars );
736  Gia_ManFraSupports( p );
737  pFrames = Gia_ManStart( Vec_VecSizeSize((Vec_Vec_t*)p->vIns)+
738  Vec_VecSizeSize((Vec_Vec_t*)p->vAnds)+Vec_VecSizeSize((Vec_Vec_t*)p->vOuts) );
739  pFrames->pName = Abc_UtilStrsav( pAig->pName );
740  pFrames->pSpec = Abc_UtilStrsav( pAig->pSpec );
741  Gia_ManHashAlloc( pFrames );
742  Gia_ManConst0(pAig)->Value = 0;
743  for ( f = 0; f < pPars->nFrames; f++ )
744  {
745  vIns = (Vec_Int_t *)Vec_PtrEntry( p->vIns, f );
746  vAnds = (Vec_Int_t *)Vec_PtrEntry( p->vAnds, f );
747  vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vOuts, f );
748  if ( pPars->fVerbose )
749  printf( "Frame %3d : CI = %6d. AND = %6d. CO = %6d.\n",
750  f, Vec_IntSize(vIns), Vec_IntSize(vAnds), Vec_IntSize(vOuts) );
751  if ( fUseAllPis )
752  {
753  Gia_ManForEachPi( pAig, pObj, i )
754  pObj->Value = Gia_ManAppendCi( pFrames );
755  if ( f == 0 )
756  {
757  Gia_ManForEachObjVec( vIns, pAig, pObj, i )
758  {
759  assert( Gia_ObjIsCi(pObj) );
760  if ( !Gia_ObjIsPi(pAig, pObj) )
761  pObj->Value = 0;
762  }
763  }
764  else
765  {
766  Gia_ManForEachObjVec( vIns, pAig, pObj, i )
767  {
768  assert( Gia_ObjIsCi(pObj) );
769  if ( !Gia_ObjIsPi(pAig, pObj) )
770  pObj->Value = Gia_ObjRoToRi(pAig, pObj)->Value;
771  }
772  }
773  }
774  else
775  {
776  if ( f == 0 )
777  {
778  Gia_ManForEachObjVec( vIns, pAig, pObj, i )
779  {
780  assert( Gia_ObjIsCi(pObj) );
781  if ( Gia_ObjIsPi(pAig, pObj) )
782  pObj->Value = Gia_ManAppendCi( pFrames );
783  else
784  pObj->Value = 0;
785  }
786  }
787  else
788  {
789  Gia_ManForEachObjVec( vIns, pAig, pObj, i )
790  {
791  assert( Gia_ObjIsCi(pObj) );
792  if ( Gia_ObjIsPi(pAig, pObj) )
793  pObj->Value = Gia_ManAppendCi( pFrames );
794  else
795  pObj->Value = Gia_ObjRoToRi(pAig, pObj)->Value;
796  }
797  }
798  }
799  Gia_ManForEachObjVec( vAnds, pAig, pObj, i )
800  {
801  assert( Gia_ObjIsAnd(pObj) );
802  pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
803  }
804  Gia_ManForEachObjVec( vOuts, pAig, pObj, i )
805  {
806  assert( Gia_ObjIsCo(pObj) );
807  if ( Gia_ObjIsPo(pAig, pObj) )
808  pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
809  else
810  pObj->Value = Gia_ObjFanin0Copy(pObj);
811  }
812  }
813  Gia_ManFraStop( p );
814  Gia_ManHashStop( pFrames );
815  if ( Gia_ManCombMarkUsed(pFrames) < Gia_ManAndNum(pFrames) )
816  {
817  pFrames = Gia_ManDupMarked( pTemp = pFrames );
818  if ( pPars->fVerbose )
819  printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
820  Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) );
821  Gia_ManStop( pTemp );
822  }
823  else if ( pPars->fVerbose )
824  printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
825  Gia_ManAndNum(pFrames), Gia_ManAndNum(pFrames) );
826  return pFrames;
827 }
Gia_Man_t * Gia_ManDupMarked(Gia_Man_t *p)
Definition: giaDup.c:975
int nFrames
Definition: gia.h:227
Gia_ManFra_t * Gia_ManFraStart(Gia_Man_t *pAig, Gia_ParFra_t *pPars)
Definition: giaFrames.c:650
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
typedefABC_NAMESPACE_IMPL_START struct Gia_ManFra_t_ Gia_ManFra_t
DECLARATIONS ///.
Definition: giaFrames.c:30
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void Gia_ManFraStop(Gia_ManFra_t *p)
Definition: giaFrames.c:671
Definition: gia.h:75
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
int Gia_ManCombMarkUsed(Gia_Man_t *p)
Definition: giaScl.c:60
char * pName
Definition: gia.h:97
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
int fVerbose
Definition: gia.h:232
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
if(last==0)
Definition: sparse_int.h:34
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
static int Vec_VecSizeSize(Vec_Vec_t *p)
Definition: vecVec.h:417
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Gia_ObjIsPo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:442
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
void Gia_ManFraSupports(Gia_ManFra_t *p)
Definition: giaFrames.c:690
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ObjIsPi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:441
Gia_Man_t* Gia_ManFramesInitSpecial ( Gia_Man_t pAig,
int  nFrames,
int  fVerbose 
)

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

Synopsis [Perform init unrolling as long as PO(s) are constant 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 941 of file giaFrames.c.

942 {
943  Gia_Man_t * pFrames, * pTemp;
944  Gia_Obj_t * pObj;
945  int i, f;
946  assert( Gia_ManRegNum(pAig) > 0 );
947  if ( nFrames > 0 )
948  printf( "Computing specialized unrolling with %d frames...\n", nFrames );
949  pFrames = Gia_ManStart( Gia_ManObjNum(pAig) );
950  pFrames->pName = Abc_UtilStrsav( pAig->pName );
951  pFrames->pSpec = Abc_UtilStrsav( pAig->pSpec );
952  Gia_ManHashAlloc( pFrames );
953  Gia_ManConst0(pAig)->Value = 0;
954  for ( f = 0; nFrames == 0 || f < nFrames; f++ )
955  {
956  if ( fVerbose && (f % 100 == 0) )
957  {
958  printf( "%6d : ", f );
959  Gia_ManPrintStats( pFrames, NULL );
960  }
961  Gia_ManForEachRo( pAig, pObj, i )
962  pObj->Value = f ? Gia_ObjRoToRi( pAig, pObj )->Value : 0;
963  Gia_ManForEachPi( pAig, pObj, i )
964  pObj->Value = Gia_ManAppendCi( pFrames );
965  Gia_ManForEachAnd( pAig, pObj, i )
966  pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
967  Gia_ManForEachPo( pAig, pObj, i )
968  if ( Gia_ObjFanin0Copy(pObj) != 0 )
969  break;
970  if ( i < Gia_ManPoNum(pAig) )
971  break;
972  Gia_ManForEachRi( pAig, pObj, i )
973  pObj->Value = Gia_ObjFanin0Copy(pObj);
974  }
975  if ( fVerbose )
976  printf( "Computed prefix of %d frames.\n", f );
977  Gia_ManForEachRi( pAig, pObj, i )
978  Gia_ManAppendCo( pFrames, pObj->Value );
979  Gia_ManHashStop( pFrames );
980  pFrames = Gia_ManCleanup( pTemp = pFrames );
981  if ( fVerbose )
982  printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
983  Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) );
984  Gia_ManStop( pTemp );
985  return pFrames;
986 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
Definition: gia.h:75
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
char * pName
Definition: gia.h:97
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
if(last==0)
Definition: sparse_int.h:34
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Gia_ManFraSetDefaultParams ( Gia_ParFra_t p)

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

Synopsis [This procedure sets default parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 631 of file giaFrames.c.

632 {
633  memset( p, 0, sizeof(Gia_ParFra_t) );
634  p->nFrames = 32; // the number of frames to unroll
635  p->fInit = 0; // initialize the timeframes
636  p->fVerbose = 0; // enables verbose output
637 }
char * memset()
int nFrames
Definition: gia.h:227
int fVerbose
Definition: gia.h:232
int fInit
Definition: gia.h:228
Gia_ManFra_t* Gia_ManFraStart ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis [Creates manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 650 of file giaFrames.c.

651 {
652  Gia_ManFra_t * p;
653  p = ABC_ALLOC( Gia_ManFra_t, 1 );
654  memset( p, 0, sizeof(Gia_ManFra_t) );
655  p->pAig = pAig;
656  p->pPars = pPars;
657  return p;
658 }
char * memset()
typedefABC_NAMESPACE_IMPL_START struct Gia_ManFra_t_ Gia_ManFra_t
DECLARATIONS ///.
Definition: giaFrames.c:30
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Gia_ManFraStop ( Gia_ManFra_t p)

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

Synopsis [Deletes manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 671 of file giaFrames.c.

672 {
673  Vec_VecFree( (Vec_Vec_t *)p->vIns );
674  Vec_VecFree( (Vec_Vec_t *)p->vAnds );
675  Vec_VecFree( (Vec_Vec_t *)p->vOuts );
676  ABC_FREE( p );
677 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Gia_ManFraSupports ( Gia_ManFra_t p)

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

Synopsis [Computes supports of all timeframes.]

Description []

SideEffects []

SeeAlso []

Definition at line 690 of file giaFrames.c.

691 {
692  Vec_Int_t * vIns = NULL, * vAnds, * vOuts;
693  Gia_Obj_t * pObj;
694  int f, i;
695  p->vIns = Vec_PtrStart( p->pPars->nFrames );
696  p->vAnds = Vec_PtrStart( p->pPars->nFrames );
697  p->vOuts = Vec_PtrStart( p->pPars->nFrames );
699  for ( f = p->pPars->nFrames - 1; f >= 0; f-- )
700  {
701  vOuts = Gia_ManCollectPoIds( p->pAig );
702  if ( vIns )
703  Gia_ManForEachObjVec( vIns, p->pAig, pObj, i )
704  if ( Gia_ObjIsRo(p->pAig, pObj) )
705  Vec_IntPush( vOuts, Gia_ObjId( p->pAig, Gia_ObjRoToRi(p->pAig, pObj) ) );
706  vIns = Vec_IntAlloc( 100 );
707  Gia_ManCollectCis( p->pAig, Vec_IntArray(vOuts), Vec_IntSize(vOuts), vIns );
708  vAnds = Vec_IntAlloc( 100 );
709  Gia_ManCollectAnds( p->pAig, Vec_IntArray(vOuts), Vec_IntSize(vOuts), vAnds );
710  Vec_PtrWriteEntry( p->vIns, f, vIns );
711  Vec_PtrWriteEntry( p->vAnds, f, vAnds );
712  Vec_PtrWriteEntry( p->vOuts, f, vOuts );
713  }
714 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
if(last==0)
Definition: sparse_int.h:34
void Gia_ManCollectCis(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vSupp)
Definition: giaDfs.c:71
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Gia_ManCollectAnds(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vNodes)
Definition: giaDfs.c:123
Vec_Int_t * Gia_ManCollectPoIds(Gia_Man_t *p)
Definition: giaUtil.c:863
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
Gia_Man_t* Gia_ManUnroll ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis [Computes init/non-init unrolling without flops.]

Description []

SideEffects []

SeeAlso []

Definition at line 507 of file giaFrames.c.

508 {
509  Gia_ManUnr_t * p;
510  Gia_Man_t * pNew, * pTemp;
511  int fMax;
512  p = (Gia_ManUnr_t *)Gia_ManUnrollStart( pAig, pPars );
513  for ( fMax = 1; fMax <= p->pPars->nFrames; fMax++ )
514  Gia_ManUnrollAdd( p, fMax );
515  assert( Gia_ManPoNum(p->pNew) == p->pPars->nFrames * Gia_ManPoNum(p->pAig) );
516  Gia_ManHashStop( p->pNew );
517  Gia_ManSetRegNum( p->pNew, 0 );
518 // Gia_ManPrintStats( pNew, 0 );
519  // cleanup
520  p->pNew = Gia_ManCleanup( pTemp = p->pNew );
521  Gia_ManStop( pTemp );
522 // Gia_ManPrintStats( pNew, 0 );
523  pNew = p->pNew; p->pNew = NULL;
524  Gia_ManUnrollStop( p );
525  return pNew;
526 }
int nFrames
Definition: gia.h:227
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * Gia_ManUnrollStart(Gia_Man_t *pAig, Gia_ParFra_t *pPars)
Definition: giaFrames.c:402
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
Gia_Man_t * pAig
Definition: giaFrames.c:45
void * Gia_ManUnrollAdd(void *pMan, int fMax)
Definition: giaFrames.c:437
void Gia_ManUnrollStop(void *pMan)
Definition: giaFrames.c:310
Definition: gia.h:95
Gia_ParFra_t * pPars
Definition: giaFrames.c:44
Gia_Man_t * pNew
Definition: giaFrames.c:56
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
Vec_Ptr_t* Gia_ManUnrollAbs ( Gia_Man_t p,
int  nFrames 
)

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

Synopsis [Duplicates AIG for unrolling.]

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file giaFrames.c.

156 {
157  int fVerbose = 0;
158  Vec_Ptr_t * vFrames;
159  Vec_Int_t * vLimit, * vOne;
160  Gia_Man_t * pNew;
161  Gia_Obj_t * pObj;
162  int nObjBits, nObjMask;
163  int f, fMax, k, Entry, Prev, iStart, iStop, Size;
164  // get the bitmasks
165  nObjBits = Abc_Base2Log( Gia_ManObjNum(p) );
166  nObjMask = (1 << nObjBits) - 1;
167  assert( Gia_ManObjNum(p) <= nObjMask );
168  // derive the tents
169  vLimit = Vec_IntAlloc( 1000 );
170  pNew = Gia_ManUnrollDup( p, vLimit );
171  // debug printout
172  if ( fVerbose )
173  {
174  Prev = 1;
175  printf( "Tents: " );
176  Vec_IntForEachEntryStart( vLimit, Entry, k, 1 )
177  printf( "%d=%d ", k, Entry-Prev ), Prev = Entry;
178  printf( " Unused=%d", Gia_ManObjNum(p) - Gia_ManObjNum(pNew) );
179  printf( "\n" );
180  }
181  // create abstraction
182  vFrames = Vec_PtrAlloc( Vec_IntSize(vLimit) );
183  for ( fMax = 0; fMax < nFrames; fMax++ )
184  {
185  Size = (fMax+1 < Vec_IntSize(vLimit)) ? Vec_IntEntry(vLimit, fMax+1) : Gia_ManObjNum(pNew);
186  vOne = Vec_IntAlloc( Size );
187  for ( f = 0; f <= fMax; f++ )
188  {
189  iStart = (f < Vec_IntSize(vLimit)) ? Vec_IntEntry(vLimit, f ) : 0;
190  iStop = (f+1 < Vec_IntSize(vLimit)) ? Vec_IntEntry(vLimit, f+1) : 0;
191  for ( k = iStop - 1; k >= iStart; k-- )
192  {
193  assert( Gia_ManObj(pNew, k)->Value > 0 );
194  pObj = Gia_ManObj(p, Gia_ManObj(pNew, k)->Value);
195  if ( Gia_ObjIsCo(pObj) || Gia_ObjIsPi(p, pObj) )
196  continue;
197  assert( Gia_ObjIsRo(p, pObj) || Gia_ObjIsAnd(pObj) );
198  Entry = ((fMax-f) << nObjBits) | Gia_ObjId(p, pObj);
199  Vec_IntPush( vOne, Entry );
200 // printf( "%d ", Gia_ManObj(pNew, k)->Value );
201  }
202 // printf( "\n" );
203  }
204  // add in reverse topological order
205  Vec_IntSort( vOne, 1 );
206  Vec_PtrPush( vFrames, vOne );
207  assert( Vec_IntSize(vOne) <= Size - 1 );
208  }
209  Vec_IntFree( vLimit );
210  Gia_ManStop( pNew );
211  return vFrames;
212 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
Definition: vecInt.h:1293
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
for(p=first;p->value< newval;p=p->next)
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Definition: gia.h:95
static int Abc_Base2Log(unsigned n)
Definition: abc_global.h:251
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
Gia_Man_t * Gia_ManUnrollDup(Gia_Man_t *p, Vec_Int_t *vLimit)
Definition: giaFrames.c:107
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjIsPi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:441
void* Gia_ManUnrollAdd ( void *  pMan,
int  fMax 
)

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

Synopsis [Computes init/non-init unrolling without flops.]

Description []

SideEffects []

SeeAlso []

Definition at line 437 of file giaFrames.c.

438 {
439  Gia_ManUnr_t * p = (Gia_ManUnr_t *)pMan;
440  Gia_Obj_t * pObj;
441  int f, i, Lit, Beg, End;
442  // create PIs on demand
443  if ( p->pPars->fSaveLastLit )
444  for ( i = 0; i < Gia_ManPiNum(p->pAig); i++ )
445  Gia_ManAppendCi(p->pNew);
446  // unroll another timeframe
447  for ( f = 0; f < fMax; f++ )
448  {
449  if ( Vec_IntSize(p->vLimit) <= fMax-f )
450  continue;
451  Beg = Vec_IntEntry( p->vLimit, fMax-f-1 );
452  End = Vec_IntEntry( p->vLimit, fMax-f );
453  for ( i = Beg; i < End; i++ )
454  {
455  pObj = Gia_ManObj( p->pOrder, i );
456  if ( Gia_ObjIsAnd(pObj) )
457  Lit = Gia_ManHashAnd( p->pNew, Gia_ObjUnrReadCopy0(p, pObj, i), Gia_ObjUnrReadCopy1(p, pObj, i) );
458  else if ( Gia_ObjIsCo(pObj) )
459  {
460  Lit = Gia_ObjUnrReadCopy0(p, pObj, i);
461  if ( f == fMax-1 )
462  {
463  if ( p->pPars->fSaveLastLit )
464  p->LastLit = Lit;
465  else
466  Gia_ManAppendCo( p->pNew, Lit );
467  }
468  }
469  else if ( Gia_ObjIsCi(pObj) )
470  Lit = Gia_ObjUnrReadCi( p, i, f, p->pNew );
471  else assert( 0 );
472  assert( Lit >= 0 );
473  Gia_ObjUnrWrite( p, i, Lit ); // should be exactly one call for each obj!
474  }
475  }
476  return p->pNew;
477 }
static int Gia_ObjUnrReadCopy0(Gia_ManUnr_t *p, Gia_Obj_t *pObj, int Id)
Definition: giaFrames.c:352
static int Gia_ObjUnrReadCi(Gia_ManUnr_t *p, int Id, int f, Gia_Man_t *pNew)
Definition: giaFrames.c:362
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int fSaveLastLit
Definition: gia.h:229
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
Gia_Man_t * pOrder
Definition: giaFrames.c:47
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
Gia_Man_t * pAig
Definition: giaFrames.c:45
static int Gia_ObjUnrReadCopy1(Gia_ManUnr_t *p, Gia_Obj_t *pObj, int Id)
Definition: giaFrames.c:357
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static void Gia_ObjUnrWrite(Gia_ManUnr_t *p, int Id, int Entry)
Definition: giaFrames.c:335
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
Vec_Int_t * vLimit
Definition: giaFrames.c:48
Gia_ParFra_t * pPars
Definition: giaFrames.c:44
Gia_Man_t * pNew
Definition: giaFrames.c:56
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
Gia_Man_t* Gia_ManUnrollDup ( Gia_Man_t p,
Vec_Int_t vLimit 
)

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

Synopsis [Duplicates AIG for unrolling.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file giaFrames.c.

108 {
109  Gia_Man_t * pNew;
110  Gia_Obj_t * pObj;
111  int i;
112  assert( Vec_IntSize(vLimit) == 0 );
113  pNew = Gia_ManStart( Gia_ManObjNum(p) );
114  pNew->pName = Abc_UtilStrsav( p->pName );
115  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
116 
117  // save constant class
118  Gia_ManFillValue( p );
119  Gia_ManConst0(p)->Value = 0;
120  Vec_IntPush( vLimit, Gia_ManObjNum(pNew) );
121 
122  // create first class
123  Gia_ManForEachPo( p, pObj, i )
124  Gia_ManUnrollDup_rec( pNew, pObj, Gia_ObjId(p, pObj) );
125  Vec_IntPush( vLimit, Gia_ManObjNum(pNew) );
126 
127  // create next classes
128  for ( i = 1; i < Gia_ManObjNum(pNew); i++ )
129  {
130  if ( i == Vec_IntEntryLast(vLimit) )
131  Vec_IntPush( vLimit, Gia_ManObjNum(pNew) );
132  pObj = Gia_ManObj( p, Gia_ManObj(pNew, i)->Value );
133  if ( Gia_ObjIsRo(p, pObj) )
134  {
135  pObj = Gia_ObjRoToRi(p, pObj);
136  assert( !~pObj->Value );
137  Gia_ManUnrollDup_rec( pNew, pObj, Gia_ObjId(p, pObj) );
138  }
139  }
140  Gia_ManSetRegNum( pNew, 0 );
141  return pNew;
142 }
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
for(p=first;p->value< newval;p=p->next)
Definition: gia.h:75
char * pName
Definition: gia.h:97
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
void Gia_ManUnrollDup_rec(Gia_Man_t *pNew, Gia_Obj_t *pObj, int Id)
FUNCTION DEFINITIONS ///.
Definition: giaFrames.c:75
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManUnrollDup_rec ( Gia_Man_t pNew,
Gia_Obj_t pObj,
int  Id 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Duplicates AIG for unrolling.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file giaFrames.c.

76 {
77  if ( ~pObj->Value )
78  return;
79  if ( Gia_ObjIsCi(pObj) )
80  pObj->Value = Gia_ManAppendCi(pNew);
81  else if ( Gia_ObjIsCo(pObj) )
82  {
83  Gia_ManUnrollDup_rec( pNew, Gia_ObjFanin0(pObj), Gia_ObjFaninId0(pObj, Id) );
84  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
85  }
86  else if ( Gia_ObjIsAnd(pObj) )
87  {
88  Gia_ManUnrollDup_rec( pNew, Gia_ObjFanin0(pObj), Gia_ObjFaninId0(pObj, Id) );
89  Gia_ManUnrollDup_rec( pNew, Gia_ObjFanin1(pObj), Gia_ObjFaninId1(pObj, Id) );
90  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
91  }
92  else assert( 0 );
93  Gia_ManObj(pNew, Abc_Lit2Var(pObj->Value))->Value = Id;
94 }
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
void Gia_ManUnrollDup_rec(Gia_Man_t *pNew, Gia_Obj_t *pObj, int Id)
FUNCTION DEFINITIONS ///.
Definition: giaFrames.c:75
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
int Gia_ManUnrollLastLit ( void *  pMan)

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

Synopsis [Read the last literal.]

Description []

SideEffects []

SeeAlso []

Definition at line 490 of file giaFrames.c.

491 {
492  Gia_ManUnr_t * p = (Gia_ManUnr_t *)pMan;
493  return p->LastLit;
494 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void* Gia_ManUnrollStart ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis [Computes init/non-init unrolling without flops.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file giaFrames.c.

403 {
404  Gia_ManUnr_t * p;
405  int f, i;
406  // start
407  p = Gia_ManUnrStart( pAig, pPars );
408  // start timeframes
409  assert( p->pNew == NULL );
410  p->pNew = Gia_ManStart( 10000 );
411  p->pNew->pName = Abc_UtilStrsav( p->pAig->pName );
412  p->pNew->pSpec = Abc_UtilStrsav( p->pAig->pSpec );
413  Gia_ManHashAlloc( p->pNew );
414  // create combinational inputs
415  if ( !p->pPars->fSaveLastLit ) // only in the case when unrolling depth is known
416  for ( f = 0; f < p->pPars->nFrames; f++ )
417  for ( i = 0; i < Gia_ManPiNum(p->pAig); i++ )
418  Gia_ManAppendCi(p->pNew);
419  // create flop outputs
420  if ( !p->pPars->fInit ) // only in the case when initialization is not performed
421  for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
422  Gia_ManAppendCi(p->pNew);
423  return p;
424 }
int nFrames
Definition: gia.h:227
Gia_ManUnr_t * Gia_ManUnrStart(Gia_Man_t *pAig, Gia_ParFra_t *pPars)
Definition: giaFrames.c:225
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int fSaveLastLit
Definition: gia.h:229
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
Gia_Man_t * pAig
Definition: giaFrames.c:45
char * pName
Definition: gia.h:97
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
int fInit
Definition: gia.h:228
Gia_ParFra_t * pPars
Definition: giaFrames.c:44
Gia_Man_t * pNew
Definition: giaFrames.c:56
#define assert(ex)
Definition: util_old.h:213
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Gia_ManUnrollStop ( void *  pMan)

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

Synopsis [Deletes manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 310 of file giaFrames.c.

311 {
312  Gia_ManUnr_t * p = (Gia_ManUnr_t *)pMan;
313  Gia_ManStopP( &p->pOrder );
314  Vec_IntFreeP( &p->vLimit );
315  Vec_IntFreeP( &p->vRank );
316  Vec_IntFreeP( &p->vDegree );
317  Vec_IntFreeP( &p->vDegDiff );
318  Vec_IntFreeP( &p->vFirst );
319  Vec_IntFreeP( &p->vStore );
320  ABC_FREE( p );
321 }
Vec_Int_t * vDegree
Definition: giaFrames.c:51
Vec_Int_t * vFirst
Definition: giaFrames.c:53
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Gia_Man_t * pOrder
Definition: giaFrames.c:47
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
Vec_Int_t * vRank
Definition: giaFrames.c:50
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
Vec_Int_t * vStore
Definition: giaFrames.c:54
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Int_t * vLimit
Definition: giaFrames.c:48
Vec_Int_t * vDegDiff
Definition: giaFrames.c:52
Gia_ManUnr_t* Gia_ManUnrStart ( Gia_Man_t pAig,
Gia_ParFra_t pPars 
)

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

Synopsis [Creates manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file giaFrames.c.

226 {
227  Gia_ManUnr_t * p;
228  Gia_Obj_t * pObj;
229  int i, k, iRank, iFanin, Degree, Shift;
230  abctime clk = Abc_Clock();
231 
232  p = ABC_CALLOC( Gia_ManUnr_t, 1 );
233  p->pAig = pAig;
234  p->pPars = pPars;
235  // create order
236  p->vLimit = Vec_IntAlloc( 0 );
237  p->pOrder = Gia_ManUnrollDup( pAig, p->vLimit );
238 /*
239  Vec_IntForEachEntryStart( p->vLimit, Shift, i, 1 )
240  printf( "%d=%d ", i, Shift-Vec_IntEntry(p->vLimit, i-1) );
241  printf( "\n" );
242 */
243  // assign rank
245  for ( iRank = i = 0; i < Gia_ManObjNum(p->pOrder); Vec_IntPush(p->vRank, iRank), i++ )
246  if ( Vec_IntEntry(p->vLimit, iRank) == i )
247  iRank++;
248  assert( iRank == Vec_IntSize(p->vLimit)-1 );
250  // assign degree
253  Gia_ManForEachAnd( p->pOrder, pObj, i )
254  {
255  for ( k = 0; k < 2; k++ )
256  {
257  iFanin = k ? Gia_ObjFaninId1(pObj, i) : Gia_ObjFaninId0(pObj, i);
258  Degree = Vec_IntEntry(p->vRank, i) - Vec_IntEntry(p->vRank, iFanin);
259  Vec_IntWriteEntry( p->vDegDiff, 2*i + k, Degree );
260  if ( Vec_IntEntry(p->vDegree, iFanin) < Degree )
261  Vec_IntWriteEntry( p->vDegree, iFanin, Degree );
262  }
263  }
264  Gia_ManForEachCo( p->pOrder, pObj, k )
265  {
266  i = Gia_ObjId( p->pOrder, pObj );
267  iFanin = Gia_ObjFaninId0(pObj, i);
268  Degree = Vec_IntEntry(p->vRank, i) - Vec_IntEntry(p->vRank, iFanin);
269  Vec_IntWriteEntry( p->vDegDiff, 2*i, Degree );
270  if ( Vec_IntEntry(p->vDegree, iFanin) < Degree )
271  Vec_IntWriteEntry( p->vDegree, iFanin, Degree );
272  }
273  // assign first
276  for ( Shift = i = 0; i < Gia_ManObjNum(p->pOrder); i++ )
277  {
278  Vec_IntPush( p->vFirst, Shift );
279  Vec_IntWriteEntry( p->vStore, Shift, 1 + Vec_IntEntry(p->vDegree, i) );
280  Shift += 2 + Vec_IntEntry(p->vDegree, i);
281  }
282  assert( Shift == Vec_IntSize(p->vStore) );
283  // cleanup
284  Vec_IntFreeP( &p->vRank );
285  Vec_IntFreeP( &p->vDegree );
286 
287  // print verbose output
288  if ( pPars->fVerbose )
289  {
290  printf( "Convergence = %d. Dangling objects = %d. Average degree = %.3f ",
291  Vec_IntSize(p->vLimit) - 1,
292  Gia_ManObjNum(pAig) - Gia_ManObjNum(p->pOrder),
293  1.0*Vec_IntSize(p->vStore)/Gia_ManObjNum(p->pOrder) - 1.0 );
294  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
295  }
296  return p;
297 }
Vec_Int_t * vDegree
Definition: giaFrames.c:51
Vec_Int_t * vFirst
Definition: giaFrames.c:53
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Gia_Man_t * pOrder
Definition: giaFrames.c:47
static abctime Abc_Clock()
Definition: abc_global.h:279
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
Definition: gia.h:75
Gia_Man_t * pAig
Definition: giaFrames.c:45
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
Vec_Int_t * vRank
Definition: giaFrames.c:50
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int fVerbose
Definition: gia.h:232
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Vec_IntSum(Vec_Int_t *p)
Definition: vecInt.h:1137
Vec_Int_t * vStore
Definition: giaFrames.c:54
Vec_Int_t * vLimit
Definition: giaFrames.c:48
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Gia_Man_t * Gia_ManUnrollDup(Gia_Man_t *p, Vec_Int_t *vLimit)
Definition: giaFrames.c:107
Gia_ParFra_t * pPars
Definition: giaFrames.c:44
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
Vec_Int_t * vDegDiff
Definition: giaFrames.c:52
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static int Gia_ObjUnrRead ( Gia_ManUnr_t p,
int  Id,
int  Degree 
)
inlinestatic

Definition at line 342 of file giaFrames.c.

343 {
344  int * pArray = Vec_IntEntryP( p->vStore, Vec_IntEntry(p->vFirst, Id) );
345  if ( Id == 0 )
346  return 0;
347  assert( Degree >= 0 && Degree < pArray[0] );
348  if ( Degree )
349  Degree--;
350  return pArray[Degree + 1];
351 }
Vec_Int_t * vFirst
Definition: giaFrames.c:53
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Vec_Int_t * vStore
Definition: giaFrames.c:54
#define assert(ex)
Definition: util_old.h:213
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static int Gia_ObjUnrReadCi ( Gia_ManUnr_t p,
int  Id,
int  f,
Gia_Man_t pNew 
)
inlinestatic

Definition at line 362 of file giaFrames.c.

363 {
364  Gia_Obj_t * pObj = Gia_ManObj( p->pOrder, Id );
365  Gia_Obj_t * pObjReal = Gia_ManObj( p->pAig, pObj->Value );
366  assert( Gia_ObjIsCi(pObjReal) );
367  if ( Gia_ObjIsPi(p->pAig, pObjReal) )
368  {
369  if ( !p->pPars->fSaveLastLit )
370  pObj = Gia_ManPi( pNew, Gia_ManPiNum(p->pAig) * f + Gia_ObjCioId(pObjReal) );
371  else
372  pObj = Gia_ManPi( pNew, Gia_ManRegNum(p->pAig) + Gia_ManPiNum(p->pAig) * f + Gia_ObjCioId(pObjReal) );
373  return Abc_Var2Lit( Gia_ObjId(pNew, pObj), 0 );
374  }
375  if ( f == 0 ) // initialize!
376  {
377  if ( p->pPars->fInit )
378  return 0;
379  assert( Gia_ObjCioId(pObjReal) >= Gia_ManPiNum(p->pAig) );
380  if ( !p->pPars->fSaveLastLit )
381  pObj = Gia_ManPi( pNew, Gia_ManPiNum(p->pAig) * p->pPars->nFrames + Gia_ObjCioId(pObjReal)-Gia_ManPiNum(p->pAig) );
382  else
383  pObj = Gia_ManPi( pNew, Gia_ObjCioId(pObjReal)-Gia_ManPiNum(p->pAig) );
384  return Abc_Var2Lit( Gia_ObjId(pNew, pObj), 0 );
385  }
386  pObj = Gia_ManObj( p->pOrder, Abc_Lit2Var(Gia_ObjRoToRi(p->pAig, pObjReal)->Value) );
387  assert( Gia_ObjIsCo(pObj) );
388  return Gia_ObjUnrRead( p, Gia_ObjId(p->pOrder, pObj), 0 );
389 }
int nFrames
Definition: gia.h:227
int fSaveLastLit
Definition: gia.h:229
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Gia_Man_t * pOrder
Definition: giaFrames.c:47
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
Gia_Man_t * pAig
Definition: giaFrames.c:45
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
Definition: gia.h:405
static Gia_Obj_t * Gia_ObjRoToRi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:446
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int fInit
Definition: gia.h:228
static int Gia_ObjUnrRead(Gia_ManUnr_t *p, int Id, int Degree)
Definition: giaFrames.c:342
Gia_ParFra_t * pPars
Definition: giaFrames.c:44
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
static int Gia_ObjIsPi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:441
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
static int Gia_ObjUnrReadCopy0 ( Gia_ManUnr_t p,
Gia_Obj_t pObj,
int  Id 
)
inlinestatic

Definition at line 352 of file giaFrames.c.

353 {
354  int Lit = Gia_ObjUnrRead(p, Gia_ObjFaninId0(pObj, Id), Vec_IntEntry(p->vDegDiff, 2*Id));
355  return Abc_LitNotCond( Lit, Gia_ObjFaninC0(pObj) );
356 }
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Gia_ObjUnrRead(Gia_ManUnr_t *p, int Id, int Degree)
Definition: giaFrames.c:342
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Vec_Int_t * vDegDiff
Definition: giaFrames.c:52
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static int Gia_ObjUnrReadCopy1 ( Gia_ManUnr_t p,
Gia_Obj_t pObj,
int  Id 
)
inlinestatic

Definition at line 357 of file giaFrames.c.

358 {
359  int Lit = Gia_ObjUnrRead(p, Gia_ObjFaninId1(pObj, Id), Vec_IntEntry(p->vDegDiff, 2*Id+1));
360  return Abc_LitNotCond( Lit, Gia_ObjFaninC1(pObj) );
361 }
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Gia_ObjUnrRead(Gia_ManUnr_t *p, int Id, int Degree)
Definition: giaFrames.c:342
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
Vec_Int_t * vDegDiff
Definition: giaFrames.c:52
static void Gia_ObjUnrWrite ( Gia_ManUnr_t p,
int  Id,
int  Entry 
)
inlinestatic

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

Synopsis [Reading/writing entry from storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file giaFrames.c.

336 {
337  int i, * pArray = Vec_IntEntryP( p->vStore, Vec_IntEntry(p->vFirst, Id) );
338  for ( i = pArray[0]; i > 1; i-- )
339  pArray[i] = pArray[i-1];
340  pArray[1] = Entry;
341 }
Vec_Int_t * vFirst
Definition: giaFrames.c:53
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Vec_Int_t * vStore
Definition: giaFrames.c:54
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417