diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-07-06 20:41:11 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-07-06 20:41:11 -0700 |
commit | 5008b1a4f3052402c47d954756e750db55743c11 (patch) | |
tree | 275701e5ecb6c7c60142352f2ec8e5f4bc9b77ad /src/aig/gia | |
parent | e879f0f6d1dde4ab92deec299998ec6a95baf1cd (diff) | |
download | abc-5008b1a4f3052402c47d954756e750db55743c11.tar.gz abc-5008b1a4f3052402c47d954756e750db55743c11.tar.bz2 abc-5008b1a4f3052402c47d954756e750db55743c11.zip |
Commands &fla_gla/&gla_fla to convert between flop-level and gate-level abstraction.
Diffstat (limited to 'src/aig/gia')
-rw-r--r-- | src/aig/gia/gia.h | 8 | ||||
-rw-r--r-- | src/aig/gia/giaAbsVta.c | 71 | ||||
-rw-r--r-- | src/aig/gia/giaUtil.c | 153 |
3 files changed, 157 insertions, 75 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 0d1c6ff1..e56e88aa 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -703,10 +703,6 @@ extern int Gia_ManGlaPbaPerform( Gia_Man_t * pGia, void * pPars, extern int Gia_GlaPerform( Gia_Man_t * p, Gia_ParVta_t * pPars, int fStartVta ); /*=== giaAbsVta.c ===========================================================*/ extern void Gia_VtaSetDefaultParams( Gia_ParVta_t * p ); -extern Vec_Ptr_t * Gia_VtaAbsToFrames( Vec_Int_t * vAbs ); -extern Vec_Int_t * Gia_VtaFramesToAbs( Vec_Vec_t * vFrames ); -extern Vec_Int_t * Gia_VtaConvertToGla( Gia_Man_t * p, Vec_Int_t * vVta ); -extern Vec_Int_t * Gia_VtaConvertFromGla( Gia_Man_t * p, Vec_Int_t * vGla, int nFrames ); extern int Gia_VtaPerform( Gia_Man_t * pAig, Gia_ParVta_t * pPars ); /*=== giaAiger.c ===========================================================*/ extern int Gia_FileSize( char * pFileName ); @@ -942,6 +938,10 @@ extern void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj ); extern int Gia_ManVerifyCex( Gia_Man_t * pAig, Abc_Cex_t * p, int fDualOut ); extern int Gia_ManFindFailedPoCex( Gia_Man_t * pAig, Abc_Cex_t * p, int nOutputs ); extern void Gia_ManInvertConstraints( Gia_Man_t * pAig ); +extern Vec_Int_t * Gia_VtaConvertToGla( Gia_Man_t * p, Vec_Int_t * vVta ); +extern Vec_Int_t * Gia_VtaConvertFromGla( Gia_Man_t * p, Vec_Int_t * vGla, int nFrames ); +extern Vec_Int_t * Gia_FlaConvertToGla( Gia_Man_t * p, Vec_Int_t * vFla ); +extern Vec_Int_t * Gia_GlaConvertToFla( Gia_Man_t * p, Vec_Int_t * vGla ); /*=== giaCTas.c ===========================================================*/ typedef struct Tas_Man_t_ Tas_Man_t; diff --git a/src/aig/gia/giaAbsVta.c b/src/aig/gia/giaAbsVta.c index e762c112..e7e5e7a6 100644 --- a/src/aig/gia/giaAbsVta.c +++ b/src/aig/gia/giaAbsVta.c @@ -228,77 +228,6 @@ Vec_Int_t * Gia_VtaFramesToAbs( Vec_Vec_t * vFrames ) /**Function************************************************************* - Synopsis [Converting VTA vector to GLA vector.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Vec_Int_t * Gia_VtaConvertToGla( Gia_Man_t * p, Vec_Int_t * vVta ) -{ - Gia_Obj_t * pObj; - Vec_Int_t * vGla; - int nObjMask, nObjs = Gia_ManObjNum(p); - int i, Entry, nFrames = Vec_IntEntry( vVta, 0 ); - assert( Vec_IntEntry(vVta, nFrames+1) == Vec_IntSize(vVta) ); - // get the bitmask - nObjMask = (1 << Abc_Base2Log(nObjs)) - 1; - assert( nObjs <= nObjMask ); - // go through objects - vGla = Vec_IntStart( nObjs ); - Vec_IntWriteEntry( vGla, 0, 1 ); - Vec_IntForEachEntryStart( vVta, Entry, i, nFrames+2 ) - { - pObj = Gia_ManObj( p, (Entry & nObjMask) ); - assert( Gia_ObjIsRo(p, pObj) || Gia_ObjIsAnd(pObj) || Gia_ObjIsConst0(pObj) ); - Vec_IntWriteEntry( vGla, (Entry & nObjMask), 1 ); - } - return vGla; -} - -/**Function************************************************************* - - Synopsis [Converting GLA vector to VTA vector.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Vec_Int_t * Gia_VtaConvertFromGla( Gia_Man_t * p, Vec_Int_t * vGla, int nFrames ) -{ - Vec_Int_t * vVta; - int nObjBits, nObjMask, nObjs = Gia_ManObjNum(p); - int i, k, j, Entry, Counter, nGlaSize; - //. get the GLA size - nGlaSize = Vec_IntSum(vGla); - // get the bitmask - nObjBits = Abc_Base2Log(nObjs); - nObjMask = (1 << Abc_Base2Log(nObjs)) - 1; - assert( nObjs <= nObjMask ); - // go through objects - vVta = Vec_IntAlloc( 1000 ); - Vec_IntPush( vVta, nFrames ); - Counter = nFrames + 2; - for ( i = 0; i <= nFrames; i++, Counter += i * nGlaSize ) - Vec_IntPush( vVta, Counter ); - for ( i = 0; i < nFrames; i++ ) - for ( k = 0; k <= i; k++ ) - Vec_IntForEachEntry( vGla, Entry, j ) - if ( Entry ) - Vec_IntPush( vVta, (k << nObjBits) | j ); - Counter = Vec_IntEntry(vVta, nFrames+1); - assert( Vec_IntEntry(vVta, nFrames+1) == Vec_IntSize(vVta) ); - return vVta; -} - -/**Function************************************************************* - Synopsis [Detects how many frames are completed.] Description [] diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c index 6f6bf0fa..1a6789b5 100644 --- a/src/aig/gia/giaUtil.c +++ b/src/aig/gia/giaUtil.c @@ -1278,6 +1278,159 @@ void Gia_ManInvertConstraints( Gia_Man_t * pAig ) } } +/**Function************************************************************* + + Synopsis [Converting VTA vector to GLA vector.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_VtaConvertToGla( Gia_Man_t * p, Vec_Int_t * vVta ) +{ + Gia_Obj_t * pObj; + Vec_Int_t * vGla; + int nObjMask, nObjs = Gia_ManObjNum(p); + int i, Entry, nFrames = Vec_IntEntry( vVta, 0 ); + assert( Vec_IntEntry(vVta, nFrames+1) == Vec_IntSize(vVta) ); + // get the bitmask + nObjMask = (1 << Abc_Base2Log(nObjs)) - 1; + assert( nObjs <= nObjMask ); + // go through objects + vGla = Vec_IntStart( nObjs ); + Vec_IntWriteEntry( vGla, 0, 1 ); + Vec_IntForEachEntryStart( vVta, Entry, i, nFrames+2 ) + { + pObj = Gia_ManObj( p, (Entry & nObjMask) ); + assert( Gia_ObjIsRo(p, pObj) || Gia_ObjIsAnd(pObj) || Gia_ObjIsConst0(pObj) ); + Vec_IntWriteEntry( vGla, (Entry & nObjMask), 1 ); + } + return vGla; +} + +/**Function************************************************************* + + Synopsis [Converting GLA vector to VTA vector.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_VtaConvertFromGla( Gia_Man_t * p, Vec_Int_t * vGla, int nFrames ) +{ + Vec_Int_t * vVta; + int nObjBits, nObjMask, nObjs = Gia_ManObjNum(p); + int i, k, j, Entry, Counter, nGlaSize; + //. get the GLA size + nGlaSize = Vec_IntSum(vGla); + // get the bitmask + nObjBits = Abc_Base2Log(nObjs); + nObjMask = (1 << Abc_Base2Log(nObjs)) - 1; + assert( nObjs <= nObjMask ); + // go through objects + vVta = Vec_IntAlloc( 1000 ); + Vec_IntPush( vVta, nFrames ); + Counter = nFrames + 2; + for ( i = 0; i <= nFrames; i++, Counter += i * nGlaSize ) + Vec_IntPush( vVta, Counter ); + for ( i = 0; i < nFrames; i++ ) + for ( k = 0; k <= i; k++ ) + Vec_IntForEachEntry( vGla, Entry, j ) + if ( Entry ) + Vec_IntPush( vVta, (k << nObjBits) | j ); + Counter = Vec_IntEntry(vVta, nFrames+1); + assert( Vec_IntEntry(vVta, nFrames+1) == Vec_IntSize(vVta) ); + return vVta; +} + +/**Function************************************************************* + + Synopsis [Converting GLA vector to FLA vector.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_FlaConvertToGla_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vGla ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + Vec_IntWriteEntry( vGla, Gia_ObjId(p, pObj), 1 ); + if ( Gia_ObjIsRo(p, pObj) ) + return; + assert( Gia_ObjIsAnd(pObj) ); + Gia_FlaConvertToGla_rec( p, Gia_ObjFanin0(pObj), vGla ); + Gia_FlaConvertToGla_rec( p, Gia_ObjFanin1(pObj), vGla ); +} + +/**Function************************************************************* + + Synopsis [Converting FLA vector to GLA vector.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_FlaConvertToGla( Gia_Man_t * p, Vec_Int_t * vFla ) +{ + Vec_Int_t * vGla; + Gia_Obj_t * pObj; + int i; + // mark const0 and relevant CI objects + Gia_ManIncrementTravId( p ); + Gia_ObjSetTravIdCurrent(p, Gia_ManConst0(p)); + Gia_ManForEachPi( p, pObj, i ) + Gia_ObjSetTravIdCurrent(p, pObj); + Gia_ManForEachRo( p, pObj, i ) + if ( !Vec_IntEntry(vFla, i) ) + Gia_ObjSetTravIdCurrent(p, pObj); + // label all objects reachable from the PO and selected flops + vGla = Vec_IntStart( Gia_ManObjNum(p) ); + Vec_IntWriteEntry( vGla, 0, 1 ); + Gia_ManForEachPo( p, pObj, i ) + Gia_FlaConvertToGla_rec( p, Gia_ObjFanin0(pObj), vGla ); + Gia_ManForEachRi( p, pObj, i ) + if ( Vec_IntEntry(vFla, i) ) + Gia_FlaConvertToGla_rec( p, Gia_ObjFanin0(pObj), vGla ); + return vGla; +} + +/**Function************************************************************* + + Synopsis [Converting GLA vector to FLA vector.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_GlaConvertToFla( Gia_Man_t * p, Vec_Int_t * vGla ) +{ + Vec_Int_t * vFla; + Gia_Obj_t * pObj; + int i; + vFla = Vec_IntStart( Gia_ManRegNum(p) ); + Gia_ManForEachRo( p, pObj, i ) + if ( Vec_IntEntry(vGla, Gia_ObjId(p, pObj)) ) + Vec_IntWriteEntry( vFla, i, 1 ); + return vFla; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// |