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
12b70d49
Commit
12b70d49
authored
Oct 17, 2011
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to CNF generation code.
parent
6f0b87dd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
18 deletions
+67
-18
abclib.dsp
+4
-0
src/aig/aig/aig.h
+16
-7
src/aig/cnf/cnf.h
+2
-0
src/aig/cnf/cnfFast.c
+0
-0
src/aig/cnf/module.make
+1
-0
src/base/abci/abcDar.c
+18
-5
src/base/io/io.c
+26
-6
No files found.
abclib.dsp
View file @
12b70d49
...
@@ -2971,6 +2971,10 @@ SOURCE=.\src\aig\cnf\cnfData.c
...
@@ -2971,6 +2971,10 @@ SOURCE=.\src\aig\cnf\cnfData.c
# End Source File
# End Source File
# Begin Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfFast.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfMan.c
SOURCE=.\src\aig\cnf\cnfMan.c
# End Source File
# End Source File
# Begin Source File
# Begin Source File
...
...
src/aig/aig/aig.h
View file @
12b70d49
...
@@ -410,24 +410,33 @@ static inline void Aig_ManRecycleMemory( Aig_Man_t * p, Aig_Obj_t * pEntry )
...
@@ -410,24 +410,33 @@ static inline void Aig_ManRecycleMemory( Aig_Man_t * p, Aig_Obj_t * pEntry )
// iterator over the primary inputs
// iterator over the primary inputs
#define Aig_ManForEachPi( p, pObj, i ) \
#define Aig_ManForEachPi( p, pObj, i ) \
Vec_PtrForEachEntry( Aig_Obj_t *, p->vPis, pObj, i )
Vec_PtrForEachEntry( Aig_Obj_t *, p->vPis, pObj, i )
#define Aig_ManForEachPiReverse( p, pObj, i ) \
Vec_PtrForEachEntryReverse( Aig_Obj_t *, p->vPis, pObj, i )
// iterator over the primary outputs
// iterator over the primary outputs
#define Aig_ManForEachPo( p, pObj, i ) \
#define Aig_ManForEachPo( p, pObj, i ) \
Vec_PtrForEachEntry( Aig_Obj_t *, p->vPos, pObj, i )
Vec_PtrForEachEntry( Aig_Obj_t *, p->vPos, pObj, i )
// iterator over the assertions
#define Aig_ManForEachPoReverse( p, pObj, i ) \
#define Aig_ManForEachAssert( p, pObj, i ) \
Vec_PtrForEachEntryReverse( Aig_Obj_t *, p->vPos, pObj, i )
Vec_PtrForEachEntryStart( Aig_Obj_t *, p->vPos, pObj, i, Aig_ManPoNum(p)-p->nAsserts )
// iterators over all objects, including those currently not used
// iterator over all objects, including those currently not used
#define Aig_ManForEachObj( p, pObj, i ) \
#define Aig_ManForEachObj( p, pObj, i ) \
Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterator over the objects whose IDs are stored in an array
#define Aig_ManForEachObjReverse( p, pObj, i ) \
#define Aig_ManForEachObjVec( vIds, p, pObj, i ) \
Vec_PtrForEachEntryReverse( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterators over the objects whose IDs are stored in an array
#define Aig_ManForEachObjVec( vIds, p, pObj, i ) \
for ( i = 0; i < Vec_IntSize(vIds) && (((pObj) = Aig_ManObj(p, Vec_IntEntry(vIds,i))), 1); i++ )
for ( i = 0; i < Vec_IntSize(vIds) && (((pObj) = Aig_ManObj(p, Vec_IntEntry(vIds,i))), 1); i++ )
// iterator over all nodes
#define Aig_ManForEachObjVecReverse( vIds, p, pObj, i ) \
for ( i = Vec_IntSize(vIds) - 1; i >= 0 && (((pObj) = Aig_ManObj(p, Vec_IntEntry(vIds,i))), 1); i-- )
// iterators over all nodes
#define Aig_ManForEachNode( p, pObj, i ) \
#define Aig_ManForEachNode( p, pObj, i ) \
Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsNode(pObj) ) {} else
Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsNode(pObj) ) {} else
#define Aig_ManForEachNodeReverse( p, pObj, i ) \
Vec_PtrForEachEntryReverse( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsNode(pObj) ) {} else
// iterator over all nodes
// iterator over all nodes
#define Aig_ManForEachExor( p, pObj, i ) \
#define Aig_ManForEachExor( p, pObj, i ) \
Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsExor(pObj) ) {} else
Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsExor(pObj) ) {} else
#define Aig_ManForEachExorReverse( p, pObj, i ) \
Vec_PtrForEachEntryReverse( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsExor(pObj) ) {} else
// these two procedures are only here for the use inside the iterator
// these two procedures are only here for the use inside the iterator
static
inline
int
Aig_ObjFanout0Int
(
Aig_Man_t
*
p
,
int
ObjId
)
{
assert
(
ObjId
<
p
->
nFansAlloc
);
return
p
->
pFanData
[
5
*
ObjId
];
}
static
inline
int
Aig_ObjFanout0Int
(
Aig_Man_t
*
p
,
int
ObjId
)
{
assert
(
ObjId
<
p
->
nFansAlloc
);
return
p
->
pFanData
[
5
*
ObjId
];
}
...
...
src/aig/cnf/cnf.h
View file @
12b70d49
...
@@ -138,6 +138,8 @@ extern void Cnf_CutUpdateRefs( Cnf_Man_t * p, Cnf_Cut_t * pCut, Cnf_C
...
@@ -138,6 +138,8 @@ extern void Cnf_CutUpdateRefs( Cnf_Man_t * p, Cnf_Cut_t * pCut, Cnf_C
extern
Cnf_Cut_t
*
Cnf_CutCompose
(
Cnf_Man_t
*
p
,
Cnf_Cut_t
*
pCut
,
Cnf_Cut_t
*
pCutFan
,
int
iFan
);
extern
Cnf_Cut_t
*
Cnf_CutCompose
(
Cnf_Man_t
*
p
,
Cnf_Cut_t
*
pCut
,
Cnf_Cut_t
*
pCutFan
,
int
iFan
);
/*=== cnfData.c ========================================================*/
/*=== cnfData.c ========================================================*/
extern
void
Cnf_ReadMsops
(
char
**
ppSopSizes
,
char
***
ppSops
);
extern
void
Cnf_ReadMsops
(
char
**
ppSopSizes
,
char
***
ppSops
);
/*=== cnfData.c ========================================================*/
extern
Cnf_Dat_t
*
Cnf_DeriveFast
(
Aig_Man_t
*
p
,
int
nOutputs
);
/*=== cnfMan.c ========================================================*/
/*=== cnfMan.c ========================================================*/
extern
Cnf_Man_t
*
Cnf_ManStart
();
extern
Cnf_Man_t
*
Cnf_ManStart
();
extern
void
Cnf_ManStop
(
Cnf_Man_t
*
p
);
extern
void
Cnf_ManStop
(
Cnf_Man_t
*
p
);
...
...
src/aig/cnf/cnfFast.c
0 → 100644
View file @
12b70d49
This diff is collapsed.
Click to expand it.
src/aig/cnf/module.make
View file @
12b70d49
SRC
+=
src/aig/cnf/cnfCore.c
\
SRC
+=
src/aig/cnf/cnfCore.c
\
src/aig/cnf/cnfCut.c
\
src/aig/cnf/cnfCut.c
\
src/aig/cnf/cnfData.c
\
src/aig/cnf/cnfData.c
\
src/aig/cnf/cnfFast.c
\
src/aig/cnf/cnfMan.c
\
src/aig/cnf/cnfMan.c
\
src/aig/cnf/cnfMap.c
\
src/aig/cnf/cnfMap.c
\
src/aig/cnf/cnfPost.c
\
src/aig/cnf/cnfPost.c
\
...
...
src/base/abci/abcDar.c
View file @
12b70d49
...
@@ -1172,13 +1172,14 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
...
@@ -1172,13 +1172,14 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
Abc_Ntk_t
*
Abc_NtkDarToCnf
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
)
Abc_Ntk_t
*
Abc_NtkDarToCnf
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
,
int
fFastAlgo
,
int
fChangePol
,
int
fVerbose
)
{
{
Vec_Ptr_t
*
vMapped
=
NULL
;
Vec_Ptr_t
*
vMapped
=
NULL
;
Aig_Man_t
*
pMan
;
Aig_Man_t
*
pMan
;
Cnf_Man_t
*
pManCnf
=
NULL
;
Cnf_Man_t
*
pManCnf
=
NULL
;
Cnf_Dat_t
*
pCnf
;
Cnf_Dat_t
*
pCnf
;
Abc_Ntk_t
*
pNtkNew
=
NULL
;
Abc_Ntk_t
*
pNtkNew
=
NULL
;
int
clk
=
clock
();
assert
(
Abc_NtkIsStrash
(
pNtk
)
);
assert
(
Abc_NtkIsStrash
(
pNtk
)
);
// convert to the AIG manager
// convert to the AIG manager
...
@@ -1192,12 +1193,25 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName )
...
@@ -1192,12 +1193,25 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName )
return
NULL
;
return
NULL
;
}
}
// perform balance
// perform balance
if
(
fVerbose
)
Aig_ManPrintStats
(
pMan
);
Aig_ManPrintStats
(
pMan
);
// derive CNF
// derive CNF
pCnf
=
Cnf_Derive
(
pMan
,
0
);
if
(
fFastAlgo
)
Cnf_DataTranformPolarity
(
pCnf
,
0
);
pCnf
=
Cnf_DeriveFast
(
pMan
,
0
);
printf
(
"Vars = %6d. Clauses = %7d. Literals = %8d.
\n
"
,
pCnf
->
nVars
,
pCnf
->
nClauses
,
pCnf
->
nLiterals
);
else
pCnf
=
Cnf_Derive
(
pMan
,
0
);
// adjust polarity
if
(
fChangePol
)
Cnf_DataTranformPolarity
(
pCnf
,
0
);
// print stats
if
(
fVerbose
)
{
printf
(
"Vars = %6d. Clauses = %7d. Literals = %8d. "
,
pCnf
->
nVars
,
pCnf
->
nClauses
,
pCnf
->
nLiterals
);
Abc_PrintTime
(
1
,
"Time"
,
clock
()
-
clk
);
}
/*
/*
// write the network for verification
// write the network for verification
...
@@ -1210,7 +1224,6 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName )
...
@@ -1210,7 +1224,6 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName )
Cnf_DataWriteIntoFile
(
pCnf
,
pFileName
,
0
);
Cnf_DataWriteIntoFile
(
pCnf
,
pFileName
,
0
);
Cnf_DataFree
(
pCnf
);
Cnf_DataFree
(
pCnf
);
Cnf_ClearMemory
();
Cnf_ClearMemory
();
Aig_ManStop
(
pMan
);
Aig_ManStop
(
pMan
);
return
pNtkNew
;
return
pNtkNew
;
}
}
...
...
src/base/io/io.c
View file @
12b70d49
...
@@ -1865,23 +1865,38 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
...
@@ -1865,23 +1865,38 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
{
{
char
*
pFileName
;
char
*
pFileName
;
int
c
;
int
c
;
int
fAllPrimes
;
int
fNewAlgo
;
int
fNewAlgo
;
extern
Abc_Ntk_t
*
Abc_NtkDarToCnf
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
);
int
fFastAlgo
;
int
fAllPrimes
;
int
fChangePol
;
int
fVerbose
;
extern
Abc_Ntk_t
*
Abc_NtkDarToCnf
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
,
int
fFastAlgo
,
int
fChangePol
,
int
fVerbose
);
fNewAlgo
=
1
;
fNewAlgo
=
1
;
fFastAlgo
=
0
;
fAllPrimes
=
0
;
fAllPrimes
=
0
;
fChangePol
=
1
;
fVerbose
=
0
;
Extra_UtilGetoptReset
();
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"n
p
h"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"n
fpcv
h"
)
)
!=
EOF
)
{
{
switch
(
c
)
switch
(
c
)
{
{
case
'n'
:
case
'n'
:
fNewAlgo
^=
1
;
fNewAlgo
^=
1
;
break
;
break
;
case
'f'
:
fFastAlgo
^=
1
;
break
;
case
'p'
:
case
'p'
:
fAllPrimes
^=
1
;
fAllPrimes
^=
1
;
break
;
break
;
case
'c'
:
fChangePol
^=
1
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
case
'h'
:
goto
usage
;
goto
usage
;
default:
default:
...
@@ -1904,8 +1919,10 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
...
@@ -1904,8 +1919,10 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
printf
(
"Warning: Selected option to write all primes has no effect when deriving CNF from AIG.
\n
"
);
printf
(
"Warning: Selected option to write all primes has no effect when deriving CNF from AIG.
\n
"
);
}
}
// call the corresponding file writer
// call the corresponding file writer
if
(
fNewAlgo
)
if
(
fFastAlgo
)
Abc_NtkDarToCnf
(
pAbc
->
pNtkCur
,
pFileName
);
Abc_NtkDarToCnf
(
pAbc
->
pNtkCur
,
pFileName
,
1
,
fChangePol
,
fVerbose
);
else
if
(
fNewAlgo
)
Abc_NtkDarToCnf
(
pAbc
->
pNtkCur
,
pFileName
,
0
,
fChangePol
,
fVerbose
);
else
if
(
fAllPrimes
)
else
if
(
fAllPrimes
)
Io_WriteCnf
(
pAbc
->
pNtkCur
,
pFileName
,
1
);
Io_WriteCnf
(
pAbc
->
pNtkCur
,
pFileName
,
1
);
else
else
...
@@ -1913,10 +1930,13 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
...
@@ -1913,10 +1930,13 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
return
0
;
return
0
;
usage:
usage:
fprintf
(
pAbc
->
Err
,
"usage: write_cnf [-n
p
h] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"usage: write_cnf [-n
fpcv
h] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
writes the miter cone into a CNF file
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
writes the miter cone into a CNF file
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-n : toggle using new algorithm [default = %s]
\n
"
,
fNewAlgo
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-n : toggle using new algorithm [default = %s]
\n
"
,
fNewAlgo
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-f : toggle using fast algorithm [default = %s]
\n
"
,
fFastAlgo
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-p : toggle using all primes to enhance implicativity [default = %s]
\n
"
,
fAllPrimes
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-p : toggle using all primes to enhance implicativity [default = %s]
\n
"
,
fAllPrimes
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-c : toggle adjasting polarity of internal variables [default = %s]
\n
"
,
fChangePol
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-v : toggle printing verbose information [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : print the help massage
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : print the help massage
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : the name of the file to write
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : the name of the file to write
\n
"
);
return
1
;
return
1
;
...
...
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