Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
8eeecc51
Commit
8eeecc51
authored
Mar 07, 2008
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version abc80307
parent
8bd19a27
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
301 additions
and
57 deletions
+301
-57
Makefile
+1
-1
abc.dsp
+4
-0
readme
+7
-0
src/aig/aig/aigInter.c
+11
-1
src/aig/kit/cloud.c
+30
-30
src/aig/kit/cloud.h
+8
-10
src/base/abci/abcDar.c
+6
-1
src/base/abci/abcDelay.c
+2
-2
src/base/abci/abcGen.c
+1
-1
src/base/abci/abcSat.c
+125
-0
src/base/cmd/cmd.c
+3
-3
src/base/cmd/cmdUtils.c
+3
-3
src/base/io/io.c
+72
-0
src/base/main/mainInt.h
+2
-2
src/misc/extra/extra.h
+1
-0
src/misc/extra/extraUtilUtil.c
+19
-3
src/sat/bsat/satInterP.c
+0
-0
src/sat/bsat/satStore.h
+6
-0
No files found.
Makefile
View file @
8eeecc51
...
...
@@ -24,7 +24,7 @@ MODULES := src/base/abc src/base/abci src/base/cmd \
default
:
$(PROG)
#OPTFLAGS := -DNDEBUG -O3
OPTFLAGS
:=
-g
-O
OPTFLAGS
:=
-g
-O
-DLIN64
CFLAGS
+=
-Wall
-Wno-unused-function
$(OPTFLAGS)
$
(
patsubst %,
-I
%,
$(MODULES)
)
CXXFLAGS
+=
$(CFLAGS)
...
...
abc.dsp
View file @
8eeecc51
...
...
@@ -1178,6 +1178,10 @@ SOURCE=.\src\sat\bsat\satInterA.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satInterP.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satMem.c
# End Source File
# Begin Source File
...
...
readme
View file @
8eeecc51
...
...
@@ -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
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:
abc>>> so regtest.script
src/aig/aig/aigInter.c
View file @
8eeecc51
...
...
@@ -162,7 +162,17 @@ clk = clock();
pRes
=
Inta_ManInterpolate
(
pManInter
,
pSatCnf
,
vVarsAB
,
fVerbose
);
Inta_ManFree
(
pManInter
);
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
);
Sto_ManFree
(
pSatCnf
);
return
pRes
;
...
...
src/aig/kit/cloud.c
View file @
8eeecc51
...
...
@@ -105,8 +105,8 @@ clk2 = clock();
dd
->
nSignCur
=
1
;
dd
->
tUnique
[
0
].
s
=
dd
->
nSignCur
;
dd
->
tUnique
[
0
].
v
=
CLOUD_CONST_INDEX
;
dd
->
tUnique
[
0
].
e
=
CLOUD_VOID
;
dd
->
tUnique
[
0
].
t
=
CLOUD_VOID
;
dd
->
tUnique
[
0
].
e
=
NULL
;
dd
->
tUnique
[
0
].
t
=
NULL
;
dd
->
one
=
dd
->
tUnique
;
dd
->
zero
=
Cloud_Not
(
dd
->
one
);
dd
->
nNodesCur
=
1
;
...
...
@@ -256,7 +256,7 @@ CloudNode * Cloud_MakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudN
if
(
Cloud_IsComplement
(
t
)
)
{
pRes
=
cloudMakeNode
(
dd
,
v
,
Cloud_Not
(
t
),
Cloud_Not
(
e
)
);
if
(
pRes
!=
CLOUD_VOID
)
if
(
pRes
!=
NULL
)
pRes
=
Cloud_Not
(
pRes
);
}
else
...
...
@@ -314,7 +314,7 @@ CloudNode * cloudMakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNo
printf
(
"Cloud needs restart!
\n
"
);
// fflush( stdout );
// exit(1);
return
CLOUD_VOID
;
return
NULL
;
}
// create the node
entryUnique
->
s
=
dd
->
nSignCur
;
...
...
@@ -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] + cloudHashBuddy2(f, g, dd->shiftCache[CLOUD_OPER_AND]);
r
=
cloudCacheLookup2
(
cacheEntry
,
dd
->
nSignCur
,
f
,
g
);
if
(
r
!=
CLOUD_VOID
)
if
(
r
!=
NULL
)
{
dd
->
nCacheHits
++
;
return
r
;
...
...
@@ -419,16 +419,16 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
else
t
=
cloudBddAnd
(
dd
,
gv
,
fv
);
if
(
t
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
t
==
NULL
)
return
NULL
;
if
(
fnv
<=
gnv
)
e
=
cloudBddAnd
(
dd
,
fnv
,
gnv
);
else
e
=
cloudBddAnd
(
dd
,
gnv
,
fnv
);
if
(
e
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
e
==
NULL
)
return
NULL
;
if
(
t
==
e
)
r
=
t
;
...
...
@@ -437,15 +437,15 @@ CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
if
(
Cloud_IsComplement
(
t
)
)
{
r
=
cloudMakeNode
(
dd
,
var
,
Cloud_Not
(
t
),
Cloud_Not
(
e
)
);
if
(
r
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
r
==
NULL
)
return
NULL
;
r
=
Cloud_Not
(
r
);
}
else
{
r
=
cloudMakeNode
(
dd
,
var
,
t
,
e
);
if
(
r
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
r
==
NULL
)
return
NULL
;
}
}
cloudCacheInsert2
(
cacheEntry
,
dd
->
nSignCur
,
f
,
g
,
r
);
...
...
@@ -484,8 +484,8 @@ static inline CloudNode * cloudBddAnd_gate( CloudManager * dd, CloudNode * f, Cl
******************************************************************************/
CloudNode
*
Cloud_bddAnd
(
CloudManager
*
dd
,
CloudNode
*
f
,
CloudNode
*
g
)
{
if
(
Cloud_Regular
(
f
)
==
CLOUD_VOID
||
Cloud_Regular
(
g
)
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
Cloud_Regular
(
f
)
==
NULL
||
Cloud_Regular
(
g
)
==
NULL
)
return
NULL
;
CLOUD_ASSERT
(
f
);
CLOUD_ASSERT
(
g
);
if
(
dd
->
tCaches
[
CLOUD_OPER_AND
]
==
NULL
)
...
...
@@ -507,14 +507,14 @@ CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
CloudNode
*
Cloud_bddOr
(
CloudManager
*
dd
,
CloudNode
*
f
,
CloudNode
*
g
)
{
CloudNode
*
res
;
if
(
Cloud_Regular
(
f
)
==
CLOUD_VOID
||
Cloud_Regular
(
g
)
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
Cloud_Regular
(
f
)
==
NULL
||
Cloud_Regular
(
g
)
==
NULL
)
return
NULL
;
CLOUD_ASSERT
(
f
);
CLOUD_ASSERT
(
g
);
if
(
dd
->
tCaches
[
CLOUD_OPER_AND
]
==
NULL
)
cloudCacheAllocate
(
dd
,
CLOUD_OPER_AND
);
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
;
}
...
...
@@ -532,18 +532,18 @@ CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g )
CloudNode
*
Cloud_bddXor
(
CloudManager
*
dd
,
CloudNode
*
f
,
CloudNode
*
g
)
{
CloudNode
*
t0
,
*
t1
,
*
r
;
if
(
Cloud_Regular
(
f
)
==
CLOUD_VOID
||
Cloud_Regular
(
g
)
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
Cloud_Regular
(
f
)
==
NULL
||
Cloud_Regular
(
g
)
==
NULL
)
return
NULL
;
CLOUD_ASSERT
(
f
);
CLOUD_ASSERT
(
g
);
if
(
dd
->
tCaches
[
CLOUD_OPER_AND
]
==
NULL
)
cloudCacheAllocate
(
dd
,
CLOUD_OPER_AND
);
t0
=
cloudBddAnd_gate
(
dd
,
f
,
Cloud_Not
(
g
)
);
if
(
t0
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
t0
==
NULL
)
return
NULL
;
t1
=
cloudBddAnd_gate
(
dd
,
Cloud_Not
(
f
),
g
);
if
(
t1
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
t1
==
NULL
)
return
NULL
;
r
=
Cloud_bddOr
(
dd
,
t0
,
t1
);
return
r
;
}
...
...
@@ -631,7 +631,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n )
if
(
support
[
i
]
==
1
)
{
res
=
Cloud_bddAnd
(
dd
,
res
,
dd
->
vars
[
i
]
);
if
(
res
==
CLOUD_VOID
)
if
(
res
==
NULL
)
break
;
}
FREE
(
support
);
...
...
@@ -831,8 +831,8 @@ CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc )
// try to find the cube with the negative literal
res
=
Cloud_GetOneCube
(
dd
,
bFunc0
);
if
(
res
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
res
==
NULL
)
return
NULL
;
if
(
res
!=
dd
->
zero
)
{
...
...
@@ -842,8 +842,8 @@ CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc )
{
// try to find the cube with the positive literal
res
=
Cloud_GetOneCube
(
dd
,
bFunc1
);
if
(
res
==
CLOUD_VOID
)
return
CLOUD_VOID
;
if
(
res
==
NULL
)
return
NULL
;
assert
(
res
!=
dd
->
zero
);
res
=
Cloud_bddAnd
(
dd
,
res
,
dd
->
vars
[
Cloud_V
(
bFunc
)]
);
}
...
...
@@ -873,7 +873,7 @@ void Cloud_bddPrint( CloudManager * dd, CloudNode * Func )
while
(
1
)
{
Cube
=
Cloud_GetOneCube
(
dd
,
Func
);
if
(
Cube
==
CLOUD_VOID
||
Cube
==
dd
->
zero
)
if
(
Cube
==
NULL
||
Cube
==
dd
->
zero
)
break
;
if
(
fFirst
)
fFirst
=
0
;
else
printf
(
" + "
);
...
...
src/aig/kit/cloud.h
View file @
8eeecc51
...
...
@@ -27,6 +27,7 @@ extern "C" {
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include "port_type.h"
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
...
...
@@ -162,9 +163,6 @@ struct cloudCacheEntry3 // the three-argument cache
// parameters
#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_MARK_ON ((unsigned)0x10000000)
...
...
@@ -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))
// node complementation (using node)
#define Cloud_Regular(p) ((CloudNode*)(((
unsigned)(p)) & CLOUD_NOT_ONE))
// get the regular node (w/o bubble)
#define Cloud_Not(p) ((CloudNode*)(((
unsigned)(p)) ^ CLOUD_ONE))
// complement the node
#define Cloud_NotCond(p,c) ((
(int)(c))? Cloud_Not(p):(p))
// complement the node conditionally
#define Cloud_IsComplement(p) ((int)(((
unsigned)(p)) & CLOUD_ONE))
// check if complemented
#define Cloud_Regular(p) ((CloudNode*)(((
PORT_PTRUINT_T)(p)) & ~01))
// get the regular node (w/o bubble)
#define Cloud_Not(p) ((CloudNode*)(((
PORT_PTRUINT_T)(p)) ^ 01))
// complement the node
#define Cloud_NotCond(p,c) ((
CloudNode*)(((PORT_PTRUINT_T)(p)) ^ (c)))
// complement the node conditionally
#define Cloud_IsComplement(p) ((int)(((
PORT_PTRUINT_T)(p)) & 01))
// check if complemented
// checking constants (using node)
#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)
...
...
@@ -204,9 +202,9 @@ struct cloudCacheEntry3 // the three-argument cache
#define cloudNodeIsMarked(p) ((int)((p)->v & CLOUD_MARK_ON))
// cache lookups and inserts (using node)
#define cloudCacheLookup1(p,sign,f) (((p)->s == (sign) && (p)->a == (f))? ((p)->r): (
CLOUD_VOID
))
#define cloudCacheLookup2(p,sign,f,g) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g))? ((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): (
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): (
0
))
#define cloudCacheLookup3(p,sign,f,g,h) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g) && (p)->c == (h))? ((p)->r): (
0
))
// cache inserts
#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)))
...
...
src/base/abci/abcDar.c
View file @
8eeecc51
...
...
@@ -266,6 +266,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
Abc_NtkAddDummyBoxNames
(
pNtkNew
);
else
{
/*
{
int i, k, iFlop, Counter = 0;
FILE * pFile;
...
...
@@ -285,6 +286,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
fclose( pFile );
//printf( "\n" );
}
*/
assert
(
Abc_NtkBoxNum
(
pNtkOld
)
==
Abc_NtkLatchNum
(
pNtkOld
)
);
nDigits
=
Extra_Base10Log
(
Abc_NtkLatchNum
(
pNtkNew
)
);
Abc_NtkForEachLatch
(
pNtkNew
,
pObjNew
,
i
)
...
...
@@ -1622,11 +1624,14 @@ timeInt = 0;
}
else
pNtkInter1
=
Abc_NtkInterOne
(
pNtkOn1
,
pNtkOff1
,
fVerbose
);
if
(
pNtkInter1
)
{
Abc_NtkAppend
(
pNtkInter
,
pNtkInter1
,
1
);
Abc_NtkDelete
(
pNtkInter1
);
}
Abc_NtkDelete
(
pNtkOn1
);
Abc_NtkDelete
(
pNtkOff1
);
Abc_NtkDelete
(
pNtkInter1
);
}
// PRT( "CNF", timeCnf );
// PRT( "SAT", timeSat );
...
...
src/base/abci/abcDelay.c
View file @
8eeecc51
...
...
@@ -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_ObjSetSlack
(
Abc_Obj_t
*
pNode
,
float
Time
)
{
pNode
->
pNtk
->
pLutTimes
[
3
*
pNode
->
Id
+
2
]
=
Time
;
}
extern
void
*
Abc_FrameReadLibLut
();
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
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
***********************************************************************/
float
Abc_NtkDelayTraceLut
(
Abc_Ntk_t
*
pNtk
,
int
fUseLutLib
)
{
extern
void
*
Abc_FrameReadLibLut
();
int
fUseSorting
=
0
;
int
pPinPerm
[
32
];
float
pPinDelays
[
32
];
...
...
src/base/abci/abcGen.c
View file @
8eeecc51
...
...
@@ -131,7 +131,7 @@ void Abc_GenSorter( char * pFileName, int nVars )
fprintf
(
pFile
,
" y%02d=%0*d"
,
k
,
nDigits
,
Counter
++
);
fprintf
(
pFile
,
"
\n
"
);
Counter
-=
nVars
;
for
(
i
=
1
;
i
<
nVars
-
2
;
i
++
)
for
(
i
=
1
;
i
<
2
*
nVars
-
2
;
i
++
)
{
fprintf
(
pFile
,
".subckt Layer%d"
,
(
i
&
1
)
);
for
(
k
=
0
;
k
<
nVars
;
k
++
)
...
...
src/base/abci/abcSat.c
View file @
8eeecc51
...
...
@@ -591,6 +591,16 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk )
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
;
Quits
:
// delete
...
...
@@ -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 ///
...
...
src/base/cmd/cmd.c
View file @
8eeecc51
...
...
@@ -169,16 +169,16 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
pAbc
->
TimeTotal
+=
pAbc
->
TimeCommand
;
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;
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 );
}
*/
pAbc
->
TimeCommand
=
0
;
pAbc
->
TimeCommand
=
0
.
0
;
return
0
;
usage:
...
...
src/base/cmd/cmdUtils.c
View file @
8eeecc51
...
...
@@ -92,7 +92,7 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Command
*
pCommand
;
char
*
value
;
int
fError
;
int
clk
;
double
clk
;
if
(
argc
==
0
)
return
0
;
...
...
@@ -121,10 +121,10 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv )
}
// execute the command
clk
=
Extra_CpuTime
();
clk
=
Extra_CpuTime
Double
();
pFunc
=
(
int
(
*
)(
Abc_Frame_t
*
,
int
,
char
**
))
pCommand
->
pFunc
;
fError
=
(
*
pFunc
)(
pAbc
,
argc
,
argv
);
pAbc
->
TimeCommand
+=
(
Extra_CpuTime
()
-
clk
)
;
pAbc
->
TimeCommand
+=
Extra_CpuTimeDouble
()
-
clk
;
// automatic execution of arbitrary command after each command
// usually this is a passive command ...
...
...
src/base/io/io.c
View file @
8eeecc51
...
...
@@ -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
IoCommandWriteVerilog
(
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
;
...
...
@@ -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_verilog"
,
IoCommandWriteVerilog
,
0
);
// Cmd_CommandAdd( pAbc, "I/O", "write_verlib", IoCommandWriteVerLib, 0 );
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write_sorter_cnf"
,
IoCommandWriteSortCnf
,
0
);
}
/**Function*************************************************************
...
...
@@ -2010,6 +2012,76 @@ usage:
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
,
"
\t
file : the name of the file to write
\n
"
);
return
1
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/base/main/mainInt.h
View file @
8eeecc51
...
...
@@ -61,8 +61,8 @@ struct Abc_Frame_t_
FILE
*
Err
;
FILE
*
Hst
;
// used for runtime measurement
PORT_INT64_T
TimeCommand
;
// the runtime of the last command
PORT_INT64_T
TimeTotal
;
// the total runtime of all commands
double
TimeCommand
;
// the runtime of the last command
double
TimeTotal
;
// the total runtime of all commands
// temporary storage for structural choices
Vec_Ptr_t
*
vStore
;
// networks to be used by choice
// decomposition package
...
...
src/misc/extra/extra.h
View file @
8eeecc51
...
...
@@ -607,6 +607,7 @@ extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux
extern
long
Extra_CpuTime
();
extern
double
Extra_CpuTimeDouble
();
extern
int
Extra_GetSoftDataLimit
();
extern
void
Extra_UtilGetoptReset
();
extern
int
Extra_UtilGetopt
(
int
argc
,
char
*
argv
[],
char
*
optstring
);
...
...
src/misc/extra/extraUtilUtil.c
View file @
8eeecc51
...
...
@@ -344,20 +344,36 @@ void (*Extra_UtilMMoutOfMemory)() = Extra_UtilMMout_Of_Memory;
SeeAlso []
***********************************************************************/
#if defined(NT) || defined(NT64) || defined(WIN32)
long
Extra_CpuTime
()
{
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
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
long
Extra_CpuTim
e
()
double
Extra_CpuTimeDoubl
e
()
{
struct
rusage
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
...
...
src/sat/bsat/satInterP.c
0 → 100644
View file @
8eeecc51
This diff is collapsed.
Click to expand it.
src/sat/bsat/satStore.h
View file @
8eeecc51
...
...
@@ -135,6 +135,12 @@ extern Inta_Man_t * Inta_ManAlloc();
extern
void
Inta_ManFree
(
Inta_Man_t
*
p
);
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
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment