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
7dcba3e2
Commit
7dcba3e2
authored
Jun 29, 2016
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with edge-based mapping.
parent
688f0269
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
198 additions
and
35 deletions
+198
-35
src/aig/gia/giaEdge.c
+3
-2
src/aig/gia/giaSatLE.c
+170
-24
src/base/abci/abc.c
+25
-9
No files found.
src/aig/gia/giaEdge.c
View file @
7dcba3e2
...
@@ -175,13 +175,14 @@ int Gia_ObjCheckEdge( Gia_Man_t * p, int iObj, int iNext )
...
@@ -175,13 +175,14 @@ int Gia_ObjCheckEdge( Gia_Man_t * p, int iObj, int iNext )
}
}
static
inline
int
Gia_ObjEvalEdgeDelay
(
Gia_Man_t
*
p
,
int
iObj
,
Vec_Int_t
*
vDelay
)
static
inline
int
Gia_ObjEvalEdgeDelay
(
Gia_Man_t
*
p
,
int
iObj
,
Vec_Int_t
*
vDelay
)
{
{
int
nEdgeDelay
=
2
;
int
i
,
iFan
,
Delay
,
DelayMax
=
0
;
int
i
,
iFan
,
Delay
,
DelayMax
=
0
;
if
(
Gia_ManHasMapping
(
p
)
&&
Gia_ObjIsLut
(
p
,
iObj
)
)
if
(
Gia_ManHasMapping
(
p
)
&&
Gia_ObjIsLut
(
p
,
iObj
)
)
{
{
assert
(
Gia_ObjLutSize
(
p
,
iObj
)
<=
4
);
assert
(
Gia_ObjLutSize
(
p
,
iObj
)
<=
4
);
Gia_LutForEachFanin
(
p
,
iObj
,
iFan
,
i
)
Gia_LutForEachFanin
(
p
,
iObj
,
iFan
,
i
)
{
{
Delay
=
Vec_IntEntry
(
vDelay
,
iFan
)
+
(
Gia_ObjHaveEdge
(
p
,
iObj
,
iFan
)
?
2
:
10
);
Delay
=
Vec_IntEntry
(
vDelay
,
iFan
)
+
(
Gia_ObjHaveEdge
(
p
,
iObj
,
iFan
)
?
nEdgeDelay
:
10
);
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Delay
);
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Delay
);
}
}
}
}
...
@@ -190,7 +191,7 @@ static inline int Gia_ObjEvalEdgeDelay( Gia_Man_t * p, int iObj, Vec_Int_t * vDe
...
@@ -190,7 +191,7 @@ static inline int Gia_ObjEvalEdgeDelay( Gia_Man_t * p, int iObj, Vec_Int_t * vDe
assert
(
Gia_ObjLutSize2
(
p
,
iObj
)
<=
4
);
assert
(
Gia_ObjLutSize2
(
p
,
iObj
)
<=
4
);
Gia_LutForEachFanin2
(
p
,
iObj
,
iFan
,
i
)
Gia_LutForEachFanin2
(
p
,
iObj
,
iFan
,
i
)
{
{
Delay
=
Vec_IntEntry
(
vDelay
,
iFan
)
+
(
Gia_ObjHaveEdge
(
p
,
iObj
,
iFan
)
?
2
:
10
);
Delay
=
Vec_IntEntry
(
vDelay
,
iFan
)
+
(
Gia_ObjHaveEdge
(
p
,
iObj
,
iFan
)
?
nEdgeDelay
:
10
);
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Delay
);
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Delay
);
}
}
}
}
...
...
src/aig/gia/giaSatLE.c
View file @
7dcba3e2
...
@@ -31,8 +31,8 @@ ABC_NAMESPACE_IMPL_START
...
@@ -31,8 +31,8 @@ ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
static
inline
int
Sle_CutSize
(
int
*
pCut
)
{
return
pCut
[
0
]
&
0xF
;
}
// 4 bits
static
inline
int
Sle_CutSize
(
int
*
pCut
)
{
return
pCut
[
0
]
&
0xF
;
}
// 4 bits
static
inline
int
Sle_CutSign
(
int
*
pCut
)
{
return
pCut
[
0
]
>>
4
;
}
// 28 bits
static
inline
int
Sle_CutSign
(
int
*
pCut
)
{
return
((
unsigned
)
pCut
[
0
])
>>
4
;
}
// 28 bits
static
inline
int
Sle_CutSetSizeSign
(
int
s
,
int
S
)
{
return
(
S
<<
28
)
|
s
;
}
static
inline
int
Sle_CutSetSizeSign
(
int
s
,
int
S
)
{
return
(
S
<<
4
)
|
s
;
}
static
inline
int
*
Sle_CutLeaves
(
int
*
pCut
)
{
return
pCut
+
1
;
}
static
inline
int
*
Sle_CutLeaves
(
int
*
pCut
)
{
return
pCut
+
1
;
}
static
inline
int
Sle_CutIsUsed
(
int
*
pCut
)
{
return
pCut
[
1
]
!=
0
;
}
static
inline
int
Sle_CutIsUsed
(
int
*
pCut
)
{
return
pCut
[
1
]
!=
0
;
}
...
@@ -197,7 +197,7 @@ int Sle_ManCutMerge( Gia_Man_t * p, int iObj, Vec_Int_t * vCuts, Vec_Int_t * vTe
...
@@ -197,7 +197,7 @@ int Sle_ManCutMerge( Gia_Man_t * p, int iObj, Vec_Int_t * vCuts, Vec_Int_t * vTe
nCuts
++
;
nCuts
++
;
}
}
// add unit cut
// add unit cut
Vec_IntPush
(
vCuts
,
Sle_CutSetSizeSign
(
1
,
iObj
%
28
)
);
Vec_IntPush
(
vCuts
,
Sle_CutSetSizeSign
(
1
,
1
<<
(
iObj
%
28
)
)
);
Vec_IntPush
(
vCuts
,
iObj
);
Vec_IntPush
(
vCuts
,
iObj
);
Vec_IntWriteEntry
(
vCuts
,
Vec_IntEntry
(
vCuts
,
iObj
),
nCuts
);
Vec_IntWriteEntry
(
vCuts
,
Vec_IntEntry
(
vCuts
,
iObj
),
nCuts
);
return
nCuts
;
return
nCuts
;
...
@@ -213,7 +213,7 @@ Vec_Int_t * Sle_ManComputeCuts( Gia_Man_t * p, int nLutSize, int fVerbose )
...
@@ -213,7 +213,7 @@ Vec_Int_t * Sle_ManComputeCuts( Gia_Man_t * p, int nLutSize, int fVerbose )
{
{
Vec_IntWriteEntry
(
vCuts
,
iObj
,
Vec_IntSize
(
vCuts
)
);
Vec_IntWriteEntry
(
vCuts
,
iObj
,
Vec_IntSize
(
vCuts
)
);
Vec_IntPush
(
vCuts
,
0
);
Vec_IntPush
(
vCuts
,
0
);
Vec_IntPush
(
vCuts
,
Sle_CutSetSizeSign
(
1
,
iObj
%
28
)
);
Vec_IntPush
(
vCuts
,
Sle_CutSetSizeSign
(
1
,
1
<<
(
iObj
%
28
)
)
);
Vec_IntPush
(
vCuts
,
iObj
);
Vec_IntPush
(
vCuts
,
iObj
);
}
}
Gia_ManForEachAndId
(
p
,
iObj
)
Gia_ManForEachAndId
(
p
,
iObj
)
...
@@ -226,6 +226,64 @@ Vec_Int_t * Sle_ManComputeCuts( Gia_Man_t * p, int nLutSize, int fVerbose )
...
@@ -226,6 +226,64 @@ Vec_Int_t * Sle_ManComputeCuts( Gia_Man_t * p, int nLutSize, int fVerbose )
Vec_IntFree
(
vTemp
);
Vec_IntFree
(
vTemp
);
return
vCuts
;
return
vCuts
;
}
}
/**Function*************************************************************
Synopsis [Cut delay computation.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Sle_ManComputeDelayCut
(
Gia_Man_t
*
p
,
int
*
pCut
,
Vec_Int_t
*
vTime
)
{
int
nSize
=
Sle_CutSize
(
pCut
);
int
k
,
*
pC
=
Sle_CutLeaves
(
pCut
);
int
DelayMax
=
0
;
for
(
k
=
0
;
k
<
nSize
;
k
++
)
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Vec_IntEntry
(
vTime
,
pC
[
k
])
);
return
DelayMax
+
1
;
}
int
Sle_ManComputeDelayOne
(
Gia_Man_t
*
p
,
int
iObj
,
Vec_Int_t
*
vCuts
,
Vec_Int_t
*
vTime
)
{
int
i
,
*
pCut
,
Delay
,
DelayMin
=
ABC_INFINITY
;
int
*
pList
=
Vec_IntEntryP
(
vCuts
,
Vec_IntEntry
(
vCuts
,
iObj
)
);
Sle_ForEachCut
(
pList
,
pCut
,
i
)
{
Delay
=
Sle_ManComputeDelayCut
(
p
,
pCut
,
vTime
);
DelayMin
=
Abc_MinInt
(
DelayMin
,
Delay
);
}
Vec_IntWriteEntry
(
vTime
,
iObj
,
DelayMin
);
return
DelayMin
;
}
int
Sle_ManComputeDelay
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vCuts
)
{
int
iObj
,
Delay
,
DelayMax
=
0
;
Vec_Int_t
*
vTime
=
Vec_IntStart
(
Gia_ManObjNum
(
p
)
);
Gia_ManForEachAndId
(
p
,
iObj
)
{
Delay
=
Sle_ManComputeDelayOne
(
p
,
iObj
,
vCuts
,
vTime
);
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Delay
);
}
Vec_IntFree
(
vTime
);
//printf( "Delay = %d.\n", DelayMax );
return
DelayMax
;
}
/**Function*************************************************************
Synopsis [Cut printing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Sle_ManPrintCut
(
int
*
pCut
)
void
Sle_ManPrintCut
(
int
*
pCut
)
{
{
int
nSize
=
Sle_CutSize
(
pCut
);
int
nSize
=
Sle_CutSize
(
pCut
);
...
@@ -347,6 +405,7 @@ struct Sle_Man_t_
...
@@ -347,6 +405,7 @@ struct Sle_Man_t_
Gia_Man_t
*
pGia
;
// user's manager (with mapping and edges)
Gia_Man_t
*
pGia
;
// user's manager (with mapping and edges)
int
nLevels
;
// total number of levels
int
nLevels
;
// total number of levels
int
fVerbose
;
// verbose flag
int
fVerbose
;
// verbose flag
int
nSatCalls
;
// the number of SAT calls
// SAT variables
// SAT variables
int
nNodeVars
;
// node variables (Gia_ManAndNum(pGia))
int
nNodeVars
;
// node variables (Gia_ManAndNum(pGia))
int
nCutVars
;
// cut variables (total number of non-trivial cuts)
int
nCutVars
;
// cut variables (total number of non-trivial cuts)
...
@@ -405,6 +464,7 @@ Sle_Man_t * Sle_ManAlloc( Gia_Man_t * pGia, int nLevels, int fVerbose )
...
@@ -405,6 +464,7 @@ Sle_Man_t * Sle_ManAlloc( Gia_Man_t * pGia, int nLevels, int fVerbose )
p
->
vDelayFirst
=
Vec_IntStartFull
(
Gia_ManObjNum
(
pGia
)
);
p
->
vDelayFirst
=
Vec_IntStartFull
(
Gia_ManObjNum
(
pGia
)
);
p
->
vPolars
=
Vec_IntAlloc
(
100
);
p
->
vPolars
=
Vec_IntAlloc
(
100
);
p
->
vLits
=
Vec_IntAlloc
(
100
);
p
->
vLits
=
Vec_IntAlloc
(
100
);
p
->
nLevels
=
Sle_ManComputeDelay
(
pGia
,
p
->
vCuts
);
return
p
;
return
p
;
}
}
void
Sle_ManStop
(
Sle_Man_t
*
p
)
void
Sle_ManStop
(
Sle_Man_t
*
p
)
...
@@ -462,8 +522,6 @@ void Sle_ManMarkupVariables( Sle_Man_t * p )
...
@@ -462,8 +522,6 @@ void Sle_ManMarkupVariables( Sle_Man_t * p )
}
}
p
->
nDelayVars
=
Counter
-
p
->
nEdgeVars
-
p
->
nCutVars
-
p
->
nNodeVars
;
p
->
nDelayVars
=
Counter
-
p
->
nEdgeVars
-
p
->
nCutVars
-
p
->
nNodeVars
;
p
->
nVarsTotal
=
Counter
;
p
->
nVarsTotal
=
Counter
;
printf
(
"Vars: Total = %d. Node = %d. Cut = %d. Edge = %d. Delay = %d.
\n
"
,
p
->
nVarsTotal
,
p
->
nNodeVars
,
p
->
nCutVars
,
p
->
nEdgeVars
,
p
->
nDelayVars
);
}
}
...
@@ -552,9 +610,8 @@ void Sle_ManDeriveInit( Sle_Man_t * p )
...
@@ -552,9 +610,8 @@ void Sle_ManDeriveInit( Sle_Man_t * p )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Sle_ManDeriveCnf
(
Sle_Man_t
*
p
)
void
Sle_ManDeriveCnf
(
Sle_Man_t
*
p
,
int
nBTLimit
,
int
fDynamic
)
{
{
int
nBTLimit
=
0
;
int
nTimeOut
=
0
;
int
nTimeOut
=
0
;
int
i
,
iObj
,
value
;
int
i
,
iObj
,
value
;
Vec_Int_t
*
vArray
;
Vec_Int_t
*
vArray
;
...
@@ -580,7 +637,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -580,7 +637,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
// add cover clauses and edge-to-cut clauses
// add cover clauses and edge-to-cut clauses
Gia_ManForEachAndId
(
p
->
pGia
,
iObj
)
Gia_ManForEachAndId
(
p
->
pGia
,
iObj
)
{
{
int
e
,
iEdge
,
nEdges
=
0
,
Entry
;
int
iEdge
,
nEdges
=
0
,
Entry
;
int
iCutVar0
=
Vec_IntEntry
(
p
->
vCutFirst
,
iObj
);
int
iCutVar0
=
Vec_IntEntry
(
p
->
vCutFirst
,
iObj
);
int
iEdgeVar0
=
Vec_IntEntry
(
p
->
vEdgeFirst
,
iObj
);
int
iEdgeVar0
=
Vec_IntEntry
(
p
->
vEdgeFirst
,
iObj
);
int
*
pCut
,
*
pList
=
Sle_ManList
(
p
,
iObj
);
int
*
pCut
,
*
pList
=
Sle_ManList
(
p
,
iObj
);
...
@@ -609,14 +666,16 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -609,14 +666,16 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
// find the edge ID between pC[k] and iObj
// find the edge ID between pC[k] and iObj
iEdge
=
Vec_IntEntry
(
p
->
vObjMap
,
pC
[
k
]);
iEdge
=
Vec_IntEntry
(
p
->
vObjMap
,
pC
[
k
]);
if
(
iEdge
==
-
1
)
if
(
iEdge
==
-
1
)
{
Vec_IntWriteEntry
(
p
->
vObjMap
,
pC
[
k
],
(
iEdge
=
nEdges
++
)
);
Vec_IntWriteEntry
(
p
->
vObjMap
,
pC
[
k
],
(
iEdge
=
nEdges
++
)
);
Vec_WecPush
(
p
->
vFanoutEdges
,
pC
[
k
],
iEdgeVar0
+
iEdge
);
}
Vec_WecPush
(
p
->
vEdgeCuts
,
iEdge
,
iCutVar0
+
i
);
Vec_WecPush
(
p
->
vEdgeCuts
,
iEdge
,
iCutVar0
+
i
);
Vec_WecPush
(
p
->
vFanoutEdges
,
pC
[
k
],
iEdgeVar0
+
iEdge
);
p
->
nCutClas
++
;
p
->
nCutClas
++
;
}
}
}
}
assert
(
nEdges
==
Vec_IntSize
(
vCutFans
)
);
assert
(
nEdges
==
Vec_IntSize
(
vCutFans
)
);
/*
// edge requires one of the fanout cuts
// edge requires one of the fanout cuts
Vec_WecForEachLevel( p->vEdgeCuts, vArray, e )
Vec_WecForEachLevel( p->vEdgeCuts, vArray, e )
{
{
...
@@ -628,7 +687,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -628,7 +687,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
assert( value );
assert( value );
p->nEdgeClas++;
p->nEdgeClas++;
}
}
*/
// clean object map
// clean object map
Vec_IntForEachEntry
(
vCutFans
,
Entry
,
i
)
Vec_IntForEachEntry
(
vCutFans
,
Entry
,
i
)
Vec_IntWriteEntry
(
p
->
vObjMap
,
Entry
,
-
1
);
Vec_IntWriteEntry
(
p
->
vObjMap
,
Entry
,
-
1
);
...
@@ -644,6 +703,8 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -644,6 +703,8 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
for
(
i
=
0
;
i
<
Vec_IntSize
(
vCutFans
);
i
++
)
for
(
i
=
0
;
i
<
Vec_IntSize
(
vCutFans
);
i
++
)
Vec_IntPush
(
vArray
,
iEdgeVar0
+
i
);
Vec_IntPush
(
vArray
,
iEdgeVar0
+
i
);
// generate pairs
// generate pairs
if
(
fDynamic
)
continue
;
Vec_IntForEachEntry
(
vArray
,
EdgeJ
,
j
)
Vec_IntForEachEntry
(
vArray
,
EdgeJ
,
j
)
Vec_IntForEachEntryStart
(
vArray
,
EdgeK
,
k
,
j
+
1
)
Vec_IntForEachEntryStart
(
vArray
,
EdgeK
,
k
,
j
+
1
)
{
{
...
@@ -667,6 +728,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -667,6 +728,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
if
(
Sle_ManCutHasPisOnly
(
pCut
,
p
->
vMask
)
)
if
(
Sle_ManCutHasPisOnly
(
pCut
,
p
->
vMask
)
)
{
{
Vec_IntFill
(
p
->
vLits
,
1
,
Abc_Var2Lit
(
iDelayVar0
,
0
)
);
// pos lit
Vec_IntFill
(
p
->
vLits
,
1
,
Abc_Var2Lit
(
iDelayVar0
,
0
)
);
// pos lit
// Vec_IntFillTwo( p->vLits, 2, Abc_Var2Lit(iObj, 1), Abc_Var2Lit(iDelayVar0, 0) );
value
=
sat_solver_addclause
(
p
->
pSat
,
Vec_IntArray
(
p
->
vLits
),
Vec_IntLimit
(
p
->
vLits
)
);
value
=
sat_solver_addclause
(
p
->
pSat
,
Vec_IntArray
(
p
->
vLits
),
Vec_IntLimit
(
p
->
vLits
)
);
assert
(
value
);
assert
(
value
);
break
;
break
;
...
@@ -680,6 +742,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -680,6 +742,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
for
(
d
=
0
;
d
<
p
->
nLevels
;
d
++
)
for
(
d
=
0
;
d
<
p
->
nLevels
;
d
++
)
{
{
Vec_IntClear
(
p
->
vLits
);
Vec_IntClear
(
p
->
vLits
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iObj
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iFanin
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iFanin
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iDelayVarIn
+
d
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iDelayVarIn
+
d
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iEdgeVar0
+
e
,
0
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iEdgeVar0
+
e
,
0
)
);
...
@@ -689,6 +752,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -689,6 +752,7 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
assert
(
value
);
assert
(
value
);
Vec_IntClear
(
p
->
vLits
);
Vec_IntClear
(
p
->
vLits
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iObj
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iFanin
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iFanin
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iDelayVarIn
+
d
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
iDelayVarIn
+
d
,
1
)
);
if
(
d
<
p
->
nLevels
-
1
)
if
(
d
<
p
->
nLevels
-
1
)
...
@@ -700,8 +764,68 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
...
@@ -700,8 +764,68 @@ void Sle_ManDeriveCnf( Sle_Man_t * p )
p
->
nDelayClas
+=
2
*
p
->
nLevels
;
p
->
nDelayClas
+=
2
*
p
->
nLevels
;
}
}
}
}
printf
(
"Clas: Total = %d. Cut = %d. Edge = %d. EdgeEx = %d. Delay = %d.
\n
"
,
}
sat_solver_nclauses
(
p
->
pSat
),
p
->
nCutClas
,
p
->
nEdgeClas
,
p
->
nEdgeClas2
,
p
->
nDelayClas
);
/**Function*************************************************************
Synopsis [Add edge compatibility constraints.]
Description [Returns 1 if constraints have been added.]
SideEffects []
SeeAlso []
***********************************************************************/
int
Sle_ManAddEdgeConstraints
(
Sle_Man_t
*
p
,
int
nEdges
)
{
Vec_Int_t
*
vArray
;
Vec_Int_t
*
vTemp
=
Vec_IntAlloc
(
100
);
int
value
,
iObj
,
nAdded
=
0
;
assert
(
nEdges
==
1
||
nEdges
==
2
);
Vec_WecForEachLevel
(
p
->
vFanoutEdges
,
vArray
,
iObj
)
{
int
j
,
k
,
EdgeJ
,
EdgeK
;
// check if they are incompatible
Vec_IntClear
(
vTemp
);
Vec_IntForEachEntry
(
vArray
,
EdgeJ
,
j
)
if
(
sat_solver_var_value
(
p
->
pSat
,
EdgeJ
)
)
Vec_IntPush
(
vTemp
,
EdgeJ
);
if
(
Vec_IntSize
(
vTemp
)
<=
nEdges
)
continue
;
nAdded
++
;
if
(
nEdges
==
1
)
{
// generate pairs
Vec_IntForEachEntry
(
vTemp
,
EdgeJ
,
j
)
Vec_IntForEachEntryStart
(
vTemp
,
EdgeK
,
k
,
j
+
1
)
{
Vec_IntFillTwo
(
p
->
vLits
,
2
,
Abc_Var2Lit
(
EdgeJ
,
1
),
Abc_Var2Lit
(
EdgeK
,
1
)
);
value
=
sat_solver_addclause
(
p
->
pSat
,
Vec_IntArray
(
p
->
vLits
),
Vec_IntLimit
(
p
->
vLits
)
);
assert
(
value
);
}
p
->
nEdgeClas2
+=
Vec_IntSize
(
vTemp
)
*
(
Vec_IntSize
(
vTemp
)
-
1
)
/
2
;
}
else
if
(
nEdges
==
2
)
{
int
m
,
EdgeM
;
// generate triples
Vec_IntForEachEntry
(
vTemp
,
EdgeJ
,
j
)
Vec_IntForEachEntryStart
(
vTemp
,
EdgeK
,
k
,
j
+
1
)
Vec_IntForEachEntryStart
(
vTemp
,
EdgeM
,
m
,
k
+
1
)
{
Vec_IntFillTwo
(
p
->
vLits
,
2
,
Abc_Var2Lit
(
EdgeJ
,
1
),
Abc_Var2Lit
(
EdgeK
,
1
)
);
Vec_IntPush
(
p
->
vLits
,
Abc_Var2Lit
(
EdgeM
,
1
)
);
value
=
sat_solver_addclause
(
p
->
pSat
,
Vec_IntArray
(
p
->
vLits
),
Vec_IntLimit
(
p
->
vLits
)
);
assert
(
value
);
}
p
->
nEdgeClas2
+=
Vec_IntSize
(
vTemp
)
*
(
Vec_IntSize
(
vTemp
)
-
1
)
*
(
Vec_IntSize
(
vTemp
)
-
2
)
/
6
;
}
else
assert
(
0
);
}
Vec_IntFree
(
vTemp
);
//printf( "Added clauses to %d nodes.\n", nAdded );
return
nAdded
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -761,23 +885,31 @@ void Sle_ManDeriveResult( Sle_Man_t * p, Vec_Int_t * vEdge2, Vec_Int_t * vMappin
...
@@ -761,23 +885,31 @@ void Sle_ManDeriveResult( Sle_Man_t * p, Vec_Int_t * vEdge2, Vec_Int_t * vMappin
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Sle_ManExplore
(
Gia_Man_t
*
pGia
,
int
DelayInit
,
int
fVerbose
)
void
Sle_ManExplore
(
Gia_Man_t
*
pGia
,
int
nBTLimit
,
int
DelayInit
,
int
fDynamic
,
int
fTwoEdges
,
int
fVerbose
)
{
{
int
fVeryVerbose
=
0
;
int
fVeryVerbose
=
0
;
abctime
clk
=
Abc_Clock
();
abctime
clk
=
Abc_Clock
();
Vec_Int_t
*
vEdges2
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vEdges2
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vMapping
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vMapping
=
Vec_IntAlloc
(
1000
);
int
i
,
iLut
,
nConfs
,
status
,
Delay
,
iFirstVar
;
int
i
,
iLut
,
nConfs
,
status
,
Delay
,
iFirstVar
;
int
DelayStart
=
DelayInit
?
DelayInit
:
Gia_ManLutLevel
(
pGia
,
NULL
);
int
DelayStart
=
(
DelayInit
||
!
Gia_ManHasMapping
(
pGia
))
?
DelayInit
:
Gia_ManLutLevel
(
pGia
,
NULL
);
Sle_Man_t
*
p
=
Sle_ManAlloc
(
pGia
,
DelayStart
,
fVerbose
);
Sle_Man_t
*
p
=
Sle_ManAlloc
(
pGia
,
DelayStart
,
fVerbose
);
if
(
fVerbose
)
printf
(
"Running solver with %d conflicts, %d initial delay, and %d edges. Dynamic constraints = %s.
\n
"
,
nBTLimit
,
DelayInit
,
1
+
fTwoEdges
,
fDynamic
?
"yes"
:
"no"
);
Sle_ManMarkupVariables
(
p
);
Sle_ManMarkupVariables
(
p
);
if
(
fVerbose
)
printf
(
"Vars: Total = %d. Node = %d. Cut = %d. Edge = %d. Delay = %d.
\n
"
,
p
->
nVarsTotal
,
p
->
nNodeVars
,
p
->
nCutVars
,
p
->
nEdgeVars
,
p
->
nDelayVars
);
Sle_ManDeriveInit
(
p
);
Sle_ManDeriveInit
(
p
);
Sle_ManDeriveCnf
(
p
);
Sle_ManDeriveCnf
(
p
,
nBTLimit
,
fDynamic
||
fTwoEdges
);
if
(
fVerbose
)
printf
(
"Clas: Total = %d. Cut = %d. Edge = %d. EdgeEx = %d. Delay = %d.
\n
"
,
sat_solver_nclauses
(
p
->
pSat
),
p
->
nCutClas
,
p
->
nEdgeClas
,
p
->
nEdgeClas2
,
p
->
nDelayClas
);
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", NULL, NULL, 0 );
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", NULL, NULL, 0 );
for
(
Delay
=
DelayStart
;
Delay
>=
0
;
Delay
--
)
for
(
Delay
=
p
->
nLevels
;
Delay
>=
0
;
Delay
--
)
{
{
// we constrain COs, although it would be fine to constrain only POs
// we constrain COs, although it would be fine to constrain only POs
if
(
Delay
<
DelayStart
)
if
(
Delay
<
p
->
nLevels
)
{
{
Gia_ManForEachCoDriverId
(
p
->
pGia
,
iLut
,
i
)
Gia_ManForEachCoDriverId
(
p
->
pGia
,
iLut
,
i
)
if
(
Vec_BitEntry
(
p
->
vMask
,
iLut
)
)
// internal node
if
(
Vec_BitEntry
(
p
->
vMask
,
iLut
)
)
// internal node
...
@@ -788,15 +920,26 @@ void Sle_ManExplore( Gia_Man_t * pGia, int DelayInit, int fVerbose )
...
@@ -788,15 +920,26 @@ void Sle_ManExplore( Gia_Man_t * pGia, int DelayInit, int fVerbose )
}
}
if
(
i
<
Gia_ManCoNum
(
p
->
pGia
)
)
if
(
i
<
Gia_ManCoNum
(
p
->
pGia
)
)
{
{
printf
(
"Proved UNSAT for delay %d. "
,
Delay
);
if
(
fVerbose
)
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
{
printf
(
"Proved UNSAT for delay %d. "
,
Delay
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
}
break
;
break
;
}
}
}
}
// solve with assumptions
// solve with assumptions
//clk = Abc_Clock();
//clk = Abc_Clock();
nConfs
=
sat_solver_nconflicts
(
p
->
pSat
);
nConfs
=
sat_solver_nconflicts
(
p
->
pSat
);
status
=
sat_solver_solve_internal
(
p
->
pSat
);
while
(
1
)
{
p
->
nSatCalls
++
;
status
=
sat_solver_solve_internal
(
p
->
pSat
);
if
(
status
!=
l_True
)
break
;
if
(
!
Sle_ManAddEdgeConstraints
(
p
,
1
+
fTwoEdges
)
)
break
;
}
nConfs
=
sat_solver_nconflicts
(
p
->
pSat
)
-
nConfs
;
nConfs
=
sat_solver_nconflicts
(
p
->
pSat
)
-
nConfs
;
if
(
status
==
l_True
)
if
(
status
==
l_True
)
{
{
...
@@ -851,14 +994,17 @@ void Sle_ManExplore( Gia_Man_t * pGia, int DelayInit, int fVerbose )
...
@@ -851,14 +994,17 @@ void Sle_ManExplore( Gia_Man_t * pGia, int DelayInit, int fVerbose )
if
(
fVerbose
)
if
(
fVerbose
)
{
{
if
(
status
==
l_False
)
if
(
status
==
l_False
)
printf
(
"Proved UNSAT for delay %d.
"
,
Delay
);
printf
(
"Proved UNSAT for delay %d.
Conf = %8d. "
,
Delay
,
nConfs
);
else
else
printf
(
"Resource limit reached for delay %d.
"
,
Delay
);
printf
(
"Resource limit reached for delay %d.
Conf = %8d. "
,
Delay
,
nConfs
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
}
}
break
;
break
;
}
}
}
}
if
(
fVerbose
)
printf
(
"Clas: Total = %d. Cut = %d. Edge = %d. EdgeEx = %d. Delay = %d. Calls = %d.
\n
"
,
sat_solver_nclauses
(
p
->
pSat
),
p
->
nCutClas
,
p
->
nEdgeClas
,
p
->
nEdgeClas2
,
p
->
nDelayClas
,
p
->
nSatCalls
);
if
(
Vec_IntSize
(
vMapping
)
>
0
)
if
(
Vec_IntSize
(
vMapping
)
>
0
)
{
{
Gia_ManEdgeFromArray
(
p
->
pGia
,
vEdges2
);
Gia_ManEdgeFromArray
(
p
->
pGia
,
vEdges2
);
...
...
src/base/abci/abc.c
View file @
7dcba3e2
...
@@ -35224,14 +35224,23 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -35224,14 +35224,23 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
{
{
extern
int
Edg_ManAssignEdgeNew
(
Gia_Man_t
*
p
,
int
nEdges
,
int
fVerbose
);
extern
int
Edg_ManAssignEdgeNew
(
Gia_Man_t
*
p
,
int
nEdges
,
int
fVerbose
);
extern
void
Seg_ManComputeDelay
(
Gia_Man_t
*
pGia
,
int
Delay
,
int
nFanouts
,
int
fTwo
,
int
fVerbose
);
extern
void
Seg_ManComputeDelay
(
Gia_Man_t
*
pGia
,
int
Delay
,
int
nFanouts
,
int
fTwo
,
int
fVerbose
);
extern
void
Sle_ManExplore
(
Gia_Man_t
*
pGia
,
int
DelayInit
,
int
fVerbose
);
extern
void
Sle_ManExplore
(
Gia_Man_t
*
pGia
,
int
nBTLimit
,
int
DelayInit
,
int
fDynamic
,
int
fTwoEdges
,
int
fVerbose
);
int
c
,
DelayMax
=
0
,
nFanouts
=
0
,
nEdges
=
1
,
fReverse
=
0
,
fUsePack
=
0
,
fUseOld
=
0
,
fMapping
=
0
,
fVerbose
=
0
;
int
c
,
nBTLimit
=
0
,
DelayMax
=
0
,
nFanouts
=
0
,
nEdges
=
1
,
fReverse
=
0
,
fUsePack
=
0
,
fUseOld
=
0
,
fMapping
=
0
,
fDynamic
=
1
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"
DFErpom
vh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"
CDFErpomd
vh"
)
)
!=
EOF
)
{
{
switch
(
c
)
switch
(
c
)
{
{
case
'C'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-C
\"
should be followed by a positive integer.
\n
"
);
goto
usage
;
}
nBTLimit
=
atoi
(
argv
[
globalUtilOptind
]);
globalUtilOptind
++
;
break
;
case
'D'
:
case
'D'
:
if
(
globalUtilOptind
>=
argc
)
if
(
globalUtilOptind
>=
argc
)
{
{
...
@@ -35276,6 +35285,9 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -35276,6 +35285,9 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
case
'm'
:
case
'm'
:
fMapping
^=
1
;
fMapping
^=
1
;
break
;
break
;
case
'd'
:
fDynamic
^=
1
;
break
;
case
'v'
:
case
'v'
:
fVerbose
^=
1
;
fVerbose
^=
1
;
break
;
break
;
...
@@ -35289,16 +35301,16 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -35289,16 +35301,16 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
-
1
,
"Empty GIA network.
\n
"
);
Abc_Print
(
-
1
,
"Empty GIA network.
\n
"
);
return
1
;
return
1
;
}
}
if
(
fMapping
)
{
Sle_ManExplore
(
pAbc
->
pGia
,
nBTLimit
,
DelayMax
,
fDynamic
,
nEdges
==
2
,
fVerbose
);
return
0
;
}
if
(
!
Gia_ManHasMapping
(
pAbc
->
pGia
)
)
if
(
!
Gia_ManHasMapping
(
pAbc
->
pGia
)
)
{
{
Abc_Print
(
-
1
,
"Current AIG has no mapping. Run
\"
&if
\"
.
\n
"
);
Abc_Print
(
-
1
,
"Current AIG has no mapping. Run
\"
&if
\"
.
\n
"
);
return
1
;
return
1
;
}
}
if
(
fMapping
)
{
Sle_ManExplore
(
pAbc
->
pGia
,
DelayMax
,
fVerbose
);
return
0
;
}
if
(
Gia_ManLutSizeMax
(
pAbc
->
pGia
)
>
6
)
if
(
Gia_ManLutSizeMax
(
pAbc
->
pGia
)
>
6
)
{
{
Abc_Print
(
0
,
"Current AIG has mapping into %d-LUTs.
\n
"
,
Gia_ManLutSizeMax
(
pAbc
->
pGia
)
);
Abc_Print
(
0
,
"Current AIG has mapping into %d-LUTs.
\n
"
,
Gia_ManLutSizeMax
(
pAbc
->
pGia
)
);
...
@@ -35333,8 +35345,9 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -35333,8 +35345,9 @@ int Abc_CommandAbc9Edge( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
return
0
;
usage:
usage:
Abc_Print
(
-
2
,
"usage: &edge [-
DFE num] [-rpom
vh]
\n
"
);
Abc_Print
(
-
2
,
"usage: &edge [-
CDFE num] [-rpomd
vh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
find edge assignment of the LUT-mapped network
\n
"
);
Abc_Print
(
-
2
,
"
\t
find edge assignment of the LUT-mapped network
\n
"
);
Abc_Print
(
-
2
,
"
\t
-C num : the SAT solver conflict limit (0 = unused) [default = %d]
\n
"
,
nBTLimit
);
Abc_Print
(
-
2
,
"
\t
-D num : the upper bound on delay [default = %d]
\n
"
,
DelayMax
);
Abc_Print
(
-
2
,
"
\t
-D num : the upper bound on delay [default = %d]
\n
"
,
DelayMax
);
Abc_Print
(
-
2
,
"
\t
-F num : skip using edge if fanout higher than this [default = %d]
\n
"
,
nFanouts
);
Abc_Print
(
-
2
,
"
\t
-F num : skip using edge if fanout higher than this [default = %d]
\n
"
,
nFanouts
);
Abc_Print
(
-
2
,
"
\t
-E num : the limit on the number of edges (1 <= num <= 2) [default = %d]
\n
"
,
nEdges
);
Abc_Print
(
-
2
,
"
\t
-E num : the limit on the number of edges (1 <= num <= 2) [default = %d]
\n
"
,
nEdges
);
...
@@ -35342,6 +35355,7 @@ usage:
...
@@ -35342,6 +35355,7 @@ usage:
Abc_Print
(
-
2
,
"
\t
-p : toggles deriving edges from packing [default = %s]
\n
"
,
fUsePack
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-p : toggles deriving edges from packing [default = %s]
\n
"
,
fUsePack
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-o : toggles using old algorithm [default = %s]
\n
"
,
fUseOld
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-o : toggles using old algorithm [default = %s]
\n
"
,
fUseOld
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-m : toggles combining edge assignment with mapping [default = %s]
\n
"
,
fMapping
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-m : toggles combining edge assignment with mapping [default = %s]
\n
"
,
fMapping
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-d : toggles dynamic addition of clauses [default = %s]
\n
"
,
fDynamic
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-v : toggles verbose output [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-v : toggles verbose output [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : prints the command usage
\n
"
);
Abc_Print
(
-
2
,
"
\t
-h : prints the command usage
\n
"
);
return
1
;
return
1
;
...
@@ -35505,6 +35519,8 @@ int Abc_CommandAbc9Unmap( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -35505,6 +35519,8 @@ int Abc_CommandAbc9Unmap( Abc_Frame_t * pAbc, int argc, char ** argv )
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vMapping
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vMapping
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vPacking
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vPacking
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vCellMapping
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vCellMapping
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vEdge1
);
Vec_IntFreeP
(
&
pAbc
->
pGia
->
vEdge2
);
return
0
;
return
0
;
usage:
usage:
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