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
3c978925
Commit
3c978925
authored
May 30, 2013
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New MFS package.
parent
67127b83
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
197 additions
and
67 deletions
+197
-67
src/base/abci/abc.c
+6
-2
src/misc/vec/vecWec.h
+8
-0
src/opt/sfm/sfmCnf.c
+8
-5
src/opt/sfm/sfmCore.c
+4
-4
src/opt/sfm/sfmInt.h
+5
-4
src/opt/sfm/sfmNtk.c
+6
-2
src/opt/sfm/sfmSat.c
+52
-3
src/opt/sfm/sfmWin.c
+108
-47
No files found.
src/base/abci/abc.c
View file @
3c978925
...
...
@@ -4318,7 +4318,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults
Abc_NtkMfsParsDefault
(
pPars
);
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"WFDMLCdraestpgvwh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"WFDMLCd
l
raestpgvwh"
)
)
!=
EOF
)
{
switch
(
c
)
{
...
...
@@ -4391,6 +4391,9 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case
'd'
:
pPars
->
fRrOnly
^=
1
;
break
;
case
'l'
:
pPars
->
nGrowthLevel
=
10000
;
break
;
case
'r'
:
pPars
->
fResub
^=
1
;
break
;
...
...
@@ -4445,7 +4448,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: mfs [-WFDMLC <num>] [-draestpgvh]
\n
"
);
Abc_Print
(
-
2
,
"usage: mfs [-WFDMLC <num>] [-d
l
raestpgvh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
performs don't-care-based optimization of logic networks
\n
"
);
Abc_Print
(
-
2
,
"
\t
-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]
\n
"
,
pPars
->
nWinTfoLevs
);
Abc_Print
(
-
2
,
"
\t
-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]
\n
"
,
pPars
->
nFanoutsMax
);
...
...
@@ -4454,6 +4457,7 @@ usage:
Abc_Print
(
-
2
,
"
\t
-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]
\n
"
,
pPars
->
nGrowthLevel
);
Abc_Print
(
-
2
,
"
\t
-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]
\n
"
,
pPars
->
nBTLimit
);
Abc_Print
(
-
2
,
"
\t
-d : toggle performing redundancy removal [default = %s]
\n
"
,
pPars
->
fRrOnly
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-l : allow logic level to increase [default = %s]
\n
"
,
(
pPars
->
nGrowthLevel
>
0
)
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-r : toggle resubstitution and dc-minimization [default = %s]
\n
"
,
pPars
->
fResub
?
"resub"
:
"dc-min"
);
Abc_Print
(
-
2
,
"
\t
-a : toggle minimizing area or area+edges [default = %s]
\n
"
,
pPars
->
fArea
?
"area"
:
"area+edges"
);
Abc_Print
(
-
2
,
"
\t
-e : toggle high-effort resubstitution [default = %s]
\n
"
,
pPars
->
fMoreEffort
?
"yes"
:
"no"
);
src/misc/vec/vecWec.h
View file @
3c978925
...
...
@@ -215,6 +215,14 @@ static inline int Vec_WecSizeUsed( Vec_Wec_t * p )
Counter
+=
(
int
)(
Vec_IntSize
(
vVec
)
>
0
);
return
Counter
;
}
static
inline
int
Vec_WecSizeUsedLimits
(
Vec_Wec_t
*
p
,
int
iStart
,
int
iStop
)
{
Vec_Int_t
*
vVec
;
int
i
,
Counter
=
0
;
Vec_WecForEachLevelStartStop
(
p
,
vVec
,
i
,
iStart
,
iStop
)
Counter
+=
(
int
)(
Vec_IntSize
(
vVec
)
>
0
);
return
Counter
;
}
/**Function*************************************************************
...
...
src/opt/sfm/sfmCnf.c
View file @
3c978925
...
...
@@ -150,7 +150,7 @@ Vec_Wec_t * Sfm_CreateCnf( Sfm_Ntk_t * p )
SeeAlso []
***********************************************************************/
void
Sfm_TranslateCnf
(
Vec_Wec_t
*
vRes
,
Vec_Str_t
*
vCnf
,
Vec_Int_t
*
vFaninMap
)
void
Sfm_TranslateCnf
(
Vec_Wec_t
*
vRes
,
Vec_Str_t
*
vCnf
,
Vec_Int_t
*
vFaninMap
,
int
iPivotVar
)
{
Vec_Int_t
*
vClause
;
char
Entry
;
...
...
@@ -159,11 +159,14 @@ void Sfm_TranslateCnf( Vec_Wec_t * vRes, Vec_Str_t * vCnf, Vec_Int_t * vFaninMap
vClause
=
Vec_WecPushLevel
(
vRes
);
Vec_StrForEachEntry
(
vCnf
,
Entry
,
i
)
{
Lit
=
(
int
)
Entry
;
if
(
Lit
==
-
1
)
if
(
(
int
)
Entry
==
-
1
)
{
vClause
=
Vec_WecPushLevel
(
vRes
);
else
Vec_IntPush
(
vClause
,
Abc_Lit2LitV
(
Vec_IntArray
(
vFaninMap
),
Lit
)
);
continue
;
}
Lit
=
Abc_Lit2LitV
(
Vec_IntArray
(
vFaninMap
),
(
int
)
Entry
);
Lit
=
Abc_LitNotCond
(
Lit
,
Abc_Lit2Var
(
Lit
)
==
iPivotVar
);
Vec_IntPush
(
vClause
,
Lit
);
}
}
...
...
src/opt/sfm/sfmCore.c
View file @
3c978925
...
...
@@ -49,7 +49,7 @@ void Sfm_ParSetDefault( Sfm_Par_t * pPars )
pPars
->
nFanoutMax
=
30
;
// the maximum number of fanouts
pPars
->
nDepthMax
=
20
;
// the maximum depth to try
pPars
->
nWinSizeMax
=
300
;
// the maximum window size
pPars
->
nBTLimit
=
0
;
// the maximum number of conflicts in one SAT run
pPars
->
nBTLimit
=
500
0
;
// the maximum number of conflicts in one SAT run
pPars
->
fFixLevel
=
1
;
// does not allow level to increase
pPars
->
fRrOnly
=
0
;
// perform redundancy removal
pPars
->
fArea
=
0
;
// performs optimization for area
...
...
@@ -255,13 +255,13 @@ int Sfm_NtkPerform( Sfm_Ntk_t * p, Sfm_Par_t * pPars )
{
int
i
,
k
,
Counter
=
0
;
p
->
timeTotal
=
Abc_Clock
();
if
(
pPars
->
fVerbose
)
if
(
pPars
->
fVerbose
&&
Vec_StrSum
(
p
->
vFixed
)
>
0
)
printf
(
"Performing MFS with %d fixed objects.
\n
"
,
Vec_StrSum
(
p
->
vFixed
)
);
p
->
pPars
=
pPars
;
Sfm_NtkPrepare
(
p
);
// Sfm_ComputeInterpolantCheck( p );
// return 0;
p
->
nTotalNodesBeg
=
Vec_WecSize
(
&
p
->
vFanins
)
-
Sfm_NtkPiNum
(
p
)
-
Sfm_NtkPoNum
(
p
);
p
->
nTotalNodesBeg
=
Vec_WecSize
UsedLimits
(
&
p
->
vFanins
,
Sfm_NtkPiNum
(
p
),
Vec_WecSize
(
&
p
->
vFanins
)
-
Sfm_NtkPoNum
(
p
)
);
p
->
nTotalEdgesBeg
=
Vec_WecSizeSize
(
&
p
->
vFanins
)
-
Sfm_NtkPoNum
(
p
);
Sfm_NtkForEachNode
(
p
,
i
)
{
...
...
@@ -278,7 +278,7 @@ int Sfm_NtkPerform( Sfm_Ntk_t * p, Sfm_Par_t * pPars )
}
Counter
+=
(
k
>
0
);
}
p
->
nTotalNodesEnd
=
Vec_WecSizeUsed
(
&
p
->
vFanins
)
-
Sfm_NtkPoNum
(
p
);
p
->
nTotalNodesEnd
=
Vec_WecSizeUsed
Limits
(
&
p
->
vFanins
,
Sfm_NtkPiNum
(
p
),
Vec_WecSize
(
&
p
->
vFanins
)
-
Sfm_NtkPoNum
(
p
)
);
p
->
nTotalEdgesEnd
=
Vec_WecSizeSize
(
&
p
->
vFanins
)
-
Sfm_NtkPoNum
(
p
);
p
->
timeTotal
=
Abc_Clock
()
-
p
->
timeTotal
;
if
(
pPars
->
fVerbose
)
...
...
src/opt/sfm/sfmInt.h
View file @
3c978925
...
...
@@ -42,7 +42,6 @@
ABC_NAMESPACE_HEADER_START
#define SFM_FANIN_MAX 6
#define SFM_SAT_UNDEC 0x1234567812345678
#define SFM_SAT_SAT 0x8765432187654321
...
...
@@ -77,9 +76,11 @@ struct Sfm_Ntk_t_
int
nTravIds
;
// traversal IDs
int
nTravIds2
;
// traversal IDs
// window
int
i
Node
;
int
i
PivotNode
;
// window pivot
Vec_Int_t
*
vLeaves
;
// leaves
Vec_Int_t
*
vLeaves2
;
// leaves
Vec_Int_t
*
vNodes
;
// internal
Vec_Int_t
*
vNodes2
;
// internal
Vec_Int_t
*
vDivs
;
// divisors
Vec_Int_t
*
vRoots
;
// roots
Vec_Int_t
*
vTfo
;
// TFO (excluding iNode)
...
...
@@ -145,7 +146,7 @@ static inline int Sfm_ObjFanout( Sfm_Ntk_t * p, int i, int k ) { return
static
inline
int
Sfm_ObjSatVar
(
Sfm_Ntk_t
*
p
,
int
iObj
)
{
assert
(
Vec_IntEntry
(
&
p
->
vId2Var
,
iObj
)
>
0
);
return
Vec_IntEntry
(
&
p
->
vId2Var
,
iObj
);
}
static
inline
void
Sfm_ObjSetSatVar
(
Sfm_Ntk_t
*
p
,
int
iObj
,
int
Num
)
{
assert
(
Vec_IntEntry
(
&
p
->
vId2Var
,
iObj
)
==
-
1
);
Vec_IntWriteEntry
(
&
p
->
vId2Var
,
iObj
,
Num
);
Vec_IntWriteEntry
(
&
p
->
vVar2Id
,
Num
,
iObj
);
}
static
inline
void
Sfm_ObjCleanSatVar
(
Sfm_Ntk_t
*
p
,
int
Num
)
{
int
iObj
=
Vec_IntEntry
(
&
p
->
vVar2Id
,
Num
);
assert
(
Vec_IntEntry
(
&
p
->
vId2Var
,
iObj
)
>
0
);
Vec_IntWriteEntry
(
&
p
->
vId2Var
,
iObj
,
-
1
);
Vec_IntWriteEntry
(
&
p
->
vVar2Id
,
Num
,
-
1
);
}
static
inline
void
Sfm_NtkCleanVars
(
Sfm_Ntk_t
*
p
)
{
int
i
;
for
(
i
=
1
;
i
<
p
->
nSatVars
;
i
++
)
Sfm_ObjCleanSatVar
(
p
,
i
);
}
static
inline
void
Sfm_NtkCleanVars
(
Sfm_Ntk_t
*
p
)
{
int
i
;
for
(
i
=
1
;
i
<
p
->
nSatVars
;
i
++
)
if
(
Vec_IntEntry
(
&
p
->
vVar2Id
,
i
)
!=
-
1
)
Sfm_ObjCleanSatVar
(
p
,
i
);
}
static
inline
int
Sfm_ObjLevel
(
Sfm_Ntk_t
*
p
,
int
iObj
)
{
return
Vec_IntEntry
(
&
p
->
vLevels
,
iObj
);
}
static
inline
void
Sfm_ObjSetLevel
(
Sfm_Ntk_t
*
p
,
int
iObj
,
int
Lev
)
{
Vec_IntWriteEntry
(
&
p
->
vLevels
,
iObj
,
Lev
);
}
...
...
@@ -171,7 +172,7 @@ extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );
extern
void
Sfm_PrintCnf
(
Vec_Str_t
*
vCnf
);
extern
int
Sfm_TruthToCnf
(
word
Truth
,
int
nVars
,
Vec_Int_t
*
vCover
,
Vec_Str_t
*
vCnf
);
extern
Vec_Wec_t
*
Sfm_CreateCnf
(
Sfm_Ntk_t
*
p
);
extern
void
Sfm_TranslateCnf
(
Vec_Wec_t
*
vRes
,
Vec_Str_t
*
vCnf
,
Vec_Int_t
*
vFaninMap
);
extern
void
Sfm_TranslateCnf
(
Vec_Wec_t
*
vRes
,
Vec_Str_t
*
vCnf
,
Vec_Int_t
*
vFaninMap
,
int
iPivotVar
);
/*=== sfmCore.c ==========================================================*/
/*=== sfmNtk.c ==========================================================*/
extern
Sfm_Ntk_t
*
Sfm_ConstructNetwork
(
Vec_Wec_t
*
vFanins
,
int
nPis
,
int
nPos
);
...
...
src/opt/sfm/sfmNtk.c
View file @
3c978925
...
...
@@ -155,8 +155,8 @@ Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t
Vec_IntFill
(
&
p
->
vCounts
,
p
->
nObjs
,
0
);
Vec_IntFill
(
&
p
->
vTravIds
,
p
->
nObjs
,
0
);
Vec_IntFill
(
&
p
->
vTravIds2
,
p
->
nObjs
,
0
);
Vec_IntFill
(
&
p
->
vId2Var
,
p
->
nObjs
,
-
1
);
Vec_IntFill
(
&
p
->
vVar2Id
,
p
->
nObjs
,
-
1
);
Vec_IntFill
(
&
p
->
vId2Var
,
2
*
p
->
nObjs
,
-
1
);
Vec_IntFill
(
&
p
->
vVar2Id
,
2
*
p
->
nObjs
,
-
1
);
p
->
vCover
=
Vec_IntAlloc
(
1
<<
16
);
p
->
vCnfs
=
Sfm_CreateCnf
(
p
);
return
p
;
...
...
@@ -164,7 +164,9 @@ Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t
void
Sfm_NtkPrepare
(
Sfm_Ntk_t
*
p
)
{
p
->
vLeaves
=
Vec_IntAlloc
(
1000
);
p
->
vLeaves2
=
Vec_IntAlloc
(
1000
);
p
->
vNodes
=
Vec_IntAlloc
(
1000
);
p
->
vNodes2
=
Vec_IntAlloc
(
1000
);
p
->
vDivs
=
Vec_IntAlloc
(
100
);
p
->
vRoots
=
Vec_IntAlloc
(
1000
);
p
->
vTfo
=
Vec_IntAlloc
(
1000
);
...
...
@@ -197,7 +199,9 @@ void Sfm_NtkFree( Sfm_Ntk_t * p )
Vec_IntFree
(
p
->
vCover
);
// other data
Vec_IntFreeP
(
&
p
->
vLeaves
);
Vec_IntFreeP
(
&
p
->
vLeaves2
);
Vec_IntFreeP
(
&
p
->
vNodes
);
Vec_IntFreeP
(
&
p
->
vNodes2
);
Vec_IntFreeP
(
&
p
->
vDivs
);
Vec_IntFreeP
(
&
p
->
vRoots
);
Vec_IntFreeP
(
&
p
->
vTfo
);
...
...
src/opt/sfm/sfmSat.c
View file @
3c978925
...
...
@@ -53,13 +53,17 @@ static word s_Truths6[6] = {
***********************************************************************/
void
Sfm_NtkWindowToSolver
(
Sfm_Ntk_t
*
p
)
{
// p->vOrder contains all variables in the window in a good order
// p->vDivs is a subset of nodes in p->vOrder used as divisor candidates
// p->vTfo contains TFO of the node (does not include node)
// p->vRoots contains roots of the TFO of the node (may include node)
Vec_Int_t
*
vClause
;
int
RetValue
,
iNode
=
-
1
,
iFanin
,
i
,
k
;
abctime
clk
=
Abc_Clock
();
// if ( p->pSat )
// printf( "%d ", p->pSat->stats.learnts );
sat_solver_restart
(
p
->
pSat
);
sat_solver_setnvars
(
p
->
pSat
,
1
+
Vec_IntSize
(
p
->
v
Divs
)
+
2
*
Vec_IntSize
(
p
->
vTfo
)
+
Vec_IntSize
(
p
->
vRoots
)
+
5
0
);
sat_solver_setnvars
(
p
->
pSat
,
1
+
Vec_IntSize
(
p
->
v
Order
)
+
Vec_IntSize
(
p
->
vTfo
)
+
Vec_IntSize
(
p
->
vRoots
)
+
1
0
);
// create SAT variables
Sfm_NtkCleanVars
(
p
);
p
->
nSatVars
=
1
;
...
...
@@ -80,7 +84,7 @@ void Sfm_NtkWindowToSolver( Sfm_Ntk_t * p )
Vec_IntPush
(
p
->
vFaninMap
,
Sfm_ObjSatVar
(
p
,
iFanin
)
);
Vec_IntPush
(
p
->
vFaninMap
,
Sfm_ObjSatVar
(
p
,
iNode
)
);
// generate CNF
Sfm_TranslateCnf
(
p
->
vClauses
,
(
Vec_Str_t
*
)
Vec_WecEntry
(
p
->
vCnfs
,
iNode
),
p
->
vFaninMap
);
Sfm_TranslateCnf
(
p
->
vClauses
,
(
Vec_Str_t
*
)
Vec_WecEntry
(
p
->
vCnfs
,
iNode
),
p
->
vFaninMap
,
-
1
);
// add clauses
Vec_WecForEachLevel
(
p
->
vClauses
,
vClause
,
k
)
{
...
...
@@ -90,6 +94,51 @@ void Sfm_NtkWindowToSolver( Sfm_Ntk_t * p )
assert
(
RetValue
);
}
}
if
(
Vec_IntSize
(
p
->
vTfo
)
>
0
)
{
assert
(
p
->
pPars
->
nTfoLevMax
>
0
);
assert
(
Vec_IntSize
(
p
->
vRoots
)
>
0
);
assert
(
Vec_IntEntry
(
p
->
vTfo
,
0
)
!=
p
->
iPivotNode
);
// collect variables of root nodes
Vec_IntClear
(
p
->
vLits
);
Vec_IntForEachEntry
(
p
->
vRoots
,
iNode
,
i
)
Vec_IntPush
(
p
->
vLits
,
Sfm_ObjSatVar
(
p
,
iNode
)
);
// assign new variables to the TFO nodes
Vec_IntForEachEntry
(
p
->
vTfo
,
iNode
,
i
)
{
Sfm_ObjCleanSatVar
(
p
,
Sfm_ObjSatVar
(
p
,
iNode
)
);
Sfm_ObjSetSatVar
(
p
,
iNode
,
p
->
nSatVars
++
);
}
// add CNF clauses for the TFO
Vec_IntForEachEntry
(
p
->
vTfo
,
iNode
,
i
)
{
assert
(
Sfm_ObjIsNode
(
p
,
iNode
)
);
// collect fanin variables
Vec_IntClear
(
p
->
vFaninMap
);
Sfm_ObjForEachFanin
(
p
,
iNode
,
iFanin
,
k
)
Vec_IntPush
(
p
->
vFaninMap
,
Sfm_ObjSatVar
(
p
,
iFanin
)
);
Vec_IntPush
(
p
->
vFaninMap
,
Sfm_ObjSatVar
(
p
,
iNode
)
);
// generate CNF
Sfm_TranslateCnf
(
p
->
vClauses
,
(
Vec_Str_t
*
)
Vec_WecEntry
(
p
->
vCnfs
,
iNode
),
p
->
vFaninMap
,
Sfm_ObjSatVar
(
p
,
p
->
iPivotNode
)
);
// add clauses
Vec_WecForEachLevel
(
p
->
vClauses
,
vClause
,
k
)
{
if
(
Vec_IntSize
(
vClause
)
==
0
)
break
;
RetValue
=
sat_solver_addclause
(
p
->
pSat
,
Vec_IntArray
(
vClause
),
Vec_IntArray
(
vClause
)
+
Vec_IntSize
(
vClause
)
);
assert
(
RetValue
);
}
}
// create XOR clauses for the roots
Vec_IntForEachEntry
(
p
->
vRoots
,
iNode
,
i
)
{
sat_solver_add_xor
(
p
->
pSat
,
Vec_IntEntry
(
p
->
vLits
,
i
),
Sfm_ObjSatVar
(
p
,
iNode
),
p
->
nSatVars
++
,
0
);
Vec_IntWriteEntry
(
p
->
vLits
,
i
,
Abc_Var2Lit
(
p
->
nSatVars
-
1
,
0
)
);
}
// make OR clause for the last nRoots variables
RetValue
=
sat_solver_addclause
(
p
->
pSat
,
Vec_IntArray
(
p
->
vLits
),
Vec_IntArray
(
p
->
vLits
)
+
Vec_IntSize
(
p
->
vLits
)
);
assert
(
RetValue
);
}
// finalize
RetValue
=
sat_solver_simplify
(
p
->
pSat
);
assert
(
RetValue
);
...
...
@@ -113,7 +162,7 @@ word Sfm_ComputeInterpolant( Sfm_Ntk_t * p )
int
status
,
i
,
Div
,
iVar
,
nFinal
,
*
pFinal
,
nIter
=
0
;
int
pLits
[
2
],
nVars
=
sat_solver_nvars
(
p
->
pSat
);
sat_solver_setnvars
(
p
->
pSat
,
nVars
+
1
);
pLits
[
0
]
=
Abc_Var2Lit
(
Sfm_ObjSatVar
(
p
,
Vec_IntEntryLast
(
p
->
vNodes
)
),
0
);
// F = 1
pLits
[
0
]
=
Abc_Var2Lit
(
Sfm_ObjSatVar
(
p
,
p
->
iPivotNode
),
0
);
// F = 1
pLits
[
1
]
=
Abc_Var2Lit
(
nVars
,
0
);
// iNewLit
while
(
1
)
{
...
...
src/opt/sfm/sfmWin.c
View file @
3c978925
This diff is collapsed.
Click to expand it.
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