summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/aig/gia/gia.h2
-rw-r--r--src/aig/gia/giaMan.c6
-rw-r--r--src/aig/gia/giaMuxes.c2
-rw-r--r--src/aig/gia/giaSimBase.c114
-rw-r--r--src/base/abc/abc.h2
-rw-r--r--src/base/abc/abcNtk.c33
-rw-r--r--src/base/abc/abcUtil.c6
-rw-r--r--src/base/acb/acbFunc.c140
-rw-r--r--src/base/acb/acbUtil.c44
9 files changed, 312 insertions, 37 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h
index c3842fe1..af5c82b8 100644
--- a/src/aig/gia/gia.h
+++ b/src/aig/gia/gia.h
@@ -233,7 +233,7 @@ struct Gia_Man_t_
Vec_Wrd_t * vSuppWords; // support information
Vec_Int_t vCopiesTwo; // intermediate copies
Vec_Int_t vSuppVars; // used variables
- Gia_Dat_t * pUserData;
+ Gia_Dat_t * pUData;
};
diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c
index 0958cdfa..447ecea9 100644
--- a/src/aig/gia/giaMan.c
+++ b/src/aig/gia/giaMan.c
@@ -82,7 +82,7 @@ Gia_Man_t * Gia_ManStart( int nObjsMax )
void Gia_ManStop( Gia_Man_t * p )
{
extern void Gia_DatFree( Gia_Dat_t * p );
- Gia_DatFree( p->pUserData );
+ Gia_DatFree( p->pUData );
if ( p->vSeqModelVec )
Vec_PtrFreeFree( p->vSeqModelVec );
Gia_ManStaticFanoutStop( p );
@@ -487,6 +487,7 @@ void Gia_ManLogAigStats( Gia_Man_t * p, char * pDumpFile )
void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
{
extern float Gia_ManLevelAve( Gia_Man_t * p );
+ int fHaveLevels = p->vLevels != NULL;
if ( pPars && pPars->fMiter )
{
Gia_ManPrintStatsMiter( p, 0 );
@@ -542,7 +543,8 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
Abc_Print( 1, " %s(%.2f)%s", "\033[1;35m", Gia_ManLevelAve(p), "\033[0m" );
#endif
}
- Vec_IntFreeP( &p->vLevels );
+ if ( !fHaveLevels )
+ Vec_IntFreeP( &p->vLevels );
if ( pPars && pPars->fCut )
Abc_Print( 1, " cut = %d(%d)", Gia_ManCrossCut(p, 0), Gia_ManCrossCut(p, 1) );
Abc_Print( 1, " mem =%5.2f MB", Gia_ManMemory(p)/(1<<20) );
diff --git a/src/aig/gia/giaMuxes.c b/src/aig/gia/giaMuxes.c
index c0414d14..5182336f 100644
--- a/src/aig/gia/giaMuxes.c
+++ b/src/aig/gia/giaMuxes.c
@@ -162,7 +162,7 @@ Gia_Man_t * Gia_ManDupNoMuxes( Gia_Man_t * p )
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj;
int i;
- assert( p->pMuxes != NULL );
+ assert( p->pMuxes != NULL || Gia_ManXorNum(p) );
// start the new manager
pNew = Gia_ManStart( 5000 );
pNew->pName = Abc_UtilStrsav( p->pName );
diff --git a/src/aig/gia/giaSimBase.c b/src/aig/gia/giaSimBase.c
index 95508d70..825c01ca 100644
--- a/src/aig/gia/giaSimBase.c
+++ b/src/aig/gia/giaSimBase.c
@@ -188,7 +188,7 @@ Vec_Wrd_t * Gia_ManSimCombine( int nInputs, Vec_Wrd_t * vBase, Vec_Wrd_t * vAddO
for ( w = 0; w < nWordsUse; w++ )
Vec_WrdPush( vSimsIn, pSimsA[w] );
}
- assert( Vec_WrdSize(vSimsIn) == Vec_WrdCap(vSimsIn) );
+ assert( Vec_WrdSize(vSimsIn) == Vec_WrdCap(vSimsIn) || Vec_WrdSize(vSimsIn) < 16 );
return vSimsIn;
}
int Gia_ManSimBitPackOne( int nWords, Vec_Wrd_t * vSimsIn, Vec_Wrd_t * vSimsCare, int iPat, int * pLits, int nLits )
@@ -819,13 +819,83 @@ Vec_Wrd_t * Gia_ManSimRel( Gia_Man_t * p, Vec_Int_t * vObjs, Vec_Wrd_t * vVals )
SeeAlso []
***********************************************************************/
+Vec_Wrd_t * Gia_ManSimRelDeriveFuncs( Gia_Man_t * p, Vec_Wrd_t * vRel, int nOuts )
+{
+ int i, k, m, nMints = 1 << nOuts, nWords = Vec_WrdSize(vRel) / nMints;
+ Vec_Wrd_t * vFuncs = Vec_WrdStart( nOuts * nWords );
+ assert( Vec_WrdSize(vRel) % nMints == 0 );
+ for ( i = 0; i < 64 * nWords; i++ )
+ {
+ for ( m = 0; m < nMints; m++ )
+ if ( Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+m ) )
+ break;
+ assert( m < nMints );
+ for ( k = 0; k < nOuts; k++ )
+ if ( (m >> k) & 1 )
+ Abc_TtSetBit( Vec_WrdEntryP(vFuncs, k*nWords), i );
+ }
+ return vFuncs;
+}
+Vec_Wrd_t * Gia_ManSimRelDeriveFuncs2( Gia_Man_t * p, Vec_Wrd_t * vRel, int nOuts )
+{
+ int i, k, m, nMints = 1 << nOuts, nWords = Vec_WrdSize(vRel) / nMints;
+ Vec_Wrd_t * vFuncs = Vec_WrdStart( 2 * nOuts * nWords );
+ assert( Vec_WrdSize(vRel) % nMints == 0 );
+ for ( i = 0; i < 64 * nWords; i++ )
+ {
+ for ( m = 0; m < nMints; m++ )
+ if ( Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+m ) )
+ break;
+ assert( m < nMints );
+ for ( k = 0; k < nOuts; k++ )
+ {
+ if ( Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+(m^(1<<k)) ) )
+ continue;
+ if ( (m >> k) & 1 )
+ Abc_TtSetBit( Vec_WrdEntryP(vFuncs, (2*k+1)*nWords), i );
+ else
+ Abc_TtSetBit( Vec_WrdEntryP(vFuncs, (2*k+0)*nWords), i );
+ }
+ if ( 0 )
+ {
+ for ( m = 0; m < nMints; m++ )
+ printf( "%d", Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+m ) );
+ printf( " " );
+ for ( k = 0; k < nOuts; k++ )
+ {
+ if ( Abc_TtGetBit( Vec_WrdEntryP(vFuncs, (2*k+0)*nWords), i ) )
+ printf( "0" );
+ else if ( Abc_TtGetBit( Vec_WrdEntryP(vFuncs, (2*k+1)*nWords), i ) )
+ printf( "1" );
+ else
+ printf( "-" );
+ }
+ printf( "\n" );
+ }
+ }
+ return vFuncs;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Gia_ManSimRelPrint( Gia_Man_t * p, Vec_Wrd_t * vRel, Vec_Int_t * vOutMints )
{
int nWords = Vec_WrdSize(p->vSimsPi) / Gia_ManCiNum(p);
int nMints = Vec_WrdSize(vRel) / nWords;
- int i, k, m, Count;
+ int i, m, Count;
+/*
for ( i = 0; i < 64 * nWords; i++ )
{
+ int k;
for ( k = 0; k < Gia_ManCiNum(p); k++ )
printf( "%d", Abc_TtGetBit( Vec_WrdEntryP(p->vSimsPi, k), i ) );
printf( " " );
@@ -846,6 +916,27 @@ void Gia_ManSimRelPrint( Gia_Man_t * p, Vec_Wrd_t * vRel, Vec_Int_t * vOutMints
}
printf( "\n" );
}
+*/
+/*
+ for ( i = 0; i < 64 * nWords; i++ )
+ {
+ Count = 0;
+ for ( m = 0; m < nMints; m++ )
+ Count += Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+m );
+ printf( "%d ", Count );
+ }
+ printf( "\n" );
+*/
+ for ( i = 0; i < 64 * nWords; i++ )
+ {
+ Count = 0;
+ for ( m = 0; m < nMints; m++ )
+ {
+ printf( "%d", Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+m ) );
+ Count += Abc_TtGetBit( Vec_WrdArray(vRel), i*nMints+m );
+ }
+ printf( " Count = %2d \n", Count );
+ }
}
Vec_Int_t * Gia_ManSimPatStart( int nItems )
{
@@ -871,11 +962,6 @@ void Gia_ManSimRelTest( Gia_Man_t * p )
-
-
-
-
-
/**Function*************************************************************
Synopsis []
@@ -1074,9 +1160,9 @@ void Gia_SimAbsSolve( Gia_SimAbsMan_t * p )
}
printf( "Solution %2d for covering problem [%5d x %5d]: ", Vec_IntSize(p->vResub), Vec_IntSize(p->vPatPairs)/2, p->nCands );
Vec_IntForEachEntry( p->vResub, iPat, i )
- printf( "%4d ", iPat );
- for ( ; i < 16; i++ )
- printf( " " );
+ printf( "%6d ", iPat );
+ for ( ; i < 12; i++ )
+ printf( " " );
printf( " " );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
}
@@ -1130,14 +1216,14 @@ void Gia_SimAbsInit( Gia_SimAbsMan_t * p )
Vec_Int_t * vValue0 = Gia_SimAbsFind( p->vValues, 0 );
Vec_Int_t * vValue1 = Gia_SimAbsFind( p->vValues, 1 );
Vec_IntClear( p->vPatPairs );
- printf( "There %d offset and %d onset minterms (%d pairs).\n", Vec_IntSize(vValue0), Vec_IntSize(vValue1), Vec_IntSize(vValue0)*Vec_IntSize(vValue1) );
- Gia_ManRandom( 1 );
+ printf( "There are %d offset and %d onset minterms (%d pairs).\n", Vec_IntSize(vValue0), Vec_IntSize(vValue1), Vec_IntSize(vValue0)*Vec_IntSize(vValue1) );
+ Abc_Random( 1 );
assert( Vec_IntSize(vValue0) > 0 );
assert( Vec_IntSize(vValue1) > 0 );
for ( n = 0; n < nPairsInit; n++ )
Vec_IntPushTwo( p->vPatPairs,
- Vec_IntEntry(vValue0, Gia_ManRandom(0) % Vec_IntSize(vValue0)),
- Vec_IntEntry(vValue1, Gia_ManRandom(0) % Vec_IntSize(vValue1)) );
+ Vec_IntEntry(vValue0, Abc_Random(0) % Vec_IntSize(vValue0)),
+ Vec_IntEntry(vValue1, Abc_Random(0) % Vec_IntSize(vValue1)) );
Vec_IntFree( vValue0 );
Vec_IntFree( vValue1 );
}
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h
index 185ac7b9..312354da 100644
--- a/src/base/abc/abc.h
+++ b/src/base/abc/abc.h
@@ -789,7 +789,7 @@ extern ABC_DLL void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemove
extern ABC_DLL void Abc_NtkPermute( Abc_Ntk_t * pNtk, int fInputs, int fOutputs, int fFlops, char * pFlopPermFile );
extern ABC_DLL void Abc_NtkUnpermute( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromSops( char * pName, Vec_Ptr_t * vSops );
-extern ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromGias( char * pName, Vec_Ptr_t * vGias );
+extern ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromGias( char * pName, Vec_Ptr_t * vGias, Gia_Man_t * pMulti );
/*=== abcObj.c ==========================================================*/
extern ABC_DLL Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
extern ABC_DLL void Abc_ObjRecycle( Abc_Obj_t * pObj );
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c
index 8e10ab3b..7c54f3c4 100644
--- a/src/base/abc/abcNtk.c
+++ b/src/base/abc/abcNtk.c
@@ -2250,15 +2250,43 @@ Abc_Ntk_t * Abc_NtkCreateFromSops( char * pName, Vec_Ptr_t * vSops )
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkCreateFromGias( char * pName, Vec_Ptr_t * vGias )
+Abc_Ntk_t * Abc_NtkCreateFromGias( char * pName, Vec_Ptr_t * vGias, Gia_Man_t * pMulti )
{
- Gia_Man_t * pGia = (Gia_Man_t *)Vec_PtrEntry(vGias, 0);
+ Gia_Man_t * pGia = pMulti ? pMulti : (Gia_Man_t *)Vec_PtrEntry(vGias, 0);
Abc_Ntk_t * pNtk = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
Abc_Obj_t * pAbcObj, * pAbcObjPo;
Gia_Obj_t * pObj; int i, k;
pNtk->pName = Extra_UtilStrsav( pName );
for ( k = 0; k < Gia_ManCiNum(pGia); k++ )
Abc_NtkCreatePi( pNtk );
+ if ( pMulti )
+ {
+ Gia_ManCleanValue(pGia);
+ Gia_ManForEachCi( pGia, pObj, k )
+ pObj->Value = Abc_ObjId( Abc_NtkCi(pNtk, k) );
+ Gia_ManForEachAnd( pGia, pObj, k )
+ {
+ Abc_Obj_t * pAbcObj0 = Abc_NtkObj( pNtk, Gia_ObjFanin0(pObj)->Value );
+ Abc_Obj_t * pAbcObj1 = Abc_NtkObj( pNtk, Gia_ObjFanin1(pObj)->Value );
+ pAbcObj0 = Abc_ObjNotCond( pAbcObj0, Gia_ObjFaninC0(pObj) );
+ pAbcObj1 = Abc_ObjNotCond( pAbcObj1, Gia_ObjFaninC1(pObj) );
+ pAbcObj = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAbcObj0, pAbcObj1 );
+ pObj->Value = Abc_ObjId( pAbcObj );
+ }
+ Gia_ManForEachCo( pGia, pObj, k )
+ {
+ //pObj = Gia_ManCo(pGia, 0);
+ if ( Gia_ObjFaninId0p(pGia, pObj) == 0 )
+ pAbcObj = Abc_ObjNot( Abc_AigConst1(pNtk) );
+ else
+ pAbcObj = Abc_NtkObj( pNtk, Gia_ObjFanin0(pObj)->Value );
+ pAbcObj = Abc_ObjNotCond( pAbcObj, Gia_ObjFaninC0(pObj) );
+ pAbcObjPo = Abc_NtkCreatePo( pNtk );
+ Abc_ObjAddFanin( pAbcObjPo, pAbcObj );
+ }
+ }
+ else
+ {
Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
{
assert( Gia_ManCoNum(pGia) == 1 );
@@ -2283,6 +2311,7 @@ Abc_Ntk_t * Abc_NtkCreateFromGias( char * pName, Vec_Ptr_t * vGias )
pAbcObjPo = Abc_NtkCreatePo( pNtk );
Abc_ObjAddFanin( pAbcObjPo, pAbcObj );
}
+ }
Abc_NtkAddDummyPiNames( pNtk );
Abc_NtkAddDummyPoNames( pNtk );
return pNtk;
diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c
index 038079e8..1f0c9725 100644
--- a/src/base/abc/abcUtil.c
+++ b/src/base/abc/abcUtil.c
@@ -3141,10 +3141,10 @@ Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops )
assert( Vec_WecSize(vRes) == iNode );
return vRes;
}
-Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias )
+Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti )
{
Vec_Wec_t * vRes = NULL;
- Abc_Ntk_t * pNtk = Abc_NtkCreateFromGias( "top", vGias );
+ Abc_Ntk_t * pNtk = Abc_NtkCreateFromGias( "top", vGias, pMulti );
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pFanin;
int i, k, iNode = 0;
@@ -3173,7 +3173,7 @@ Gia_Man_t * Abc_GiaSynthesizeInter( Gia_Man_t * p )
Abc_Ntk_t * pNtkNew, * pNtk;
Vec_Ptr_t * vGias = Vec_PtrAlloc( 1 );
Vec_PtrPush( vGias, p );
- pNtk = Abc_NtkCreateFromGias( "top", vGias );
+ pNtk = Abc_NtkCreateFromGias( "top", vGias, NULL );
Vec_PtrFree( vGias );
Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk );
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "balance; collapse; muxes; strash; dc2" );
diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c
index 4c8ad4eb..f063f7fb 100644
--- a/src/base/acb/acbFunc.c
+++ b/src/base/acb/acbFunc.c
@@ -1893,8 +1893,8 @@ Vec_Ptr_t * Acb_GenerateSignalNames( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t
Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUsed, Vec_Ptr_t * vSops, Vec_Ptr_t * vGias, Vec_Int_t * vTars )
{
extern Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops );
- extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias );
- Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate;
+ extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti );
+ Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias, NULL) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate;
int nOuts = vGias ? Vec_PtrSize(vGias) : Vec_PtrSize(vSops);
int i, k, iObj, nWires = Vec_WecSize(vGates) - Vec_IntSize(vUsed) - nOuts, fFirst = 1;
Vec_Ptr_t * vNames = Acb_GenerateSignalNames( p, vDivs, vUsed, nWires, vTars, vGates );
@@ -1961,6 +1961,142 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
/**Function*************************************************************
+ Synopsis [Patch generation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Acb_GenerateInstance2( Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts )
+{
+ char * pName; int i;
+ Vec_Str_t * vStr = Vec_StrAlloc( 100 );
+ Vec_StrAppend( vStr, " patch p0 (" );
+ Vec_PtrForEachEntry( char *, vOuts, pName, i )
+ Vec_StrPrintF( vStr, "%s .%s(target_%s)", i ? ",":"", pName, pName );
+ Vec_PtrForEachEntry( char *, vIns, pName, i )
+ Vec_StrPrintF( vStr, ", .%s(%s)", pName, pName );
+ Vec_StrAppend( vStr, " );\n\n" );
+ Vec_StrPush( vStr, '\0' );
+ return vStr;
+}
+Vec_Ptr_t * Acb_GenerateSignalNames2( Vec_Wec_t * vGates, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts )
+{
+ int nIns = Vec_PtrSize(vIns), nOuts = Vec_PtrSize(vOuts);
+ int nNodes = Vec_WecSize(vGates) - nIns - nOuts;
+ Vec_Ptr_t * vRes = Vec_PtrStart( Vec_WecSize(vGates) ); char * pName;
+ Vec_Str_t * vStr = Vec_StrAlloc(1000); int i, nWires = 1;
+ // create input names
+ Vec_PtrForEachEntry( char *, vIns, pName, i )
+ Vec_PtrWriteEntry( vRes, i, Abc_UtilStrsav(pName) );
+ // create names for nodes driving outputs
+ Vec_PtrForEachEntry( char *, vOuts, pName, i )
+ {
+ Vec_Int_t * vGate = Vec_WecEntry( vGates, nIns + nNodes + i );
+ assert( Vec_IntEntry(vGate, 0) == ABC_OPER_BIT_BUF );
+ Vec_PtrWriteEntry( vRes, Vec_IntEntry(vGate, 1), Abc_UtilStrsav(pName) );
+ }
+ for ( i = nIns; i < nIns + nNodes; i++ )
+ if ( Vec_PtrEntry(vRes, i) == NULL )
+ {
+ Vec_StrPrintF( vStr, "ww%d", nWires++ );
+ Vec_StrPush( vStr, '\0' );
+ Vec_PtrWriteEntry( vRes, i, Vec_StrReleaseArray(vStr) );
+ }
+ Vec_StrFree( vStr );
+ return vRes;
+}
+Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts )
+{
+ extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti );
+ Vec_Wec_t * vGates = Abc_GiaSynthesize( NULL, pGia ); Vec_Int_t * vGate;
+ int nIns = Vec_PtrSize(vIns), nOuts = Vec_PtrSize(vOuts); char * pName;
+ int i, k, iObj, nWires = Vec_WecSize(vGates) - nIns - nOuts, fFirst = 1;
+ Vec_Ptr_t * vNames = Acb_GenerateSignalNames2( vGates, vIns, vOuts );
+
+ Vec_Str_t * vStr = Vec_StrAlloc( 100 );
+ Vec_StrAppend( vStr, "module patch (" );
+
+ Vec_PtrForEachEntry( char *, vOuts, pName, i )
+ Vec_StrPrintF( vStr, "%s %s", i ? ",":"", pName );
+ Vec_PtrForEachEntry( char *, vIns, pName, i )
+ Vec_StrPrintF( vStr, ", %s", pName );
+ Vec_StrAppend( vStr, " );\n\n" );
+
+ Vec_StrAppend( vStr, " output" );
+ Vec_PtrForEachEntry( char *, vOuts, pName, i )
+ Vec_StrPrintF( vStr, "%s %s", i ? ",":"", pName );
+ Vec_StrAppend( vStr, ";\n" );
+
+ Vec_StrAppend( vStr, " input" );
+ Vec_PtrForEachEntry( char *, vIns, pName, i )
+ Vec_StrPrintF( vStr, "%s %s", i ? ",":"", pName );
+ Vec_StrAppend( vStr, ";\n" );
+
+ if ( nWires > nOuts )
+ {
+ Vec_StrAppend( vStr, " wire" );
+ for ( i = 0; i < nWires; i++ )
+ {
+ char * pName = (char *)Vec_PtrEntry( vNames, nIns+i );
+ if ( !strncmp(pName, "ww", 2) )
+ Vec_StrPrintF( vStr, "%s %s", fFirst ? "":",", pName ), fFirst = 0;
+ }
+ Vec_StrAppend( vStr, ";\n\n" );
+ }
+
+ // create internal nodes
+ Vec_WecForEachLevelStartStop( vGates, vGate, i, nIns, nIns+nWires )
+ {
+ if ( Vec_IntSize(vGate) > 2 )
+ {
+ Vec_StrPrintF( vStr, " %s (", Acb_Oper2Name(Vec_IntEntry(vGate, 0)) );
+ Vec_IntForEachEntryStart( vGate, iObj, k, 1 )
+ Vec_StrPrintF( vStr, "%s %s", k > 1 ? ",":"", (char *)Vec_PtrEntry(vNames, iObj) );
+ Vec_StrAppend( vStr, " );\n" );
+ }
+ else
+ {
+ assert( Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_F || Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_T );
+ Vec_StrPrintF( vStr, " %s (", Acb_Oper2Name( ABC_OPER_BIT_BUF ) );
+ Vec_StrPrintF( vStr, " %s, ", (char *)Vec_PtrEntry(vNames, Vec_IntEntry(vGate, 1)) );
+ Vec_StrPrintF( vStr, " 1\'b%d", Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_T );
+ Vec_StrPrintF( vStr, " );\n" );
+ }
+ }
+ Vec_StrAppend( vStr, "\nendmodule\n\n" );
+ Vec_StrPush( vStr, '\0' );
+ Vec_PtrFreeFree( vNames );
+ Vec_WecFree( vGates );
+
+ printf( "Synthesized patch with %d inputs, %d outputs and %d gates.\n", nIns, nOuts, nWires );
+ return vStr;
+}
+void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut )
+{
+ extern void Acb_GenerateFilePatch( Vec_Str_t * p, char * pFileNamePatch );
+ extern void Acb_GenerateFileOut( Vec_Str_t * vPatchLine, char * pFileNameF, char * pFileNameOut, Vec_Str_t * vPatch );
+ extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber );
+ Vec_Str_t * vInst = Acb_GenerateInstance2( vIns, vOuts );
+ Vec_Str_t * vPatch = Acb_GeneratePatch2( pGia, vIns, vOuts );
+ //printf( "%s", Vec_StrArray(vPatch) );
+ //Gia_AigerWrite( pGia, "test.aig", 0, 0, 0 );
+ // generate output files
+ Acb_GenerateFilePatch( vPatch, "patch.v" );
+ printf( "Finished dumping patch file \"%s\".\n", "patch.v" );
+ Acb_NtkInsert( pFileName, "temp.v", vOuts, 0 );
+ printf( "Finished dumping intermediate file \"%s\".\n", "temp.v" );
+ Acb_GenerateFileOut( vInst, "temp.v", pFileNameOut, vPatch );
+ printf( "Finished dumping the resulting file \"%s\".\n", pFileNameOut );
+ Vec_StrFree( vInst );
+ Vec_StrFree( vPatch );
+}
+
+/**Function*************************************************************
+
Synopsis [Produce output files.]
Description []
diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c
index dfebd720..6c409c45 100644
--- a/src/base/acb/acbUtil.c
+++ b/src/base/acb/acbUtil.c
@@ -589,13 +589,14 @@ Gia_Man_t * Acb_NtkToGia2( Acb_Ntk_t * p, int fUseXors, Vec_Int_t * vTargets, in
SeeAlso []
***********************************************************************/
-Vec_Int_t * Acb_NtkCollectCopies( Acb_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t ** pvNodesR )
+Vec_Int_t * Acb_NtkCollectCopies( Acb_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t ** pvNodesR, Vec_Bit_t ** pvPolar )
{
int i, iObj, iLit, nTargets = Vec_IntSize(&p->vTargets);
Vec_Int_t * vObjs = Acb_NtkFindNodes2( p );
Vec_Int_t * vNodes = Vec_IntAlloc( Acb_NtkObjNum(p) );
Vec_Ptr_t * vNodesR = Vec_PtrStart( Gia_ManObjNum(pGia) );
Vec_Bit_t * vDriver = Vec_BitStart( Gia_ManObjNum(pGia) );
+ Vec_Bit_t * vPolar = Vec_BitStart( Gia_ManObjNum(pGia) );
Gia_ManForEachCiId( pGia, iObj, i )
if ( i < Gia_ManCiNum(pGia) - nTargets )
Vec_PtrWriteEntry( vNodesR, iObj, Abc_UtilStrsav(Acb_ObjNameStr(p, Acb_NtkCi(p, i))) );
@@ -614,12 +615,14 @@ Vec_Int_t * Acb_NtkCollectCopies( Acb_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t **
{
Vec_PtrWriteEntry( vNodesR, Abc_Lit2Var(iLit), Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) );
Vec_IntPush( vNodes, Abc_Lit2Var(iLit) );
+ Vec_BitWriteEntry( vPolar, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
}
}
Vec_BitFree( vDriver );
Vec_IntFree( vObjs );
Vec_IntSort( vNodes, 0 );
*pvNodesR = vNodesR;
+ *pvPolar = vPolar;
return vNodes;
}
Vec_Int_t * Acb_NtkCollectUser( Acb_Ntk_t * p, Vec_Ptr_t * vUser )
@@ -656,7 +659,7 @@ Vec_Int_t * Acb_NtkCollectUser( Acb_Ntk_t * p, Vec_Ptr_t * vUser )
***********************************************************************/
int Acb_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVerbose,
- Gia_Man_t ** ppGiaF, Gia_Man_t ** ppGiaG, Vec_Int_t ** pvNodes, Vec_Ptr_t ** pvNodesR )
+ Gia_Man_t ** ppGiaF, Gia_Man_t ** ppGiaG, Vec_Int_t ** pvNodes, Vec_Ptr_t ** pvNodesR, Vec_Bit_t ** pvPolar )
{
extern Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW );
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileName0, NULL );
@@ -671,7 +674,7 @@ int Acb_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer
assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) );
*ppGiaF = pGiaF;
*ppGiaG = pGiaG;
- *pvNodes = Acb_NtkCollectCopies( pNtkF, pGiaF, pvNodesR );
+ *pvNodes = Acb_NtkCollectCopies( pNtkF, pGiaF, pvNodesR, pvPolar );
RetValue = nTargets;
}
if ( pNtkF ) Acb_ManFree( pNtkF->pDesign );
@@ -690,7 +693,7 @@ int Acb_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer
SeeAlso []
***********************************************************************/
-Vec_Int_t * Abc_NtkCollectCopies( Abc_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t ** pvNodesR )
+Vec_Int_t * Abc_NtkCollectCopies( Abc_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t ** pvNodesR, Vec_Bit_t ** pvPolar )
{
int i, iObj, iLit;
Abc_Obj_t * pObj;
@@ -698,6 +701,7 @@ Vec_Int_t * Abc_NtkCollectCopies( Abc_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t **
Vec_Int_t * vNodes = Vec_IntAlloc( Abc_NtkObjNumMax(p) );
Vec_Ptr_t * vNodesR = Vec_PtrStart( Gia_ManObjNum(pGia) );
Vec_Bit_t * vDriver = Vec_BitStart( Gia_ManObjNum(pGia) );
+ Vec_Bit_t * vPolar = Vec_BitStart( Gia_ManObjNum(pGia) );
Gia_ManForEachCiId( pGia, iObj, i )
Vec_PtrWriteEntry( vNodesR, iObj, Abc_UtilStrsav(Abc_ObjName(Abc_NtkCi(p, i))) );
Gia_ManForEachCoId( pGia, iObj, i )
@@ -713,12 +717,14 @@ Vec_Int_t * Abc_NtkCollectCopies( Abc_Ntk_t * p, Gia_Man_t * pGia, Vec_Ptr_t **
{
Vec_PtrWriteEntry( vNodesR, Abc_Lit2Var(iLit), Abc_UtilStrsav(Abc_ObjName(pObj)) );
Vec_IntPush( vNodes, Abc_Lit2Var(iLit) );
+ Vec_BitWriteEntry( vPolar, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
}
}
Vec_BitFree( vDriver );
Vec_PtrFree( vObjs );
Vec_IntSort( vNodes, 0 );
*pvNodesR = vNodesR;
+ *pvPolar = vPolar;
return vNodes;
}
int Abc_ObjToGia2( Gia_Man_t * pNew, Abc_Ntk_t * p, Abc_Obj_t * pObj, Vec_Int_t * vTemp, int fUseXors )
@@ -766,7 +772,7 @@ Gia_Man_t * Abc_NtkToGia2( Abc_Ntk_t * p, int fUseXors )
return pNew;
}
int Abc_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVerbose,
- Gia_Man_t ** ppGiaF, Gia_Man_t ** ppGiaG, Vec_Int_t ** pvNodes, Vec_Ptr_t ** pvNodesR )
+ Gia_Man_t ** ppGiaF, Gia_Man_t ** ppGiaG, Vec_Int_t ** pvNodes, Vec_Ptr_t ** pvNodesR, Vec_Bit_t ** pvPolar )
{
Abc_Ntk_t * pNtkF = Io_Read( pFileName0, Io_ReadFileType(pFileName0), 1, 0 );
Abc_Ntk_t * pNtkG = Io_Read( pFileName1, Io_ReadFileType(pFileName1), 1, 0 );
@@ -779,7 +785,7 @@ int Abc_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer
assert( Abc_NtkCoNum(pNtkF) == Abc_NtkCoNum(pNtkG) );
*ppGiaF = pGiaF;
*ppGiaG = pGiaG;
- *pvNodes = Abc_NtkCollectCopies( pNtkF, pGiaF, pvNodesR );
+ *pvNodes = Abc_NtkCollectCopies( pNtkF, pGiaF, pvNodesR, pvPolar );
RetValue = 0;
}
if ( pNtkF ) Abc_NtkDelete( pNtkF );
@@ -839,7 +845,7 @@ Vec_Int_t * Acb_NtkPlaces( char * pFileName, Vec_Ptr_t * vNames )
ABC_FREE( pBuffer );
return vPlaces;
}
-void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames )
+void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber )
{
int i, k, Prev = 0, Pos, Pos2, iObj;
Vec_Int_t * vPlaces;
@@ -872,11 +878,27 @@ void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames
fputc( pBuffer[k], pFile );
fprintf( pFile, "\n\n" );
fprintf( pFile, " wire " );
- Vec_PtrForEachEntry( char *, vNames, pName, i )
- fprintf( pFile, " t_%d%s", i, i==Vec_PtrSize(vNames)-1 ? ";" : "," );
+ if ( fNumber )
+ {
+ Vec_PtrForEachEntry( char *, vNames, pName, i )
+ fprintf( pFile, " t_%d%s", i, i==Vec_PtrSize(vNames)-1 ? ";" : "," );
+ }
+ else
+ {
+ Vec_PtrForEachEntry( char *, vNames, pName, i )
+ fprintf( pFile, " target_%s%s", pName, i==Vec_PtrSize(vNames)-1 ? ";" : "," );
+ }
fprintf( pFile, "\n\n" );
- Vec_PtrForEachEntry( char *, vNames, pName, i )
- fprintf( pFile, " buf( %s, t_%d );\n", pName, i );
+ if ( fNumber )
+ {
+ Vec_PtrForEachEntry( char *, vNames, pName, i )
+ fprintf( pFile, " buf( %s, t_%d );\n", pName, i );
+ }
+ else
+ {
+ Vec_PtrForEachEntry( char *, vNames, pName, i )
+ fprintf( pFile, " buf( %s, target_%s ); // t_%d\n", pName, pName, i );
+ }
fprintf( pFile, "\n" );
for ( k = Pos2; pBuffer[k]; k++ )
fputc( pBuffer[k], pFile );