Commit be9a35c0 by Miodrag Milanovic

Merge remote-tracking branch 'upstream/master' into yosys-experimental

parents ab5b16ed 70cb339f
......@@ -88,10 +88,6 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\src\aig\gia\giaSif.c
# End Source File
# Begin Source File
SOURCE=.\src\base\main\main.c
# End Source File
# End Group
......
......@@ -5191,6 +5191,10 @@ SOURCE=.\src\aig\gia\giaSatoko.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaSatSyn.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaScl.c
# End Source File
# Begin Source File
......@@ -5295,6 +5299,10 @@ SOURCE=.\src\aig\gia\giaTsim.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaTtopt.cpp
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaUnate.c
# End Source File
# Begin Source File
......
......@@ -527,18 +527,22 @@ static inline int Gia_ObjDiff1( Gia_Obj_t * pObj ) {
static inline int Gia_ObjFaninC0( Gia_Obj_t * pObj ) { return pObj->fCompl0; }
static inline int Gia_ObjFaninC1( Gia_Obj_t * pObj ) { return pObj->fCompl1; }
static inline int Gia_ObjFaninC2( Gia_Man_t * p, Gia_Obj_t * pObj ) { return p->pMuxes && Abc_LitIsCompl(p->pMuxes[Gia_ObjId(p, pObj)]); }
static inline int Gia_ObjFaninC( Gia_Obj_t * pObj, int n ) { return n ? Gia_ObjFaninC1(pObj) : Gia_ObjFaninC0(pObj); }
static inline Gia_Obj_t * Gia_ObjFanin0( Gia_Obj_t * pObj ) { return pObj - pObj->iDiff0; }
static inline Gia_Obj_t * Gia_ObjFanin1( Gia_Obj_t * pObj ) { return pObj - pObj->iDiff1; }
static inline Gia_Obj_t * Gia_ObjFanin2( Gia_Man_t * p, Gia_Obj_t * pObj ) { return p->pMuxes ? Gia_ManObj(p, Abc_Lit2Var(p->pMuxes[Gia_ObjId(p, pObj)])) : NULL; }
static inline Gia_Obj_t * Gia_ObjFanin( Gia_Obj_t * pObj, int n ) { return n ? Gia_ObjFanin1(pObj) : Gia_ObjFanin0(pObj); }
static inline Gia_Obj_t * Gia_ObjChild0( Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin0(pObj), Gia_ObjFaninC0(pObj) ); }
static inline Gia_Obj_t * Gia_ObjChild1( Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin1(pObj), Gia_ObjFaninC1(pObj) ); }
static inline Gia_Obj_t * Gia_ObjChild2( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin2(p, pObj), Gia_ObjFaninC2(p, pObj) ); }
static inline int Gia_ObjFaninId0( Gia_Obj_t * pObj, int ObjId ) { return ObjId - pObj->iDiff0; }
static inline int Gia_ObjFaninId1( Gia_Obj_t * pObj, int ObjId ) { return ObjId - pObj->iDiff1; }
static inline int Gia_ObjFaninId2( Gia_Man_t * p, int ObjId ) { return (p->pMuxes && p->pMuxes[ObjId]) ? Abc_Lit2Var(p->pMuxes[ObjId]) : -1; }
static inline int Gia_ObjFaninId( Gia_Obj_t * pObj, int ObjId, int n ){ return n ? Gia_ObjFaninId1(pObj, ObjId) : Gia_ObjFaninId0(pObj, ObjId); }
static inline int Gia_ObjFaninId0p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjFaninId0( pObj, Gia_ObjId(p, pObj) ); }
static inline int Gia_ObjFaninId1p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjFaninId1( pObj, Gia_ObjId(p, pObj) ); }
static inline int Gia_ObjFaninId2p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return (p->pMuxes && p->pMuxes[Gia_ObjId(p, pObj)]) ? Abc_Lit2Var(p->pMuxes[Gia_ObjId(p, pObj)]) : -1; }
static inline int Gia_ObjFaninIdp( Gia_Man_t * p, Gia_Obj_t * pObj, int n){ return n ? Gia_ObjFaninId1p(p, pObj) : Gia_ObjFaninId0p(p, pObj); }
static inline int Gia_ObjFaninLit0( Gia_Obj_t * pObj, int ObjId ) { return Abc_Var2Lit( Gia_ObjFaninId0(pObj, ObjId), Gia_ObjFaninC0(pObj) ); }
static inline int Gia_ObjFaninLit1( Gia_Obj_t * pObj, int ObjId ) { return Abc_Var2Lit( Gia_ObjFaninId1(pObj, ObjId), Gia_ObjFaninC1(pObj) ); }
static inline int Gia_ObjFaninLit2( Gia_Man_t * p, int ObjId ) { return (p->pMuxes && p->pMuxes[ObjId]) ? p->pMuxes[ObjId] : -1; }
......@@ -1544,6 +1548,9 @@ extern Gia_Man_t * Gia_ManReadMiniAig( char * pFileName, int fGiaSimple
extern void Gia_ManWriteMiniAig( Gia_Man_t * pGia, char * pFileName );
extern Gia_Man_t * Gia_ManReadMiniLut( char * pFileName );
extern void Gia_ManWriteMiniLut( Gia_Man_t * pGia, char * pFileName );
/*=== giaMinLut.c ===========================================================*/
extern word * Gia_ManCountFraction( Gia_Man_t * p, Vec_Wrd_t * vSimI, Vec_Int_t * vSupp, int Thresh, int fVerbose, int * pCare );
extern Vec_Int_t * Gia_ManCollectSuppNew( Gia_Man_t * p, int iOut, int nOuts );
/*=== giaMuxes.c ===========================================================*/
extern void Gia_ManCountMuxXor( Gia_Man_t * p, int * pnMuxes, int * pnXors );
extern void Gia_ManPrintMuxStats( Gia_Man_t * p );
......@@ -1754,6 +1761,10 @@ extern int Gia_ManCountPosWithNonZeroDrivers( Gia_Man_t * p );
extern void Gia_ManUpdateCopy( Vec_Int_t * vCopy, Gia_Man_t * p );
extern Vec_Int_t * Gia_ManComputeDistance( Gia_Man_t * p, int iObj, Vec_Int_t * vObjs, int fVerbose );
/*=== giaTtopt.c ===========================================================*/
extern Gia_Man_t * Gia_ManTtopt( Gia_Man_t * p, int nIns, int nOuts, int nRounds );
extern Gia_Man_t * Gia_ManTtoptCare( Gia_Man_t * p, int nIns, int nOuts, int nRounds, char * pFileName, int nRarity );
/*=== giaCTas.c ===========================================================*/
typedef struct Tas_Man_t_ Tas_Man_t;
extern Tas_Man_t * Tas_ManAlloc( Gia_Man_t * pAig, int nBTLimit );
......@@ -1763,7 +1774,6 @@ extern void Tas_ManSatPrintStats( Tas_Man_t * p );
extern int Tas_ManSolve( Tas_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pObj2 );
extern int Tas_ManSolveArray( Tas_Man_t * p, Vec_Ptr_t * vObjs );
ABC_NAMESPACE_HEADER_END
......
......@@ -20,6 +20,7 @@
#include "gia.h"
#include "misc/util/utilTruth.h"
#include "misc/vec/vecHsh.h"
ABC_NAMESPACE_IMPL_START
......@@ -29,7 +30,7 @@ ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
#define GIA_MAX_CUTSIZE 8
#define GIA_MAX_CUTNUM 51
#define GIA_MAX_CUTNUM 65
#define GIA_MAX_TT_WORDS ((GIA_MAX_CUTSIZE > 6) ? 1 << (GIA_MAX_CUTSIZE-6) : 1)
#define GIA_CUT_NO_LEAF 0xF
......@@ -778,6 +779,218 @@ void Gia_ManExtractTest( Gia_Man_t * pGia )
Abc_PrintTime( 0, "Creating windows", Abc_Clock() - clk );
}
/**Function*************************************************************
Synopsis [Extract a given number of cuts.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_StoCutPrint( int * pCut )
{
int v;
printf( "{" );
for ( v = 1; v <= pCut[0]; v++ )
printf( " %d", pCut[v] );
printf( " }\n" );
}
void Gia_StoPrintCuts( Vec_Int_t * vThis, int iObj, int nCutSize )
{
int i, * pCut;
printf( "Cuts of node %d (size = %d):\n", iObj, nCutSize );
Sdb_ForEachCut( Vec_IntArray(vThis), pCut, i )
if ( !nCutSize || pCut[0] == nCutSize )
Gia_StoCutPrint( pCut );
}
Vec_Wec_t * Gia_ManFilterCuts( Gia_Man_t * pGia, Vec_Wec_t * vStore, int nCutSize, int nCuts )
{
abctime clkStart = Abc_Clock();
Vec_Wec_t * vCutsSel = Vec_WecAlloc( nCuts );
Vec_Int_t * vLevel, * vCut = Vec_IntAlloc( 10 );
Vec_Wec_t * vCuts = Vec_WecAlloc( 1000 );
Hsh_VecMan_t * p = Hsh_VecManStart( 1000 ); int i, s;
Vec_WecForEachLevel( vStore, vLevel, i ) if ( Vec_IntSize(vLevel) )
{
int v, k, * pCut, Value;
Sdb_ForEachCut( Vec_IntArray(vLevel), pCut, k )
{
if ( pCut[0] < 2 )
continue;
for ( v = 1; v <= pCut[0]; v++ )
if ( pCut[v] < 9 )
break;
if ( v <= pCut[0] )
continue;
Vec_IntClear( vCut );
Vec_IntPushArray( vCut, pCut+1, pCut[0] );
Value = Hsh_VecManAdd( p, vCut );
if ( Value == Vec_WecSize(vCuts) )
{
Vec_Int_t * vTemp = Vec_WecPushLevel(vCuts);
Vec_IntPush( vTemp, 0 );
Vec_IntAppend( vTemp, vCut );
}
Vec_IntAddToEntry( Vec_WecEntry(vCuts, Value), 0, 1 );
}
}
printf( "Collected cuts = %d.\n", Vec_WecSize(vCuts) );
for ( s = 3; s <= nCutSize; s++ )
Vec_WecForEachLevel( vCuts, vLevel, i )
if ( Vec_IntSize(vLevel) - 1 == s )
{
int * pCut = Vec_IntEntryP(vLevel, 1);
int u, v, Value;
for ( u = 0; u < s; u++ )
{
Vec_IntClear( vCut );
for ( v = 0; v < s; v++ ) if ( v != u )
Vec_IntPush( vCut, pCut[v] );
assert( Vec_IntSize(vCut) == s-1 );
Value = Hsh_VecManAdd( p, vCut );
if ( Value < Vec_WecSize(vCuts) )
Vec_IntAddToEntry( vLevel, 0, Vec_IntEntry(Vec_WecEntry(vCuts, Value), 0) );
}
}
Hsh_VecManStop( p );
Vec_IntFree( vCut );
// collect
Vec_WecSortByFirstInt( vCuts, 1 );
Vec_WecForEachLevelStop( vCuts, vLevel, i, Abc_MinInt(Vec_WecSize(vCuts), nCuts) )
Vec_IntAppend( Vec_WecPushLevel(vCutsSel), vLevel );
Abc_PrintTime( 0, "Cut filtering time", Abc_Clock() - clkStart );
return vCutsSel;
}
int Gia_ManCountRefs( Gia_Man_t * pGia, Vec_Int_t * vLevel )
{
int i, iObj, nRefs = 0;
Vec_IntForEachEntry( vLevel, iObj, i )
nRefs += Gia_ObjRefNumId(pGia, iObj);
return nRefs;
}
Vec_Wrd_t * Gia_ManGenSims( Gia_Man_t * pGia )
{
Vec_Wrd_t * vSims;
Vec_WrdFreeP( &pGia->vSimsPi );
pGia->vSimsPi = Vec_WrdStartTruthTables( Gia_ManCiNum(pGia) );
vSims = Gia_ManSimPatSim( pGia );
return vSims;
}
int Gia_ManFindSatDcs( Gia_Man_t * pGia, Vec_Wrd_t * vSims, Vec_Int_t * vLevel )
{
int nWords = Vec_WrdSize(pGia->vSimsPi) / Gia_ManCiNum(pGia);
int i, w, iObj, Res = 0, Pres[256] = {0}, nMints = 1 << Vec_IntSize(vLevel);
for ( w = 0; w < 64*nWords; w++ )
{
int iInMint = 0;
Vec_IntForEachEntry( vLevel, iObj, i )
if ( Abc_TtGetBit( Vec_WrdEntryP(vSims, iObj*nWords), w ) )
iInMint |= 1 << i;
Pres[iInMint]++;
}
for ( i = 0; i < nMints; i++ )
Res += Pres[i] == 0;
return Res;
}
int Gia_ManCollectCutDivs( Gia_Man_t * p, Vec_Int_t * vIns )
{
Gia_Obj_t * pObj; int i, Res = 0;
Vec_Int_t * vRes = Vec_IntAlloc( 100 );
Vec_IntSort( vIns, 0 );
Vec_IntPush( vRes, 0 );
Vec_IntAppend( vRes, vIns );
Gia_ManIncrementTravId( p );
Gia_ManIncrementTravId( p );
Gia_ManForEachObjVec( vIns, p, pObj, i )
Gia_ObjSetTravIdCurrent( p, pObj );
Gia_ManForEachAnd( p, pObj, i )
if ( Gia_ObjIsTravIdCurrent(p, pObj) )
continue;
else if ( Gia_ObjIsTravIdCurrent(p, Gia_ObjFanin0(pObj)) && Gia_ObjIsTravIdCurrent(p, Gia_ObjFanin1(pObj)) )
{
if ( !Gia_ObjIsTravIdPrevious(p, pObj) )
Vec_IntPush( vRes, i );
Gia_ObjSetTravIdCurrent( p, pObj );
}
// printf( "Divisors: " );
// Vec_IntPrint( vRes );
Res = Vec_IntSize(vRes);
Vec_IntFree( vRes );
return Res;
}
void Gia_ManConsiderCuts( Gia_Man_t * pGia, Vec_Wec_t * vCuts )
{
Vec_Wrd_t * vSims = Gia_ManGenSims( pGia );
Vec_Int_t * vLevel; int i;
Gia_ManCreateRefs( pGia );
Vec_WecForEachLevel( vCuts, vLevel, i )
{
printf( "Cut %3d ", i );
printf( "Ref = %3d : ", Vec_IntEntry(vLevel, 0) );
Vec_IntShift( vLevel, 1 );
printf( "Ref = %3d : ", Gia_ManCountRefs(pGia, vLevel) );
printf( "SDC = %3d : ", Gia_ManFindSatDcs(pGia, vSims, vLevel) );
printf( "Div = %3d : ", Gia_ManCollectCutDivs(pGia, vLevel) );
Vec_IntPrint( vLevel );
Vec_IntShift( vLevel, -1 );
}
Vec_WrdFree( vSims );
}
Vec_Wec_t * Gia_ManExploreCuts( Gia_Man_t * pGia, int nCutSize0, int nCuts0, int fVerbose0 )
{
int nCutSize = nCutSize0;
int nCutNum = 64;
int fCutMin = 0;
int fTruthMin = 0;
int fVerbose = fVerbose0;
Vec_Wec_t * vCutsSel;
Gia_Sto_t * p = Gia_StoAlloc( pGia, nCutSize, nCutNum, fCutMin, fTruthMin, fVerbose );
Gia_Obj_t * pObj; int i, iObj;
assert( nCutSize <= GIA_MAX_CUTSIZE );
assert( nCutNum < GIA_MAX_CUTNUM );
// prepare references
Gia_ManForEachObj( p->pGia, pObj, iObj )
Gia_StoRefObj( p, iObj );
// compute cuts
Gia_StoComputeCutsConst0( p, 0 );
Gia_ManForEachCiId( p->pGia, iObj, i )
Gia_StoComputeCutsCi( p, iObj );
Gia_ManForEachAnd( p->pGia, pObj, iObj )
Gia_StoComputeCutsNode( p, iObj );
if ( p->fVerbose )
{
printf( "Running cut computation with CutSize = %d CutNum = %d CutMin = %s TruthMin = %s\n",
p->nCutSize, p->nCutNum, p->fCutMin ? "yes":"no", p->fTruthMin ? "yes":"no" );
printf( "CutPair = %.0f ", p->CutCount[0] );
printf( "Merge = %.0f (%.2f %%) ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
printf( "Eval = %.0f (%.2f %%) ", p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
printf( "Cut = %.0f (%.2f %%) ", p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
printf( "Cut/Node = %.2f ", p->CutCount[3] / Gia_ManAndNum(p->pGia) );
printf( "\n" );
printf( "The number of nodes with cut count over the limit (%d cuts) = %d nodes (out of %d). ",
p->nCutNum, p->nCutsOver, Gia_ManAndNum(pGia) );
Abc_PrintTime( 0, "Time", Abc_Clock() - p->clkStart );
}
vCutsSel = Gia_ManFilterCuts( pGia, p->vCuts, nCutSize0, nCuts0 );
Gia_ManConsiderCuts( pGia, vCutsSel );
Gia_StoFree( p );
return vCutsSel;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -860,6 +860,27 @@ Gia_Man_t * Gia_ManDupMap( Gia_Man_t * p, Vec_Int_t * vMap )
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
return pNew;
}
Gia_Man_t * Gia_ManDupAddBufs( Gia_Man_t * p )
{
Gia_Man_t * pNew;
Gia_Obj_t * pObj;
int i;
pNew = Gia_ManStart( Gia_ManObjNum(p) + Gia_ManCiNum(p) + Gia_ManCoNum(p) );
Gia_ManHashStart( pNew );
Gia_ManConst0(p)->Value = 0;
Gia_ManForEachCi( p, pObj, i )
pObj->Value = Gia_ManAppendCi( pNew );
Gia_ManForEachCi( p, pObj, i )
pObj->Value = Gia_ManAppendBuf( pNew, pObj->Value );
Gia_ManForEachAnd( p, pObj, i )
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
Gia_ManForEachCo( p, pObj, i )
pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
Gia_ManForEachCo( p, pObj, i )
pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
Gia_ManHashStop( pNew );
return pNew;
}
/**Function*************************************************************
......
......@@ -1869,7 +1869,7 @@ void Gia_ManEquivToChoices_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pOb
Gia_Obj_t * pRepr, * pReprNew, * pObjNew;
if ( ~pObj->Value )
return;
if ( (pRepr = Gia_ObjReprObj(p, Gia_ObjId(p, pObj))) )
if ( (pRepr = Gia_ObjReprObj(p, Gia_ObjId(p, pObj))) && !Gia_ObjFailed(p,Gia_ObjId(p,pObj)) )
{
if ( Gia_ObjIsConst0(pRepr) )
{
......
......@@ -1891,7 +1891,7 @@ Gia_Man_t * Gia_ManFromIfLogic( If_Man_t * pIfMan )
if ( !pIfMan->pPars->fUseTtPerm && !pIfMan->pPars->fDelayOpt && !pIfMan->pPars->fDelayOptLut && !pIfMan->pPars->fDsdBalance &&
!pIfMan->pPars->pLutStruct && !pIfMan->pPars->fUserRecLib && !pIfMan->pPars->fUserSesLib && !pIfMan->pPars->nGateSize &&
!pIfMan->pPars->fEnableCheck75 && !pIfMan->pPars->fEnableCheck75u && !pIfMan->pPars->fEnableCheck07 && !pIfMan->pPars->fUseDsdTune &&
!pIfMan->pPars->fUseCofVars && !pIfMan->pPars->fUseAndVars )
!pIfMan->pPars->fUseCofVars && !pIfMan->pPars->fUseAndVars && !pIfMan->pPars->fUseCheck1 && !pIfMan->pPars->fUseCheck2 )
If_CutRotatePins( pIfMan, pCutBest );
// collect leaves of the best cut
Vec_IntClear( vLeaves );
......
......@@ -733,7 +733,7 @@ void Gia_RsbCiWindowTest( Gia_Man_t * p )
SeeAlso []
***********************************************************************/
static inline int Gia_ObjFaninId( Gia_Obj_t * pObj, int iObj, int n ) { return n ? Gia_ObjFaninId1(pObj, iObj) : Gia_ObjFaninId0(pObj, iObj); }
//static inline int Gia_ObjFaninId( Gia_Obj_t * pObj, int iObj, int n ) { return n ? Gia_ObjFaninId1(pObj, iObj) : Gia_ObjFaninId0(pObj, iObj); }
static inline int Gia_ObjTravIsTopTwo( Gia_Man_t * p, int iNodeA ) { return (p->pTravIds[iNodeA] >= p->nTravIds - 1); }
static inline int Gia_ObjTravIsSame( Gia_Man_t * p, int iNodeA, int iNodeB ) { return (p->pTravIds[iNodeA] == p->pTravIds[iNodeB]); }
......
/**CFile****************************************************************
FileName [giaSyn.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Scalable AIG package.]
Synopsis [High-effort synthesis.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: giaSyn.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "gia.h"
#include "misc/util/utilTruth.h"
#include "sat/glucose/AbcGlucose.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManSyn( Gia_Man_t * p, int nNodes, int nOuts, int nTimeLimit, int fUseXor, int fFancy, int fVerbose )
{
Gia_Man_t * pNew = NULL;
return pNew;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
......@@ -3130,6 +3130,37 @@ void Gia_ManWriteResub( Gia_Man_t * p, char * pFileName )
}
}
/**Function*************************************************************
Synopsis [Transform flops.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManPrintArray( Gia_Man_t * p )
{
Gia_Obj_t * pObj; int i, nSize = Gia_ManObjNum(p);
printf( "static int s_ArraySize = %d;\n", nSize );
printf( "static int s_ArrayData[%d] = {\n", 2*nSize );
printf( " 0, 0," );
printf( "\n " );
Gia_ManForEachCi( p, pObj, i )
printf( "0, 0, " );
printf( "\n " );
Gia_ManForEachAnd( p, pObj, i )
printf( "%d, %d, ", Gia_ObjFaninLit0p(p, pObj), Gia_ObjFaninLit1p(p, pObj) );
printf( "\n " );
Gia_ManForEachCo( p, pObj, i )
printf( "%d, %d, ", Gia_ObjFaninLit0p(p, pObj), Gia_ObjFaninLit0p(p, pObj) );
printf( "\n" );
printf( "};\n" );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -77,6 +77,7 @@ SRC += src/aig/gia/giaAig.c \
src/aig/gia/giaSatLut.c \
src/aig/gia/giaSatMap.c \
src/aig/gia/giaSatoko.c \
src/aig/gia/giaSatSyn.c \
src/aig/gia/giaSat3.c \
src/aig/gia/giaScl.c \
src/aig/gia/giaScript.c \
......@@ -104,5 +105,6 @@ SRC += src/aig/gia/giaAig.c \
src/aig/gia/giaTis.c \
src/aig/gia/giaTruth.c \
src/aig/gia/giaTsim.c \
src/aig/gia/giaTtopt.cpp \
src/aig/gia/giaUnate.c \
src/aig/gia/giaUtil.c
......@@ -144,6 +144,18 @@ static Mini_Aig_t * Mini_AigStart()
Mini_AigPush( p, MINI_AIG_NULL, MINI_AIG_NULL );
return p;
}
static Mini_Aig_t * Mini_AigStartSupport( int nIns, int nObjsAlloc )
{
Mini_Aig_t * p; int i;
assert( 1+nIns < nObjsAlloc );
p = MINI_AIG_CALLOC( Mini_Aig_t, 1 );
p->nCap = 2*nObjsAlloc;
p->nSize = 2*(1+nIns);
p->pArray = MINI_AIG_ALLOC( int, p->nCap );
for ( i = 0; i < p->nSize; i++ )
p->pArray[i] = MINI_AIG_NULL;
return p;
}
static void Mini_AigStop( Mini_Aig_t * p )
{
MINI_AIG_FREE( p->pArray );
......@@ -170,6 +182,31 @@ static int Mini_AigAndNum( Mini_Aig_t * p )
nNodes++;
return nNodes;
}
static int Mini_AigXorNum( Mini_Aig_t * p )
{
int i, nNodes = 0;
Mini_AigForEachAnd( p, i )
nNodes += p->pArray[2*i] > p->pArray[2*i+1];
return nNodes;
}
static int Mini_AigLevelNum( Mini_Aig_t * p )
{
int i, Level = 0;
int * pLevels = MINI_AIG_CALLOC( int, Mini_AigNodeNum(p) );
Mini_AigForEachAnd( p, i )
{
int Lel0 = pLevels[Mini_AigLit2Var(Mini_AigNodeFanin0(p, i))];
int Lel1 = pLevels[Mini_AigLit2Var(Mini_AigNodeFanin1(p, i))];
pLevels[i] = 1 + (Lel0 > Lel1 ? Lel0 : Lel1);
}
Mini_AigForEachPo( p, i )
{
int Lel0 = pLevels[Mini_AigLit2Var(Mini_AigNodeFanin0(p, i))];
Level = Level > Lel0 ? Level : Lel0;
}
MINI_AIG_FREE( pLevels );
return Level;
}
static void Mini_AigPrintStats( Mini_Aig_t * p )
{
printf( "MiniAIG stats: PI = %d PO = %d FF = %d AND = %d\n", Mini_AigPiNum(p), Mini_AigPoNum(p), Mini_AigRegNum(p), Mini_AigAndNum(p) );
......@@ -648,6 +685,25 @@ int main( int argc, char ** argv )
}
*/
/*
#include "aig/miniaig/miniaig.h"
// this procedure creates a MiniAIG for function F = a*b + ~c and writes it into a file "test.aig"
void Mini_AigTest()
{
Mini_Aig_t * p = Mini_AigStart(); // create empty AIG manager (contains only const0 node)
int litApos = Mini_AigCreatePi( p ); // create input A (returns pos lit of A)
int litBpos = Mini_AigCreatePi( p ); // create input B (returns pos lit of B)
int litCpos = Mini_AigCreatePi( p ); // create input C (returns pos lit of C)
int litCneg = Mini_AigLitNot( litCpos ); // neg lit of C
int litAnd = Mini_AigAnd( p, litApos, litBpos ); // lit for a*b
int litOr = Mini_AigOr( p, litAnd, litCneg ); // lit for a*b + ~c
Mini_AigCreatePo( p, litOr ); // create primary output
Mini_AigerWrite( "test.aig", p, 1 ); // write the result into a file
Mini_AigStop( p ); // deallocate MiniAIG
}
*/
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
......
......@@ -506,7 +506,7 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
else if ( nArray == 3 && Type == ABC_OPER_ARI_ADD )
fprintf( pFile, "%s + %s + %s;\n", pNames[pArray[0]], pNames[pArray[1]], pNames[pArray[2]] );
else if ( Type == ABC_OPER_BIT_MUX )
fprintf( pFile, "%s ? %s : %s;\n", pNames[pArray[0]], pNames[pArray[1]], pNames[pArray[2]] );
fprintf( pFile, "%s ? %s : %s;\n", pNames[pArray[0]], pNames[pArray[2]], pNames[pArray[1]] );
else
fprintf( pFile, "<cannot write operation %s>;\n", Abc_OperName(Ndr_ObjReadBody(p, Obj, NDR_OPERTYPE)) );
}
......
......@@ -3267,6 +3267,91 @@ Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp )
return Abc_NtkStrashToGia( pNtkNew );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static int s_ArraySize = 145;
static int s_ArrayData[290] = {
0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10, 6, 14, 12, 10, 2, 22, 20, 2, 24, 16, 4, 28, 18, 16, 10, 8, 4, 34, 32, 30, 36, 38, 26, 16, 6, 36, 20, 44, 42, 46, 40, 42, 44, 14, 6, 52, 34, 32, 54, 56, 50, 58, 48, 32, 24, 20, 2, 12, 6, 66, 34, 68, 64, 62, 70, 28, 68, 74, 72, 76, 58, 70, 62, 80, 78, 68, 28, 84, 74, 4, 2, 88, 20, 64, 90, 92, 86, 66, 32, 18, 96, 98, 56, 100, 94, 52, 36, 104, 38, 90, 42, 36, 2, 108, 110, 112, 106, 114, 100, 102, 116, 118, 82, 116, 60, 120, 122, 124, 60, 118, 60, 102, 82, 128, 130, 132, 82, 134, 126, 82, 116, 122, 138, 122, 118, 142, 140, 60, 102, 130, 146, 130, 118, 150, 148, 152, 144, 154, 136, 18, 156, 144, 126, 68, 160, 32, 136, 164, 162, 166, 158, 28, 160, 70, 126, 90, 144, 174, 172, 176, 170, 152, 134, 36, 180, 2, 134, 184, 182, 186, 178, 188, 168, 64, 144, 164, 158, 194, 192, 96, 156, 44, 154, 200, 170, 202, 198, 204, 176, 206, 196, 204, 168, 62, 126, 212, 186, 24, 134, 108, 152, 218, 192, 220, 216, 222, 214, 224, 210, 220, 194, 110, 152, 30, 180, 232, 230, 184, 172, 236, 234, 238, 228, 234, 182, 242, 220, 244, 168, 42, 154, 248, 202, 54, 136, 252, 164, 254, 214, 256, 250, 218, 194, 252, 198, 262, 242, 264, 260, 232, 220, 268, 262, 270, 168,
191, 191, 209, 209, 226, 226, 240, 240, 246, 246, 259, 259, 267, 267, 272, 272,
};
int Abc_NtkHasConstNode()
{
int i;
for ( i = 1; i < s_ArraySize; i++ )
if ( s_ArrayData[2*i] || s_ArrayData[2*i+1] )
break;
for ( ; i < s_ArraySize; i++ )
if ( s_ArrayData[2*i] < 2 && s_ArrayData[2*i+1] < 2 )
return 1;
return 0;
}
Abc_Ntk_t * Abc_NtkFromArray()
{
Vec_Ptr_t * vNodes = Vec_PtrAlloc( s_ArraySize ); int i, nPos = 0;
Abc_Ntk_t * pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
Abc_Obj_t * pObjNew = Abc_NtkHasConstNode() ? Abc_NtkCreateNode(pNtkNew) : NULL;
if ( pObjNew ) pObjNew->pData = Abc_SopCreateConst0((Mem_Flex_t *)pNtkNew->pManFunc);
Vec_PtrPush( vNodes, pObjNew );
for ( i = 1; i < s_ArraySize; i++ )
if ( !s_ArrayData[2*i] && !s_ArrayData[2*i+1] )
Vec_PtrPush( vNodes, Abc_NtkCreatePi(pNtkNew) );
else
break;
for ( ; i < s_ArraySize; i++ )
{
char * pSop = NULL;
if ( s_ArrayData[2*i] > s_ArrayData[2*i+1] )
pSop = Abc_SopCreateXor( (Mem_Flex_t *)pNtkNew->pManFunc, 2 );
else if ( s_ArrayData[2*i] < s_ArrayData[2*i+1] )
pSop = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, 2, NULL );
else
break;
pObjNew = Abc_NtkCreateNode( pNtkNew );
Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)Vec_PtrEntry(vNodes, Abc_Lit2Var(s_ArrayData[2*i])) );
Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)Vec_PtrEntry(vNodes, Abc_Lit2Var(s_ArrayData[2*i+1])) );
if ( Abc_LitIsCompl(s_ArrayData[2*i]) ) Abc_SopComplementVar( pSop, 0 );
if ( Abc_LitIsCompl(s_ArrayData[2*i+1]) ) Abc_SopComplementVar( pSop, 1 );
pObjNew->pData = pSop;
Vec_PtrPush( vNodes, pObjNew );
}
for ( ; i < s_ArraySize; i++ )
{
char * pSop = NULL;
assert( s_ArrayData[2*i] == s_ArrayData[2*i+1] );
pObjNew = Abc_NtkCreateNode( pNtkNew );
Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)Vec_PtrEntry(vNodes, Abc_Lit2Var(s_ArrayData[2*i])) );
if ( Abc_LitIsCompl(s_ArrayData[2*i]) )
pSop = Abc_SopCreateInv( (Mem_Flex_t *)pNtkNew->pManFunc );
else
pSop = Abc_SopCreateBuf( (Mem_Flex_t *)pNtkNew->pManFunc );
pObjNew->pData = pSop;
Vec_PtrPush( vNodes, pObjNew );
nPos++;
}
for ( i = 0; i < nPos; i++ )
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), (Abc_Obj_t *)Vec_PtrEntry(vNodes, s_ArraySize-nPos+i) );
Vec_PtrFree( vNodes );
pNtkNew->pName = Extra_UtilStrsav("test");
Abc_NtkAddDummyPiNames( pNtkNew );
Abc_NtkAddDummyPoNames( pNtkNew );
Abc_NtkAddDummyBoxNames( pNtkNew );
if ( !Abc_NtkCheck( pNtkNew ) )
Abc_Print( 1, "Abc_NtkFromArray(): Network check has failed.\n" );
return pNtkNew;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -535,10 +535,23 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData )
SeeAlso []
***********************************************************************/
void Ndr_DumpNdr( void * pDesign )
{
int i;
char ** pNames = ABC_CALLOC( char *, 10000 );
for ( i = 0; i < 10000; i++ )
{
char Buffer[100];
sprintf( Buffer, "s%d", i );
pNames[i] = Abc_UtilStrsav( Buffer );
}
Ndr_WriteVerilog( "temp.v", pDesign, pNames, 0 );
}
Wlc_Ntk_t * Wlc_ReadNdr( char * pFileName )
{
void * pData = Ndr_Read( pFileName );
Wlc_Ntk_t * pNtk = Wlc_NtkFromNdr( pData );
//Ndr_DumpNdr( pData );
//char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" };
//Ndr_WriteVerilog( NULL, pData, ppNames, 0 );
//Ndr_Delete( pData );
......
......@@ -290,8 +290,16 @@ void Rtl_NtkBlastNode( Gia_Man_t * pNew, int Type, int nIns, Vec_Int_t * vDatas,
int fBooth = 1;
int fCla = 0;
int fSigned = fSign0 && fSign1;
//int i, iObj;
Vec_IntShrink( vArg0, nSizeArg0 );
Vec_IntShrink( vArg1, nSizeArg1 );
//printf( "Adding %d + %d + %d buffers\n", nSizeArg0, nSizeArg1, nRange );
//Vec_IntForEachEntry( vArg0, iObj, i )
// Vec_IntWriteEntry( vArg0, i, Gia_ManAppendBuf(pNew, iObj) );
//Vec_IntForEachEntry( vArg1, iObj, i )
// Vec_IntWriteEntry( vArg1, i, Gia_ManAppendBuf(pNew, iObj) );
if ( Wlc_NtkCountConstBits(Vec_IntArray(vArg0), Vec_IntSize(vArg0)) < Wlc_NtkCountConstBits(Vec_IntArray(vArg1), Vec_IntSize(vArg1)) )
ABC_SWAP( Vec_Int_t, *vArg0, *vArg1 )
if ( fBooth )
......@@ -303,6 +311,9 @@ void Rtl_NtkBlastNode( Gia_Man_t * pNew, int Type, int nIns, Vec_Int_t * vDatas,
else
Vec_IntShrink( vRes, nRange );
assert( Vec_IntSize(vRes) == nRange );
//Vec_IntForEachEntry( vRes, iObj, i )
// Vec_IntWriteEntry( vRes, i, Gia_ManAppendBuf(pNew, iObj) );
return;
}
if ( Type == ABC_OPER_ARI_DIV || Type == ABC_OPER_ARI_MOD )
......
......@@ -92,12 +92,13 @@ void Wln_End( Abc_Frame_t * pAbc )
******************************************************************************/
int Abc_CommandYosys( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Gia_Man_t * Wln_BlastSystemVerilog( char * pFileName, char * pTopModule, int fSkipStrash, int fInvert, int fTechMap, int fVerbose );
extern Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, int fCollapse, int fVerbose );
extern Gia_Man_t * Wln_BlastSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fSkipStrash, int fInvert, int fTechMap, int fVerbose );
extern Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fCollapse, int fVerbose );
FILE * pFile;
char * pFileName = NULL;
char * pTopModule= NULL;
char * pDefines = NULL;
int fBlast = 0;
int fInvert = 0;
int fTechMap = 1;
......@@ -105,7 +106,7 @@ int Abc_CommandYosys( Abc_Frame_t * pAbc, int argc, char ** argv )
int fCollapse = 0;
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Tbismcvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "TDbismcvh" ) ) != EOF )
{
switch ( c )
{
......@@ -118,6 +119,15 @@ int Abc_CommandYosys( Abc_Frame_t * pAbc, int argc, char ** argv )
pTopModule = argv[globalUtilOptind];
globalUtilOptind++;
break;
case 'D':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-D\" should be followed by a file name.\n" );
goto usage;
}
pDefines = argv[globalUtilOptind];
globalUtilOptind++;
break;
case 'b':
fBlast ^= 1;
break;
......@@ -164,11 +174,11 @@ int Abc_CommandYosys( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_Man_t * pNew = NULL;
if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) )
pNew = Wln_BlastSystemVerilog( pFileName, pTopModule, fSkipStrash, fInvert, fTechMap, fVerbose );
pNew = Wln_BlastSystemVerilog( pFileName, pTopModule, pDefines, fSkipStrash, fInvert, fTechMap, fVerbose );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "sv" ) )
pNew = Wln_BlastSystemVerilog( pFileName, pTopModule, fSkipStrash, fInvert, fTechMap, fVerbose );
pNew = Wln_BlastSystemVerilog( pFileName, pTopModule, pDefines, fSkipStrash, fInvert, fTechMap, fVerbose );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "rtlil" ) )
pNew = Wln_BlastSystemVerilog( pFileName, pTopModule, fSkipStrash, fInvert, fTechMap, fVerbose );
pNew = Wln_BlastSystemVerilog( pFileName, pTopModule, pDefines, fSkipStrash, fInvert, fTechMap, fVerbose );
else
{
printf( "Abc_CommandYosys(): Unknown file extension.\n" );
......@@ -180,11 +190,11 @@ int Abc_CommandYosys( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Rtl_Lib_t * pLib = NULL;
if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) )
pLib = Wln_ReadSystemVerilog( pFileName, pTopModule, fCollapse, fVerbose );
pLib = Wln_ReadSystemVerilog( pFileName, pTopModule, pDefines, fCollapse, fVerbose );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "sv" ) )
pLib = Wln_ReadSystemVerilog( pFileName, pTopModule, fCollapse, fVerbose );
pLib = Wln_ReadSystemVerilog( pFileName, pTopModule, pDefines, fCollapse, fVerbose );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "rtlil" ) )
pLib = Wln_ReadSystemVerilog( pFileName, pTopModule, fCollapse, fVerbose );
pLib = Wln_ReadSystemVerilog( pFileName, pTopModule, pDefines, fCollapse, fVerbose );
else
{
printf( "Abc_CommandYosys(): Unknown file extension.\n" );
......@@ -194,11 +204,12 @@ int Abc_CommandYosys( Abc_Frame_t * pAbc, int argc, char ** argv )
}
return 0;
usage:
Abc_Print( -2, "usage: %%yosys [-T <module>] [-bismcvh] <file_name>\n" );
Abc_Print( -2, "usage: %%yosys [-T <module>] [-D <defines>] [-bismcvh] <file_name>\n" );
Abc_Print( -2, "\t reads Verilog or SystemVerilog using Yosys\n" );
Abc_Print( -2, "\t-T : specify the top module name (default uses \"-auto-top\"\n" );
Abc_Print( -2, "\t-D : specify defines to be used by Yosys (default \"not used\")\n" );
Abc_Print( -2, "\t-b : toggle bit-blasting the design into an AIG using Yosys [default = %s]\n", fBlast? "yes": "no" );
Abc_Print( -2, "\t-i : toggle interting the outputs (useful for miters) [default = %s]\n", fInvert? "yes": "no" );
Abc_Print( -2, "\t-i : toggle inverting the outputs (useful for miters) [default = %s]\n", fInvert? "yes": "no" );
Abc_Print( -2, "\t-s : toggle no structural hashing during bit-blasting [default = %s]\n", fSkipStrash? "no strash": "strash" );
Abc_Print( -2, "\t-m : toggle using \"techmap\" to blast operators [default = %s]\n", fTechMap? "yes": "no" );
Abc_Print( -2, "\t-c : toggle collapsing design hierarchy using Yosys [default = %s]\n", fCollapse? "yes": "no" );
......@@ -330,13 +341,13 @@ usage:
******************************************************************************/
int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Gia_Man_t * Rtl_LibCollapse( Rtl_Lib_t * p, char * pTopModule, int fVerbose );
extern Gia_Man_t * Rtl_LibCollapse( Rtl_Lib_t * p, char * pTopModule, int fRev, int fVerbose );
Gia_Man_t * pNew = NULL;
Rtl_Lib_t * pLib = Wln_AbcGetRtl(pAbc);
char * pTopModule = NULL;
int c, fInv = 0, fVerbose = 0;
int c, fInv = 0, fRev = 0, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Tcvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Tcrvh" ) ) != EOF )
{
switch ( c )
{
......@@ -352,6 +363,9 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'c':
fInv ^= 1;
break;
case 'r':
fRev ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
......@@ -366,16 +380,17 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
printf( "The design is not entered.\n" );
return 1;
}
pNew = Rtl_LibCollapse( pLib, pTopModule, fVerbose );
pNew = Rtl_LibCollapse( pLib, pTopModule, fRev, fVerbose );
if ( fInv )
Gia_ManInvertPos( pNew );
Abc_FrameUpdateGia( pAbc, pNew );
return 0;
usage:
Abc_Print( -2, "usage: %%collapse [-T <module>] [-cvh] <file_name>\n" );
Abc_Print( -2, "usage: %%collapse [-T <module>] [-crvh] <file_name>\n" );
Abc_Print( -2, "\t collapse hierarchical design into an AIG\n" );
Abc_Print( -2, "\t-T : specify the top module of the design [default = none]\n" );
Abc_Print( -2, "\t-c : toggle complementing miter outputs after collapsing [default = %s]\n", fInv? "yes": "no" );
Abc_Print( -2, "\t-r : toggle bit order reversal in the word-level IO [default = %s]\n", fRev? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
......
......@@ -1736,6 +1736,42 @@ int Rtl_NtkInsertSignalRange( Rtl_Ntk_t * p, int Sig, int * pLits, int nLits )
SeeAlso []
***********************************************************************/
Vec_Int_t * Rtl_NtkRevPermInput( Rtl_Ntk_t * p )
{
Vec_Int_t * vNew = Vec_IntAlloc( 100 ); int b, i, Count = 0;
for ( i = 0; i < p->nInputs; i++ )
{
int Width = Rtl_WireWidth( p, i );
for ( b = 0; b < Width; b++ )
Vec_IntPush( vNew, Count + Width-1-b );
Count += Width;
}
return vNew;
}
Vec_Int_t * Rtl_NtkRevPermOutput( Rtl_Ntk_t * p )
{
Vec_Int_t * vNew = Vec_IntAlloc( 100 ); int b, i, Count = 0;
for ( i = 0; i < p->nOutputs; i++ )
{
int Width = Rtl_WireWidth( p, p->nInputs + i );
for ( b = 0; b < Width; b++ )
Vec_IntPush( vNew, Count + Width-1-b );
Count += Width;
}
return vNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Rtl_NtkBlastInputs( Gia_Man_t * pNew, Rtl_Ntk_t * p )
{
int b, i;
......@@ -2704,6 +2740,41 @@ Gia_Man_t * Rtl_ReduceInverse( Rtl_Lib_t * pLib, Gia_Man_t * p )
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManDupPermIO( Gia_Man_t * p, Vec_Int_t * vPermI, Vec_Int_t * vPermO )
{
Gia_Man_t * pNew;
Gia_Obj_t * pObj;
int i;
assert( Vec_IntSize(vPermI) == Gia_ManCiNum(p) );
assert( Vec_IntSize(vPermO) == Gia_ManCoNum(p) );
pNew = Gia_ManStart( Gia_ManObjNum(p) );
Gia_ManConst0(p)->Value = 0;
Gia_ManForEachCi( p, pObj, i )
Gia_ManCi(p, Vec_IntEntry(vPermI, i))->Value = Gia_ManAppendCi(pNew);
Gia_ManForEachAnd( p, pObj, i )
{
if ( Gia_ObjIsBuf(pObj) )
pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
else
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
assert( Abc_Lit2Var(pObj->Value) == i );
}
Gia_ManForEachCo( p, pObj, i )
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManCo(p, Vec_IntEntry(vPermO, i))) );
return pNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Rtl_LibReturnNtk( Rtl_Lib_t * p, char * pModule )
{
int NameId = Wln_ReadFindToken( pModule, p->pManName );
......@@ -2715,7 +2786,7 @@ int Rtl_LibReturnNtk( Rtl_Lib_t * p, char * pModule )
}
return iNtk;
}
Gia_Man_t * Rtl_LibCollapse( Rtl_Lib_t * p, char * pTopModule, int fVerbose )
Gia_Man_t * Rtl_LibCollapse( Rtl_Lib_t * p, char * pTopModule, int fRev, int fVerbose )
{
Gia_Man_t * pGia = NULL;
int NameId = Wln_ReadFindToken( pTopModule, p->pManName );
......@@ -2733,6 +2804,16 @@ Gia_Man_t * Rtl_LibCollapse( Rtl_Lib_t * p, char * pTopModule, int fVerbose )
Vec_IntPush( vRoots, iNtk );
Rtl_LibBlast2( p, vRoots, 1 );
pGia = Gia_ManDup( pTop->pGia );
if ( fRev )
{
Gia_Man_t * pTemp;
Vec_Int_t * vPermI = Rtl_NtkRevPermInput( pTop );
Vec_Int_t * vPermO = Rtl_NtkRevPermOutput( pTop );
pGia = Gia_ManDupPermIO( pTemp = pGia, vPermI, vPermO );
Vec_IntFree( vPermI );
Vec_IntFree( vPermO );
Gia_ManStop( pTemp );
}
//Gia_AigerWrite( pGia, "temp_miter.aig", 0, 0, 0 );
if ( pTop->pGia->vBarBufs )
pGia->vBarBufs = Vec_IntDup( pTop->pGia->vBarBufs );
......
......@@ -139,7 +139,7 @@ int Wln_ConvertToRtl( char * pCommand, char * pFileTemp )
return 1;
#endif
}
Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, int fCollapse, int fVerbose )
Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fCollapse, int fVerbose )
{
Rtl_Lib_t * pNtk = NULL;
char Command[1000];
......@@ -147,8 +147,10 @@ Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, int fCol
int fSVlog = strstr(pFileName, ".sv") != NULL;
if ( strstr(pFileName, ".rtl") )
return Rtl_LibReadFile( pFileName, pFileName );
sprintf( Command, "%s -qp \"read_verilog %s%s; hierarchy %s%s; %sproc; write_rtlil %s\"",
Wln_GetYosysName(), fSVlog ? "-sv ":"", pFileName,
sprintf( Command, "%s -qp \"read_verilog %s %s%s; hierarchy %s%s; %sproc; write_rtlil %s\"",
Wln_GetYosysName(),
pDefines ? pDefines : "",
fSVlog ? "-sv ":"", pFileName,
pTopModule ? "-top " : "",
pTopModule ? pTopModule : "",
fCollapse ? "flatten; " : "",
......@@ -167,16 +169,17 @@ Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, int fCol
unlink( pFileTemp );
return pNtk;
}
Gia_Man_t * Wln_BlastSystemVerilog( char * pFileName, char * pTopModule, int fSkipStrash, int fInvert, int fTechMap, int fVerbose )
Gia_Man_t * Wln_BlastSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fSkipStrash, int fInvert, int fTechMap, int fVerbose )
{
Gia_Man_t * pGia = NULL;
char Command[1000];
char * pFileTemp = "_temp_.aig";
int fRtlil = strstr(pFileName, ".rtl") != NULL;
int fSVlog = strstr(pFileName, ".sv") != NULL;
sprintf( Command, "%s -qp \"%s%s%s; hierarchy %s%s; flatten; proc; %saigmap; write_aiger %s\"",
sprintf( Command, "%s -qp \"%s %s%s%s; hierarchy %s%s; flatten; proc; %saigmap; write_aiger %s\"",
Wln_GetYosysName(),
fRtlil ? "read_rtlil" : "read_verilog",
pDefines ? pDefines : "",
fSVlog ? " -sv ":" ",
pFileName,
pTopModule ? "-top " : "-auto-top",
......
......@@ -140,6 +140,8 @@ struct If_Par_t_
int fUseCofVars; // use cofactoring variables
int fUseAndVars; // use bi-decomposition
int fUseTtPerm; // compute truth tables of the cut functions
int fUseCheck1; // compute truth tables of the cut functions
int fUseCheck2; // compute truth tables of the cut functions
int fDeriveLuts; // enables deriving LUT structures
int fDoAverage; // optimize average rather than maximum level
int fHashMapping; // perform AIG hashing after mapping
......@@ -553,6 +555,8 @@ extern int If_CluCheckExt( void * p, word * pTruth, int nVars, int n
char * pLut0, char * pLut1, word * pFunc0, word * pFunc1 );
extern int If_CluCheckExt3( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot,
char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 );
extern int If_MatchCheck1( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int If_MatchCheck2( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
/*=== ifDelay.c =============================================================*/
extern int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutSopBalanceEvalInt( Vec_Int_t * vCover, int * pTimes, int * pFaninLits, Vec_Int_t * vAig, int * piRes, int nSuppAll, int * pArea );
......
......@@ -767,7 +767,7 @@ void If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut )
(p->pPars->fUseDsd || p->pPars->pFuncCell2 || p->pPars->fUseBat ||
p->pPars->pLutStruct || p->pPars->fUserRecLib || p->pPars->fUserSesLib ||
p->pPars->fEnableCheck07 || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->fUse34Spec ||
p->pPars->fUseDsdTune || p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u) )
p->pPars->fUseDsdTune || p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u || p->pPars->fUseCheck1 || p->pPars->fUseCheck2) )
{
If_Cut_t * pFirst = pCutSet->ppCuts[0];
if ( pFirst->fUseless || If_ManSortCompare(p, pFirst, pCut) == 1 )
......
......@@ -1116,6 +1116,36 @@ int If_CutPerformCheck07( If_Man_t * p, unsigned * pTruth, int nVars, int nLeave
return 0;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int If_MatchCheck1( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr )
{
if ( nLeaves < nVars )
return 1;
assert( nLeaves == nVars );
if ( Abc_Tt6Check1( ((word *)pTruth)[0], nLeaves ) )
return 1;
return 0;
}
int If_MatchCheck2( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr )
{
if ( nLeaves < nVars )
return 1;
assert( nLeaves == nVars );
if ( Abc_Tt6Check2( ((word *)pTruth)[0], nLeaves ) )
return 1;
return 0;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -167,7 +167,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
int fFunc0R, fFunc1R;
int i, k, v, iCutDsd, fChange;
int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUserSesLib ||
p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->fUse34Spec || p->pPars->pLutStruct || p->pPars->pFuncCell2;
p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->fUse34Spec || p->pPars->pLutStruct || p->pPars->pFuncCell2 || p->pPars->fUseCheck1 || p->pPars->fUseCheck2;
int fUseAndCut = (p->pPars->nAndDelay > 0) || (p->pPars->nAndArea > 0);
assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
......
......@@ -72,6 +72,8 @@ void Abc_SclHashCells( SC_Lib * p )
SC_LibForEachCell( p, pCell, i )
{
pPlace = Abc_SclHashLookup( p, pCell->pName );
if ( *pPlace != -1 && pCell->pName )
printf( "There are two standard cells with the same name (%s).\n", pCell->pName );
assert( *pPlace == -1 );
*pPlace = i;
}
......
......@@ -1589,7 +1589,31 @@ static inline int Abc_Tt6SupportAndSize( word t, int nVars, int * pSuppSize )
Supp |= (1 << v), (*pSuppSize)++;
return Supp;
}
static inline int Abc_Tt6Check1( word t, int nVars )
{
int n, v, u;
for ( n = 0; n < 2; n++ )
for ( v = 0; v < nVars; v++ )
{
word Cof = n ? Abc_Tt6Cofactor1(t, v) : Abc_Tt6Cofactor0(t, v);
for ( u = 0; u < nVars; u++ )
if ( v != u && !Abc_Tt6HasVar(Cof, u) )
return 1;
}
return 0;
}
static inline int Abc_Tt6Check2( word t, int nVars )
{
int n, v;
for ( n = 0; n < 2; n++ )
for ( v = 0; v < nVars; v++ )
{
word Cof = n ? Abc_Tt6Cofactor1(t, v) : Abc_Tt6Cofactor0(t, v);
if ( Cof == 0 || ~Cof == 0 )
return 1;
}
return 0;
}
/**Function*************************************************************
Synopsis [Checks if there is a var whose both cofs have supp <= nSuppLim.]
......
......@@ -418,7 +418,6 @@ Aig_Man_t * Cec_ComputeChoicesNew( Gia_Man_t * pGia, int nConfs, int fVerbose )
Aig_Man_t * pAig;
Cec4_ManSimulateTest2( pGia, nConfs, fVerbose );
pGia = Gia_ManEquivToChoices( pGia, 3 );
Gia_ManSetRegNum( pGia, Gia_ManRegNum(pGia) );
pAig = Gia_ManToAig( pGia, 1 );
Gia_ManStop( pGia );
return pAig;
......
......@@ -265,10 +265,13 @@ void Cec_ManSimClassCreate( Gia_Man_t * p, Vec_Int_t * vClass )
SeeAlso []
***********************************************************************/
int Cec_ManSimClassRefineOne( Cec_ManSim_t * p, int i )
static int s_Count = 0;
int Cec_ManSimClassRefineOne_rec( Cec_ManSim_t * p, int i )
{
unsigned * pSim0, * pSim1;
int Ent;
s_Count++;
Vec_IntClear( p->vClassOld );
Vec_IntClear( p->vClassNew );
Vec_IntPush( p->vClassOld, i );
......@@ -290,9 +293,22 @@ int Cec_ManSimClassRefineOne( Cec_ManSim_t * p, int i )
Cec_ManSimClassCreate( p->pAig, p->vClassOld );
Cec_ManSimClassCreate( p->pAig, p->vClassNew );
if ( Vec_IntSize(p->vClassNew) > 1 )
return 1 + Cec_ManSimClassRefineOne( p, Vec_IntEntry(p->vClassNew,0) );
return 1 + Cec_ManSimClassRefineOne_rec( p, Vec_IntEntry(p->vClassNew,0) );
return 1;
}
int Cec_ManSimClassRefineOne_( Cec_ManSim_t * p, int i )
{
int Res;
s_Count = 0;
Res = Cec_ManSimClassRefineOne_rec( p, i );
if ( s_Count > 10 )
printf( "%d ", s_Count );
return Res;
}
int Cec_ManSimClassRefineOne( Cec_ManSim_t * p, int i )
{
return Cec_ManSimClassRefineOne_rec( p, i );
}
/**Function*************************************************************
......
......@@ -54,10 +54,14 @@ struct Bmc_EsPar_t_
int fMajority;
int fUseIncr;
int fOnlyAnd;
int fDynConstr;
int fDumpCnf;
int fGlucose;
int fOrderNodes;
int fEnumSols;
int fFewerVars;
int fQuadrEnc;
int fUniqFans;
int RuntimeLim;
int fVerbose;
char * pTtStr;
......@@ -73,10 +77,14 @@ static inline void Bmc_EsParSetDefault( Bmc_EsPar_t * pPars )
pPars->fMajority = 0;
pPars->fUseIncr = 0;
pPars->fOnlyAnd = 0;
pPars->fDynConstr = 0;
pPars->fDumpCnf = 0;
pPars->fGlucose = 0;
pPars->fOrderNodes = 0;
pPars->fEnumSols = 0;
pPars->fFewerVars = 0;
pPars->fQuadrEnc = 0;
pPars->fUniqFans = 0;
pPars->RuntimeLim = 0;
pPars->fVerbose = 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment