Commit 8eeecc51 by Alan Mishchenko

Version abc80307

parent 8bd19a27
...@@ -24,7 +24,7 @@ MODULES := src/base/abc src/base/abci src/base/cmd \ ...@@ -24,7 +24,7 @@ MODULES := src/base/abc src/base/abci src/base/cmd \
default: $(PROG) default: $(PROG)
#OPTFLAGS := -DNDEBUG -O3 #OPTFLAGS := -DNDEBUG -O3
OPTFLAGS := -g -O OPTFLAGS := -g -O -DLIN64
CFLAGS += -Wall -Wno-unused-function $(OPTFLAGS) $(patsubst %, -I%, $(MODULES)) CFLAGS += -Wall -Wno-unused-function $(OPTFLAGS) $(patsubst %, -I%, $(MODULES))
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
......
...@@ -1178,6 +1178,10 @@ SOURCE=.\src\sat\bsat\satInterA.c ...@@ -1178,6 +1178,10 @@ SOURCE=.\src\sat\bsat\satInterA.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\sat\bsat\satInterP.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satMem.c SOURCE=.\src\sat\bsat\satMem.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -21,6 +21,13 @@ Several things to try if it does not compile on your platform: ...@@ -21,6 +21,13 @@ Several things to try if it does not compile on your platform:
compiling ABC with gcc. Please try installing this library from compiling ABC with gcc. Please try installing this library from
http://tiswww.case.edu/php/chet/readline/rltop.html http://tiswww.case.edu/php/chet/readline/rltop.html
To compile the latest version of ABC, you may need to define "LIN" or "LIN64"
(depending on whether you are using 32- or 64-bit Linux).
For example, instead of
OPTFLAGS := -g -O
use
OPTFLAGS := -g -O -DLIN64
in Makefile.
Finally, run regression test: Finally, run regression test:
abc>>> so regtest.script abc>>> so regtest.script
...@@ -162,7 +162,17 @@ clk = clock(); ...@@ -162,7 +162,17 @@ clk = clock();
pRes = Inta_ManInterpolate( pManInter, pSatCnf, vVarsAB, fVerbose ); pRes = Inta_ManInterpolate( pManInter, pSatCnf, vVarsAB, fVerbose );
Inta_ManFree( pManInter ); Inta_ManFree( pManInter );
timeInt += clock() - clk; timeInt += clock() - clk;
/*
// test UNSAT core computation
{
Intp_Man_t * pManProof;
Vec_Int_t * vCore;
pManProof = Intp_ManAlloc();
vCore = Intp_ManUnsatCore( pManProof, pSatCnf, 0 );
Intp_ManFree( pManProof );
Vec_IntFree( vCore );
}
*/
Vec_IntFree( vVarsAB ); Vec_IntFree( vVarsAB );
Sto_ManFree( pSatCnf ); Sto_ManFree( pSatCnf );
return pRes; return pRes;
......
...@@ -105,8 +105,8 @@ clk2 = clock(); ...@@ -105,8 +105,8 @@ clk2 = clock();
dd->nSignCur = 1; dd->nSignCur = 1;
dd->tUnique[0].s = dd->nSignCur; dd->tUnique[0].s = dd->nSignCur;
dd->tUnique[0].v = CLOUD_CONST_INDEX; dd->tUnique[0].v = CLOUD_CONST_INDEX;
dd->tUnique[0].e = CLOUD_VOID; dd->tUnique[0].e = NULL;
dd->tUnique[0].t = CLOUD_VOID; dd->tUnique[0].t = NULL;
dd->one = dd->tUnique; dd->one = dd->tUnique;
dd->zero = Cloud_Not(dd->one); dd->zero = Cloud_Not(dd->one);
dd->nNodesCur = 1; dd->nNodesCur = 1;
...@@ -256,7 +256,7 @@ CloudNode * Cloud_MakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudN ...@@ -256,7 +256,7 @@ CloudNode * Cloud_MakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudN
if ( Cloud_IsComplement(t) ) if ( Cloud_IsComplement(t) )
{ {
pRes = cloudMakeNode( dd, v, Cloud_Not(t), Cloud_Not(e) ); pRes = cloudMakeNode( dd, v, Cloud_Not(t), Cloud_Not(e) );
if ( pRes != CLOUD_VOID ) if ( pRes != NULL )
pRes = Cloud_Not(pRes); pRes = Cloud_Not(pRes);
} }
else else
...@@ -314,7 +314,7 @@ CloudNode * cloudMakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNo ...@@ -314,7 +314,7 @@ CloudNode * cloudMakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNo
printf( "Cloud needs restart!\n" ); printf( "Cloud needs restart!\n" );
// fflush( stdout ); // fflush( stdout );
// exit(1); // exit(1);
return CLOUD_VOID; return NULL;
} }
// create the node // create the node
entryUnique->s = dd->nSignCur; entryUnique->s = dd->nSignCur;
...@@ -367,7 +367,7 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g ) ...@@ -367,7 +367,7 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
cacheEntry = dd->tCaches[CLOUD_OPER_AND] + cloudHashCudd2(f, g, dd->shiftCache[CLOUD_OPER_AND]); cacheEntry = dd->tCaches[CLOUD_OPER_AND] + cloudHashCudd2(f, g, dd->shiftCache[CLOUD_OPER_AND]);
// cacheEntry = dd->tCaches[CLOUD_OPER_AND] + cloudHashBuddy2(f, g, dd->shiftCache[CLOUD_OPER_AND]); // cacheEntry = dd->tCaches[CLOUD_OPER_AND] + cloudHashBuddy2(f, g, dd->shiftCache[CLOUD_OPER_AND]);
r = cloudCacheLookup2( cacheEntry, dd->nSignCur, f, g ); r = cloudCacheLookup2( cacheEntry, dd->nSignCur, f, g );
if ( r != CLOUD_VOID ) if ( r != NULL )
{ {
dd->nCacheHits++; dd->nCacheHits++;
return r; return r;
...@@ -419,16 +419,16 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g ) ...@@ -419,16 +419,16 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
else else
t = cloudBddAnd( dd, gv, fv ); t = cloudBddAnd( dd, gv, fv );
if ( t == CLOUD_VOID ) if ( t == NULL )
return CLOUD_VOID; return NULL;
if ( fnv <= gnv ) if ( fnv <= gnv )
e = cloudBddAnd( dd, fnv, gnv ); e = cloudBddAnd( dd, fnv, gnv );
else else
e = cloudBddAnd( dd, gnv, fnv ); e = cloudBddAnd( dd, gnv, fnv );
if ( e == CLOUD_VOID ) if ( e == NULL )
return CLOUD_VOID; return NULL;
if ( t == e ) if ( t == e )
r = t; r = t;
...@@ -437,15 +437,15 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g ) ...@@ -437,15 +437,15 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
if ( Cloud_IsComplement(t) ) if ( Cloud_IsComplement(t) )
{ {
r = cloudMakeNode( dd, var, Cloud_Not(t), Cloud_Not(e) ); r = cloudMakeNode( dd, var, Cloud_Not(t), Cloud_Not(e) );
if ( r == CLOUD_VOID ) if ( r == NULL )
return CLOUD_VOID; return NULL;
r = Cloud_Not(r); r = Cloud_Not(r);
} }
else else
{ {
r = cloudMakeNode( dd, var, t, e ); r = cloudMakeNode( dd, var, t, e );
if ( r == CLOUD_VOID ) if ( r == NULL )
return CLOUD_VOID; return NULL;
} }
} }
cloudCacheInsert2( cacheEntry, dd->nSignCur, f, g, r ); cloudCacheInsert2( cacheEntry, dd->nSignCur, f, g, r );
...@@ -484,8 +484,8 @@ static inline CloudNode * cloudBddAnd_gate( CloudManager * dd, CloudNode * f, Cl ...@@ -484,8 +484,8 @@ static inline CloudNode * cloudBddAnd_gate( CloudManager * dd, CloudNode * f, Cl
******************************************************************************/ ******************************************************************************/
CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g ) CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
{ {
if ( Cloud_Regular(f) == CLOUD_VOID || Cloud_Regular(g) == CLOUD_VOID ) if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
return CLOUD_VOID; return NULL;
CLOUD_ASSERT(f); CLOUD_ASSERT(f);
CLOUD_ASSERT(g); CLOUD_ASSERT(g);
if ( dd->tCaches[CLOUD_OPER_AND] == NULL ) if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
...@@ -507,14 +507,14 @@ CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g ) ...@@ -507,14 +507,14 @@ CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g ) CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g )
{ {
CloudNode * res; CloudNode * res;
if ( Cloud_Regular(f) == CLOUD_VOID || Cloud_Regular(g) == CLOUD_VOID ) if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
return CLOUD_VOID; return NULL;
CLOUD_ASSERT(f); CLOUD_ASSERT(f);
CLOUD_ASSERT(g); CLOUD_ASSERT(g);
if ( dd->tCaches[CLOUD_OPER_AND] == NULL ) if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
cloudCacheAllocate( dd, CLOUD_OPER_AND ); cloudCacheAllocate( dd, CLOUD_OPER_AND );
res = cloudBddAnd_gate( dd, Cloud_Not(f), Cloud_Not(g) ); res = cloudBddAnd_gate( dd, Cloud_Not(f), Cloud_Not(g) );
res = Cloud_NotCond( res, res != CLOUD_VOID ); res = Cloud_NotCond( res, res != NULL );
return res; return res;
} }
...@@ -532,18 +532,18 @@ CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g ) ...@@ -532,18 +532,18 @@ CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g )
CloudNode * Cloud_bddXor( CloudManager * dd, CloudNode * f, CloudNode * g ) CloudNode * Cloud_bddXor( CloudManager * dd, CloudNode * f, CloudNode * g )
{ {
CloudNode * t0, * t1, * r; CloudNode * t0, * t1, * r;
if ( Cloud_Regular(f) == CLOUD_VOID || Cloud_Regular(g) == CLOUD_VOID ) if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
return CLOUD_VOID; return NULL;
CLOUD_ASSERT(f); CLOUD_ASSERT(f);
CLOUD_ASSERT(g); CLOUD_ASSERT(g);
if ( dd->tCaches[CLOUD_OPER_AND] == NULL ) if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
cloudCacheAllocate( dd, CLOUD_OPER_AND ); cloudCacheAllocate( dd, CLOUD_OPER_AND );
t0 = cloudBddAnd_gate( dd, f, Cloud_Not(g) ); t0 = cloudBddAnd_gate( dd, f, Cloud_Not(g) );
if ( t0 == CLOUD_VOID ) if ( t0 == NULL )
return CLOUD_VOID; return NULL;
t1 = cloudBddAnd_gate( dd, Cloud_Not(f), g ); t1 = cloudBddAnd_gate( dd, Cloud_Not(f), g );
if ( t1 == CLOUD_VOID ) if ( t1 == NULL )
return CLOUD_VOID; return NULL;
r = Cloud_bddOr( dd, t0, t1 ); r = Cloud_bddOr( dd, t0, t1 );
return r; return r;
} }
...@@ -631,7 +631,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n ) ...@@ -631,7 +631,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n )
if ( support[i] == 1 ) if ( support[i] == 1 )
{ {
res = Cloud_bddAnd( dd, res, dd->vars[i] ); res = Cloud_bddAnd( dd, res, dd->vars[i] );
if ( res == CLOUD_VOID ) if ( res == NULL )
break; break;
} }
FREE( support ); FREE( support );
...@@ -831,8 +831,8 @@ CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc ) ...@@ -831,8 +831,8 @@ CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc )
// try to find the cube with the negative literal // try to find the cube with the negative literal
res = Cloud_GetOneCube( dd, bFunc0 ); res = Cloud_GetOneCube( dd, bFunc0 );
if ( res == CLOUD_VOID ) if ( res == NULL )
return CLOUD_VOID; return NULL;
if ( res != dd->zero ) if ( res != dd->zero )
{ {
...@@ -842,8 +842,8 @@ CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc ) ...@@ -842,8 +842,8 @@ CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc )
{ {
// try to find the cube with the positive literal // try to find the cube with the positive literal
res = Cloud_GetOneCube( dd, bFunc1 ); res = Cloud_GetOneCube( dd, bFunc1 );
if ( res == CLOUD_VOID ) if ( res == NULL )
return CLOUD_VOID; return NULL;
assert( res != dd->zero ); assert( res != dd->zero );
res = Cloud_bddAnd( dd, res, dd->vars[Cloud_V(bFunc)] ); res = Cloud_bddAnd( dd, res, dd->vars[Cloud_V(bFunc)] );
} }
...@@ -873,7 +873,7 @@ void Cloud_bddPrint( CloudManager * dd, CloudNode * Func ) ...@@ -873,7 +873,7 @@ void Cloud_bddPrint( CloudManager * dd, CloudNode * Func )
while ( 1 ) while ( 1 )
{ {
Cube = Cloud_GetOneCube( dd, Func ); Cube = Cloud_GetOneCube( dd, Func );
if ( Cube == CLOUD_VOID || Cube == dd->zero ) if ( Cube == NULL || Cube == dd->zero )
break; break;
if ( fFirst ) fFirst = 0; if ( fFirst ) fFirst = 0;
else printf( " + " ); else printf( " + " );
......
...@@ -27,6 +27,7 @@ extern "C" { ...@@ -27,6 +27,7 @@ extern "C" {
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#include "port_type.h"
#ifdef _WIN32 #ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0 #define inline __inline // compatible with MS VS 6.0
...@@ -162,9 +163,6 @@ struct cloudCacheEntry3 // the three-argument cache ...@@ -162,9 +163,6 @@ struct cloudCacheEntry3 // the three-argument cache
// parameters // parameters
#define CLOUD_NODE_BITS 23 #define CLOUD_NODE_BITS 23
#define CLOUD_ONE ((unsigned)0x00000001)
#define CLOUD_NOT_ONE ((unsigned)0xfffffffe)
#define CLOUD_VOID ((unsigned)0x00000000)
#define CLOUD_CONST_INDEX ((unsigned)0x0fffffff) #define CLOUD_CONST_INDEX ((unsigned)0x0fffffff)
#define CLOUD_MARK_ON ((unsigned)0x10000000) #define CLOUD_MARK_ON ((unsigned)0x10000000)
...@@ -182,10 +180,10 @@ struct cloudCacheEntry3 // the three-argument cache ...@@ -182,10 +180,10 @@ struct cloudCacheEntry3 // the three-argument cache
#define cloudHashCudd3(f,g,h,s) (((((unsigned)(f) * DD_P1 + (unsigned)(g)) * DD_P2 + (unsigned)(h)) * DD_P3) >> (s)) #define cloudHashCudd3(f,g,h,s) (((((unsigned)(f) * DD_P1 + (unsigned)(g)) * DD_P2 + (unsigned)(h)) * DD_P3) >> (s))
// node complementation (using node) // node complementation (using node)
#define Cloud_Regular(p) ((CloudNode*)(((unsigned)(p)) & CLOUD_NOT_ONE)) // get the regular node (w/o bubble) #define Cloud_Regular(p) ((CloudNode*)(((PORT_PTRUINT_T)(p)) & ~01)) // get the regular node (w/o bubble)
#define Cloud_Not(p) ((CloudNode*)(((unsigned)(p)) ^ CLOUD_ONE)) // complement the node #define Cloud_Not(p) ((CloudNode*)(((PORT_PTRUINT_T)(p)) ^ 01)) // complement the node
#define Cloud_NotCond(p,c) (((int)(c))? Cloud_Not(p):(p)) // complement the node conditionally #define Cloud_NotCond(p,c) ((CloudNode*)(((PORT_PTRUINT_T)(p)) ^ (c))) // complement the node conditionally
#define Cloud_IsComplement(p) ((int)(((unsigned)(p)) & CLOUD_ONE)) // check if complemented #define Cloud_IsComplement(p) ((int)(((PORT_PTRUINT_T)(p)) & 01)) // check if complemented
// checking constants (using node) // checking constants (using node)
#define Cloud_IsConstant(p) (((Cloud_Regular(p))->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX) #define Cloud_IsConstant(p) (((Cloud_Regular(p))->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)
#define cloudIsConstant(p) (((p)->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX) #define cloudIsConstant(p) (((p)->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)
...@@ -204,9 +202,9 @@ struct cloudCacheEntry3 // the three-argument cache ...@@ -204,9 +202,9 @@ struct cloudCacheEntry3 // the three-argument cache
#define cloudNodeIsMarked(p) ((int)((p)->v & CLOUD_MARK_ON)) #define cloudNodeIsMarked(p) ((int)((p)->v & CLOUD_MARK_ON))
// cache lookups and inserts (using node) // cache lookups and inserts (using node)
#define cloudCacheLookup1(p,sign,f) (((p)->s == (sign) && (p)->a == (f))? ((p)->r): (CLOUD_VOID)) #define cloudCacheLookup1(p,sign,f) (((p)->s == (sign) && (p)->a == (f))? ((p)->r): (0))
#define cloudCacheLookup2(p,sign,f,g) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g))? ((p)->r): (CLOUD_VOID)) #define cloudCacheLookup2(p,sign,f,g) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g))? ((p)->r): (0))
#define cloudCacheLookup3(p,sign,f,g,h) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g) && (p)->c == (h))? ((p)->r): (CLOUD_VOID)) #define cloudCacheLookup3(p,sign,f,g,h) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g) && (p)->c == (h))? ((p)->r): (0))
// cache inserts // cache inserts
#define cloudCacheInsert1(p,sign,f,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->r = (r))) #define cloudCacheInsert1(p,sign,f,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->r = (r)))
#define cloudCacheInsert2(p,sign,f,g,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->b = (g)), ((p)->r = (r))) #define cloudCacheInsert2(p,sign,f,g,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->b = (g)), ((p)->r = (r)))
......
...@@ -266,6 +266,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan ) ...@@ -266,6 +266,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
Abc_NtkAddDummyBoxNames( pNtkNew ); Abc_NtkAddDummyBoxNames( pNtkNew );
else else
{ {
/*
{ {
int i, k, iFlop, Counter = 0; int i, k, iFlop, Counter = 0;
FILE * pFile; FILE * pFile;
...@@ -285,6 +286,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan ) ...@@ -285,6 +286,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
fclose( pFile ); fclose( pFile );
//printf( "\n" ); //printf( "\n" );
} }
*/
assert( Abc_NtkBoxNum(pNtkOld) == Abc_NtkLatchNum(pNtkOld) ); assert( Abc_NtkBoxNum(pNtkOld) == Abc_NtkLatchNum(pNtkOld) );
nDigits = Extra_Base10Log( Abc_NtkLatchNum(pNtkNew) ); nDigits = Extra_Base10Log( Abc_NtkLatchNum(pNtkNew) );
Abc_NtkForEachLatch( pNtkNew, pObjNew, i ) Abc_NtkForEachLatch( pNtkNew, pObjNew, i )
...@@ -1622,11 +1624,14 @@ timeInt = 0; ...@@ -1622,11 +1624,14 @@ timeInt = 0;
} }
else else
pNtkInter1 = Abc_NtkInterOne( pNtkOn1, pNtkOff1, fVerbose ); pNtkInter1 = Abc_NtkInterOne( pNtkOn1, pNtkOff1, fVerbose );
Abc_NtkAppend( pNtkInter, pNtkInter1, 1 ); if ( pNtkInter1 )
{
Abc_NtkAppend( pNtkInter, pNtkInter1, 1 );
Abc_NtkDelete( pNtkInter1 );
}
Abc_NtkDelete( pNtkOn1 ); Abc_NtkDelete( pNtkOn1 );
Abc_NtkDelete( pNtkOff1 ); Abc_NtkDelete( pNtkOff1 );
Abc_NtkDelete( pNtkInter1 );
} }
// PRT( "CNF", timeCnf ); // PRT( "CNF", timeCnf );
// PRT( "SAT", timeSat ); // PRT( "SAT", timeSat );
......
...@@ -33,11 +33,12 @@ static inline void Abc_ObjSetArrival( Abc_Obj_t * pNode, float Time ) { pNode- ...@@ -33,11 +33,12 @@ static inline void Abc_ObjSetArrival( Abc_Obj_t * pNode, float Time ) { pNode-
static inline void Abc_ObjSetRequired( Abc_Obj_t * pNode, float Time ) { pNode->pNtk->pLutTimes[3*pNode->Id+1] = Time; } static inline void Abc_ObjSetRequired( Abc_Obj_t * pNode, float Time ) { pNode->pNtk->pLutTimes[3*pNode->Id+1] = Time; }
static inline void Abc_ObjSetSlack( Abc_Obj_t * pNode, float Time ) { pNode->pNtk->pLutTimes[3*pNode->Id+2] = Time; } static inline void Abc_ObjSetSlack( Abc_Obj_t * pNode, float Time ) { pNode->pNtk->pLutTimes[3*pNode->Id+2] = Time; }
extern void * Abc_FrameReadLibLut();
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [Sorts the pins in the decreasing order of delays.] Synopsis [Sorts the pins in the decreasing order of delays.]
...@@ -95,7 +96,6 @@ void Abc_NtkDelayTraceSortPins( Abc_Obj_t * pNode, int * pPinPerm, float * pPinD ...@@ -95,7 +96,6 @@ void Abc_NtkDelayTraceSortPins( Abc_Obj_t * pNode, int * pPinPerm, float * pPinD
***********************************************************************/ ***********************************************************************/
float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib ) float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib )
{ {
extern void * Abc_FrameReadLibLut();
int fUseSorting = 0; int fUseSorting = 0;
int pPinPerm[32]; int pPinPerm[32];
float pPinDelays[32]; float pPinDelays[32];
......
...@@ -131,7 +131,7 @@ void Abc_GenSorter( char * pFileName, int nVars ) ...@@ -131,7 +131,7 @@ void Abc_GenSorter( char * pFileName, int nVars )
fprintf( pFile, " y%02d=%0*d", k, nDigits, Counter++ ); fprintf( pFile, " y%02d=%0*d", k, nDigits, Counter++ );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
Counter -= nVars; Counter -= nVars;
for ( i = 1; i < nVars-2; i++ ) for ( i = 1; i < 2*nVars-2; i++ )
{ {
fprintf( pFile, ".subckt Layer%d", (i&1) ); fprintf( pFile, ".subckt Layer%d", (i&1) );
for ( k = 0; k < nVars; k++ ) for ( k = 0; k < nVars; k++ )
......
...@@ -591,6 +591,16 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk ) ...@@ -591,6 +591,16 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk )
ASat_SolverSetPrefVars( pSat, pPrefVars, nVars ); ASat_SolverSetPrefVars( pSat, pPrefVars, nVars );
} }
*/ */
/*
Abc_NtkForEachObj( pNtk, pNode, i )
{
if ( !pNode->fMarkA )
continue;
printf( "%10s : ", Abc_ObjName(pNode) );
printf( "%3d\n", (int)pNode->pCopy );
}
printf( "\n" );
*/
RetValue = 1; RetValue = 1;
Quits : Quits :
// delete // delete
...@@ -876,6 +886,121 @@ finish: ...@@ -876,6 +886,121 @@ finish:
/**Function*************************************************************
Synopsis [Writes CNF for the sorter with N inputs asserting Q ones.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens )
{
extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
extern void * Abc_FrameGetGlobalFrame();
extern Abc_Ntk_t * Abc_FrameReadNtk( void * p );
char Command[100];
void * pAbc;
Abc_Ntk_t * pNtk;
Abc_Obj_t * pObj, * ppNodes[2], * ppRoots[2];
Vec_Ptr_t * vNodes;
FILE * pFile;
int i, Counter;
if ( nQueens <= 0 && nQueens >= nVars )
{
printf( "The number of queens (Q = %d) should belong to the interval: 0 < Q < %d.\n", nQueens, nQueens, nVars );
return;
}
assert( nQueens > 0 && nQueens < nVars );
pAbc = Abc_FrameGetGlobalFrame();
// generate sorter
sprintf( Command, "gen -s -N %d sorter%d.blif", nVars, nVars );
if ( Cmd_CommandExecute( pAbc, Command ) )
{
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
return;
}
// read the file
sprintf( Command, "read sorter%d.blif; strash", nVars );
if ( Cmd_CommandExecute( pAbc, Command ) )
{
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
return;
}
// get the current network
pNtk = Abc_FrameReadNtk(pAbc);
// collect the nodes for the given two primary outputs
ppNodes[0] = Abc_NtkPo( pNtk, nVars - nQueens - 1 );
ppNodes[1] = Abc_NtkPo( pNtk, nVars - nQueens );
ppRoots[0] = Abc_ObjFanin0( ppNodes[0] );
ppRoots[1] = Abc_ObjFanin0( ppNodes[1] );
vNodes = Abc_NtkDfsNodes( pNtk, ppRoots, 2 );
// assign CNF variables
Counter = 0;
Abc_NtkForEachObj( pNtk, pObj, i )
pObj->pCopy = (void *)~0;
Abc_NtkForEachPi( pNtk, pObj, i )
pObj->pCopy = (void *)Counter++;
Vec_PtrForEachEntry( vNodes, pObj, i )
pObj->pCopy = (void *)Counter++;
/*
OutVar = pCnf->pVarNums[ pObj->Id ];
pVars[0] = pCnf->pVarNums[ Aig_ObjFanin0(pObj)->Id ];
pVars[1] = pCnf->pVarNums[ Aig_ObjFanin1(pObj)->Id ];
// positive phase
*pClas++ = pLits;
*pLits++ = 2 * OutVar;
*pLits++ = 2 * pVars[0] + !Aig_ObjFaninC0(pObj);
*pLits++ = 2 * pVars[1] + !Aig_ObjFaninC1(pObj);
// negative phase
*pClas++ = pLits;
*pLits++ = 2 * OutVar + 1;
*pLits++ = 2 * pVars[0] + Aig_ObjFaninC0(pObj);
*pClas++ = pLits;
*pLits++ = 2 * OutVar + 1;
*pLits++ = 2 * pVars[1] + Aig_ObjFaninC1(pObj);
*/
// add clauses for these nodes
pFile = fopen( pFileName, "w" );
fprintf( pFile, "c CNF for %d-bit sorter with %d bits set to 1 generated by ABC.\n", nVars, nQueens );
fprintf( pFile, "p cnf %d %d\n", Counter, 3 * Vec_PtrSize(vNodes) + 2 );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
// positive phase
fprintf( pFile, "%d %s%d %s%d 0\n", 1+(int)pObj->pCopy,
Abc_ObjFaninC0(pObj)? "" : "-", 1+(int)Abc_ObjFanin0(pObj)->pCopy,
Abc_ObjFaninC1(pObj)? "" : "-", 1+(int)Abc_ObjFanin1(pObj)->pCopy );
// negative phase
fprintf( pFile, "-%d %s%d 0\n", 1+(int)pObj->pCopy,
Abc_ObjFaninC0(pObj)? "-" : "", 1+(int)Abc_ObjFanin0(pObj)->pCopy );
fprintf( pFile, "-%d %s%d 0\n", 1+(int)pObj->pCopy,
Abc_ObjFaninC1(pObj)? "-" : "", 1+(int)Abc_ObjFanin1(pObj)->pCopy );
}
Vec_PtrFree( vNodes );
/*
*pClas++ = pLits;
*pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
*/
// assert the first literal to zero
fprintf( pFile, "%s%d 0\n",
Abc_ObjFaninC0(ppNodes[0])? "" : "-", 1+(int)Abc_ObjFanin0(ppNodes[0])->pCopy );
// assert the second literal to one
fprintf( pFile, "%s%d 0\n",
Abc_ObjFaninC0(ppNodes[1])? "-" : "", 1+(int)Abc_ObjFanin0(ppNodes[1])->pCopy );
fclose( pFile );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -168,17 +168,17 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -168,17 +168,17 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
} }
pAbc->TimeTotal += pAbc->TimeCommand; pAbc->TimeTotal += pAbc->TimeCommand;
fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n", fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n",
(float)(1.0 * pAbc->TimeCommand / CLOCKS_PER_SEC), (float)(1.0 * pAbc->TimeTotal / CLOCKS_PER_SEC) ); pAbc->TimeCommand, pAbc->TimeTotal );
/* /*
{ {
FILE * pTable; FILE * pTable;
pTable = fopen( "runtimes.txt", "a+" ); pTable = fopen( "runtimes.txt", "a+" );
fprintf( pTable, "%4.2f\n", (float)pAbc->TimeCommand / CLOCKS_PER_SEC ); fprintf( pTable, "%4.2f\n", pAbc->TimeCommand );
fclose( pTable ); fclose( pTable );
} }
*/ */
pAbc->TimeCommand = 0; pAbc->TimeCommand = 0.0;
return 0; return 0;
usage: usage:
......
...@@ -92,7 +92,7 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -92,7 +92,7 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Command * pCommand; Abc_Command * pCommand;
char * value; char * value;
int fError; int fError;
int clk; double clk;
if ( argc == 0 ) if ( argc == 0 )
return 0; return 0;
...@@ -121,10 +121,10 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -121,10 +121,10 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// execute the command // execute the command
clk = Extra_CpuTime(); clk = Extra_CpuTimeDouble();
pFunc = (int (*)(Abc_Frame_t *, int, char **))pCommand->pFunc; pFunc = (int (*)(Abc_Frame_t *, int, char **))pCommand->pFunc;
fError = (*pFunc)( pAbc, argc, argv ); fError = (*pFunc)( pAbc, argc, argv );
pAbc->TimeCommand += (Extra_CpuTime() - clk); pAbc->TimeCommand += Extra_CpuTimeDouble() - clk;
// automatic execution of arbitrary command after each command // automatic execution of arbitrary command after each command
// usually this is a passive command ... // usually this is a passive command ...
......
...@@ -58,6 +58,7 @@ static int IoCommandWriteList ( Abc_Frame_t * pAbc, int argc, char **argv ); ...@@ -58,6 +58,7 @@ static int IoCommandWriteList ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWritePla ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWritePla ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteSortCnf( Abc_Frame_t * pAbc, int argc, char **argv );
extern int glo_fMapped; extern int glo_fMapped;
...@@ -111,6 +112,7 @@ void Io_Init( Abc_Frame_t * pAbc ) ...@@ -111,6 +112,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "I/O", "write_pla", IoCommandWritePla, 0 ); Cmd_CommandAdd( pAbc, "I/O", "write_pla", IoCommandWritePla, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_verilog", IoCommandWriteVerilog, 0 ); Cmd_CommandAdd( pAbc, "I/O", "write_verilog", IoCommandWriteVerilog, 0 );
// Cmd_CommandAdd( pAbc, "I/O", "write_verlib", IoCommandWriteVerLib, 0 ); // Cmd_CommandAdd( pAbc, "I/O", "write_verlib", IoCommandWriteVerLib, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_sorter_cnf", IoCommandWriteSortCnf, 0 );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -2010,6 +2012,76 @@ usage: ...@@ -2010,6 +2012,76 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteSortCnf( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * pFileName;
int c;
int nVars = 16;
int nQueens = 4;
extern void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "NQh" ) ) != EOF )
{
switch ( c )
{
case 'N':
if ( globalUtilOptind >= argc )
{
fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nVars = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nVars <= 0 )
goto usage;
break;
case 'Q':
if ( globalUtilOptind >= argc )
{
fprintf( stdout, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
nQueens = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nQueens <= 0 )
goto usage;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
goto usage;
// get the output file name
pFileName = argv[globalUtilOptind];
Abc_NtkWriteSorterCnf( pFileName, nVars, nQueens );
// call the corresponding file writer
return 0;
usage:
fprintf( pAbc->Err, "usage: write_sorter_cnf [-N <num>] [-Q <num>] <file>\n" );
fprintf( pAbc->Err, "\t write CNF for the sorter\n" );
fprintf( pAbc->Err, "\t-N num : the number of sorter bits [default = %d]\n", nVars );
fprintf( pAbc->Err, "\t-Q num : the number of bits to be asserted to 1 [default = %d]\n", nQueens );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -61,8 +61,8 @@ struct Abc_Frame_t_ ...@@ -61,8 +61,8 @@ struct Abc_Frame_t_
FILE * Err; FILE * Err;
FILE * Hst; FILE * Hst;
// used for runtime measurement // used for runtime measurement
PORT_INT64_T TimeCommand; // the runtime of the last command double TimeCommand; // the runtime of the last command
PORT_INT64_T TimeTotal; // the total runtime of all commands double TimeTotal; // the total runtime of all commands
// temporary storage for structural choices // temporary storage for structural choices
Vec_Ptr_t * vStore; // networks to be used by choice Vec_Ptr_t * vStore; // networks to be used by choice
// decomposition package // decomposition package
......
...@@ -607,6 +607,7 @@ extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux ...@@ -607,6 +607,7 @@ extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux
extern long Extra_CpuTime(); extern long Extra_CpuTime();
extern double Extra_CpuTimeDouble();
extern int Extra_GetSoftDataLimit(); extern int Extra_GetSoftDataLimit();
extern void Extra_UtilGetoptReset(); extern void Extra_UtilGetoptReset();
extern int Extra_UtilGetopt( int argc, char *argv[], char *optstring ); extern int Extra_UtilGetopt( int argc, char *argv[], char *optstring );
......
...@@ -344,20 +344,36 @@ void (*Extra_UtilMMoutOfMemory)() = Extra_UtilMMout_Of_Memory; ...@@ -344,20 +344,36 @@ void (*Extra_UtilMMoutOfMemory)() = Extra_UtilMMout_Of_Memory;
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
#if defined(NT) || defined(NT64) || defined(WIN32)
long Extra_CpuTime() long Extra_CpuTime()
{ {
return clock(); return clock();
} }
/**Function*************************************************************
Synopsis [util_cpu_time()]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
#if defined(NT) || defined(NT64) || defined(WIN32)
double Extra_CpuTimeDouble()
{
return (double)clock()/CLOCKS_PER_SEC;
}
#else #else
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <unistd.h> #include <unistd.h>
long Extra_CpuTime() double Extra_CpuTimeDouble()
{ {
struct rusage ru; struct rusage ru;
getrusage(RUSAGE_SELF, &ru); getrusage(RUSAGE_SELF, &ru);
return (long)(CLOCKS_PER_SEC * ((double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000)); return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000;
} }
#endif #endif
......
...@@ -135,6 +135,12 @@ extern Inta_Man_t * Inta_ManAlloc(); ...@@ -135,6 +135,12 @@ extern Inta_Man_t * Inta_ManAlloc();
extern void Inta_ManFree( Inta_Man_t * p ); extern void Inta_ManFree( Inta_Man_t * p );
extern void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose ); extern void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose );
/*=== satInterP.c ==========================================================*/
typedef struct Intp_Man_t_ Intp_Man_t;
extern Intp_Man_t * Intp_ManAlloc();
extern void Intp_ManFree( Intp_Man_t * p );
extern void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fVerbose );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
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