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
4488ab83
Commit
4488ab83
authored
Dec 29, 2016
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates to delay optimization project.
parent
fdd8404b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
26 deletions
+77
-26
src/opt/sbd/sbdCore.c
+0
-0
src/opt/sbd/sbdCut.c
+68
-24
src/opt/sbd/sbdInt.h
+3
-1
src/sat/bsat/satSolver.h
+6
-1
No files found.
src/opt/sbd/sbdCore.c
View file @
4488ab83
This diff is collapsed.
Click to expand it.
src/opt/sbd/sbdCut.c
View file @
4488ab83
...
@@ -40,9 +40,9 @@ struct Sbd_Cut_t_
...
@@ -40,9 +40,9 @@ struct Sbd_Cut_t_
int
iFunc
;
// functionality
int
iFunc
;
// functionality
int
Cost
;
// cut cost
int
Cost
;
// cut cost
int
CostLev
;
// cut cost
int
CostLev
;
// cut cost
unsigned
fSpec
:
1
;
// special cut
unsigned
nSlowLeaves
:
14
;
// slow leaves
unsigned
nTreeLeaves
:
27
;
// cut cost
unsigned
nTreeLeaves
:
14
;
// tree leaves
unsigned
nLeaves
:
4
;
//
the number of leaves
unsigned
nLeaves
:
4
;
//
leaf count
int
pLeaves
[
SBD_MAX_CUTSIZE
];
// leaves
int
pLeaves
[
SBD_MAX_CUTSIZE
];
// leaves
};
};
...
@@ -62,11 +62,13 @@ struct Sbd_Sto_t_
...
@@ -62,11 +62,13 @@ struct Sbd_Sto_t_
Vec_Mem_t
*
vTtMem
;
// truth tables
Vec_Mem_t
*
vTtMem
;
// truth tables
Sbd_Cut_t
pCuts
[
3
][
SBD_MAX_CUTNUM
];
// temporary cuts
Sbd_Cut_t
pCuts
[
3
][
SBD_MAX_CUTNUM
];
// temporary cuts
Sbd_Cut_t
*
ppCuts
[
SBD_MAX_CUTNUM
];
// temporary cut pointers
Sbd_Cut_t
*
ppCuts
[
SBD_MAX_CUTNUM
];
// temporary cut pointers
abctime
clkStart
;
// starting time
int
nCutsR
;
// the number of cuts
int
Pivot
;
// current object
double
CutCount
[
4
];
// cut counters
double
CutCount
[
4
];
// cut counters
int
nCutsSpec
;
// special cuts
int
nCutsSpec
;
// special cuts
int
nCutsOver
;
// overflow cuts
int
nCutsOver
;
// overflow cuts
int
DelayMin
;
// minimum delay
int
DelayMin
;
// minimum delay
abctime
clkStart
;
// starting time
};
};
static
inline
word
*
Sbd_CutTruth
(
Sbd_Sto_t
*
p
,
Sbd_Cut_t
*
pCut
)
{
return
Vec_MemReadEntry
(
p
->
vTtMem
,
Abc_Lit2Var
(
pCut
->
iFunc
));
}
static
inline
word
*
Sbd_CutTruth
(
Sbd_Sto_t
*
p
,
Sbd_Cut_t
*
pCut
)
{
return
Vec_MemReadEntry
(
p
->
vTtMem
,
Abc_Lit2Var
(
pCut
->
iFunc
));
}
...
@@ -309,6 +311,22 @@ static inline int Sbd_CutCompare( Sbd_Cut_t * pCut0, Sbd_Cut_t * pCut1 )
...
@@ -309,6 +311,22 @@ static inline int Sbd_CutCompare( Sbd_Cut_t * pCut0, Sbd_Cut_t * pCut1 )
}
}
return
0
;
return
0
;
}
}
static
inline
int
Sbd_CutCompare2
(
Sbd_Cut_t
*
pCut0
,
Sbd_Cut_t
*
pCut1
)
{
assert
(
pCut0
->
nLeaves
>
4
&&
pCut1
->
nLeaves
>
4
);
if
(
pCut0
->
nSlowLeaves
<
pCut1
->
nSlowLeaves
)
return
-
1
;
if
(
pCut0
->
nSlowLeaves
>
pCut1
->
nSlowLeaves
)
return
1
;
if
(
pCut0
->
nTreeLeaves
<
pCut1
->
nTreeLeaves
)
return
-
1
;
if
(
pCut0
->
nTreeLeaves
>
pCut1
->
nTreeLeaves
)
return
1
;
if
(
pCut0
->
Cost
<
pCut1
->
Cost
)
return
-
1
;
if
(
pCut0
->
Cost
>
pCut1
->
Cost
)
return
1
;
if
(
pCut0
->
CostLev
<
pCut1
->
CostLev
)
return
-
1
;
if
(
pCut0
->
CostLev
>
pCut1
->
CostLev
)
return
1
;
if
(
pCut0
->
nLeaves
<
pCut1
->
nLeaves
)
return
-
1
;
if
(
pCut0
->
nLeaves
>
pCut1
->
nLeaves
)
return
1
;
return
0
;
}
static
inline
int
Sbd_CutSetLastCutContains
(
Sbd_Cut_t
**
pCuts
,
int
nCuts
)
static
inline
int
Sbd_CutSetLastCutContains
(
Sbd_Cut_t
**
pCuts
,
int
nCuts
)
{
{
int
i
,
k
,
fChanges
=
0
;
int
i
,
k
,
fChanges
=
0
;
...
@@ -424,12 +442,12 @@ static inline int Sbd_CutCountBits( word i )
...
@@ -424,12 +442,12 @@ static inline int Sbd_CutCountBits( word i )
i
=
((
i
+
(
i
>>
4
))
&
0x0F0F0F0F0F0F0F0F
);
i
=
((
i
+
(
i
>>
4
))
&
0x0F0F0F0F0F0F0F0F
);
return
(
i
*
(
0x0101010101010101
))
>>
56
;
return
(
i
*
(
0x0101010101010101
))
>>
56
;
}
}
static
inline
int
Sbd_Cut
IsSpec
(
Sbd_Sto_t
*
p
,
int
iObj
,
Sbd_Cut_t
*
pCut
)
static
inline
int
Sbd_Cut
SlowLeaves
(
Sbd_Sto_t
*
p
,
int
iObj
,
Sbd_Cut_t
*
pCut
)
{
{
int
i
,
Delay
=
Vec_IntEntry
(
p
->
vDelays
,
iObj
),
DelayMax
=
-
ABC_INFINITY
;
int
i
,
Count
=
0
,
Delay
=
Vec_IntEntry
(
p
->
vDelays
,
iObj
)
;
for
(
i
=
0
;
i
<
(
int
)
pCut
->
nLeaves
;
i
++
)
for
(
i
=
0
;
i
<
(
int
)
pCut
->
nLeaves
;
i
++
)
DelayMax
=
Abc_MaxInt
(
DelayMax
,
Vec_IntEntry
(
p
->
vDelays
,
pCut
->
pLeaves
[
i
])
-
Delay
);
Count
+=
(
Vec_IntEntry
(
p
->
vDelays
,
pCut
->
pLeaves
[
i
])
-
Delay
>=
-
1
);
return
DelayMax
<
-
1
;
return
Count
;
}
}
static
inline
int
Sbd_CutCost
(
Sbd_Sto_t
*
p
,
Sbd_Cut_t
*
pCut
)
static
inline
int
Sbd_CutCost
(
Sbd_Sto_t
*
p
,
Sbd_Cut_t
*
pCut
)
{
{
...
@@ -475,9 +493,9 @@ static inline int Sbd_StoPrepareSet( Sbd_Sto_t * p, int iObj, int Index )
...
@@ -475,9 +493,9 @@ static inline int Sbd_StoPrepareSet( Sbd_Sto_t * p, int iObj, int Index )
pCutTemp
->
pLeaves
[
v
-
1
]
=
pCut
[
v
];
pCutTemp
->
pLeaves
[
v
-
1
]
=
pCut
[
v
];
pCutTemp
->
iFunc
=
pCut
[
pCut
[
0
]
+
1
];
pCutTemp
->
iFunc
=
pCut
[
pCut
[
0
]
+
1
];
pCutTemp
->
Sign
=
Sbd_CutGetSign
(
pCutTemp
);
pCutTemp
->
Sign
=
Sbd_CutGetSign
(
pCutTemp
);
pCutTemp
->
fSpec
=
Sbd_CutIsSpec
(
p
,
iObj
,
pCutTemp
);
pCutTemp
->
Cost
=
Sbd_CutCost
(
p
,
pCutTemp
);
pCutTemp
->
Cost
=
Sbd_CutCost
(
p
,
pCutTemp
);
pCutTemp
->
CostLev
=
Sbd_CutCostLev
(
p
,
pCutTemp
);
pCutTemp
->
CostLev
=
Sbd_CutCostLev
(
p
,
pCutTemp
);
pCutTemp
->
nSlowLeaves
=
Sbd_CutSlowLeaves
(
p
,
iObj
,
pCutTemp
);
pCutTemp
->
nTreeLeaves
=
Sbd_CutTreeLeaves
(
p
,
pCutTemp
);
pCutTemp
->
nTreeLeaves
=
Sbd_CutTreeLeaves
(
p
,
pCutTemp
);
}
}
return
pList
[
0
];
return
pList
[
0
];
...
@@ -524,8 +542,8 @@ static inline void Sbd_StoComputeSpec( Sbd_Sto_t * p, int iObj, Sbd_Cut_t ** pCu
...
@@ -524,8 +542,8 @@ static inline void Sbd_StoComputeSpec( Sbd_Sto_t * p, int iObj, Sbd_Cut_t ** pCu
int
i
;
int
i
;
for
(
i
=
0
;
i
<
nCuts
;
i
++
)
for
(
i
=
0
;
i
<
nCuts
;
i
++
)
{
{
pCuts
[
i
]
->
fSpec
=
Sbd_CutIsSpec
(
p
,
iObj
,
pCuts
[
i
]
);
pCuts
[
i
]
->
nSlowLeaves
=
Sbd_CutSlowLeaves
(
p
,
iObj
,
pCuts
[
i
]
);
p
->
nCutsSpec
+=
pCuts
[
i
]
->
fSpec
;
p
->
nCutsSpec
+=
(
pCuts
[
i
]
->
nSlowLeaves
==
0
)
;
}
}
}
}
static
inline
void
Sbd_CutPrint
(
Sbd_Sto_t
*
p
,
int
iObj
,
Sbd_Cut_t
*
pCut
)
static
inline
void
Sbd_CutPrint
(
Sbd_Sto_t
*
p
,
int
iObj
,
Sbd_Cut_t
*
pCut
)
...
@@ -537,8 +555,9 @@ static inline void Sbd_CutPrint( Sbd_Sto_t * p, int iObj, Sbd_Cut_t * pCut )
...
@@ -537,8 +555,9 @@ static inline void Sbd_CutPrint( Sbd_Sto_t * p, int iObj, Sbd_Cut_t * pCut )
printf
(
" %*d"
,
nDigits
,
pCut
->
pLeaves
[
i
]
);
printf
(
" %*d"
,
nDigits
,
pCut
->
pLeaves
[
i
]
);
for
(
;
i
<
(
int
)
p
->
nCutSize
;
i
++
)
for
(
;
i
<
(
int
)
p
->
nCutSize
;
i
++
)
printf
(
" %*s"
,
nDigits
,
" "
);
printf
(
" %*s"
,
nDigits
,
" "
);
printf
(
" } Cost = %4d CostLev = %4d Tree = %2d "
,
pCut
->
Cost
,
pCut
->
CostLev
,
pCut
->
nTreeLeaves
);
printf
(
" } Cost = %3d CostL = %3d Slow = %d Tree = %d "
,
printf
(
"%c "
,
pCut
->
fSpec
?
'*'
:
' '
);
pCut
->
Cost
,
pCut
->
CostLev
,
pCut
->
nSlowLeaves
,
pCut
->
nTreeLeaves
);
printf
(
"%c "
,
pCut
->
nSlowLeaves
==
0
?
'*'
:
' '
);
for
(
i
=
0
;
i
<
(
int
)
pCut
->
nLeaves
;
i
++
)
for
(
i
=
0
;
i
<
(
int
)
pCut
->
nLeaves
;
i
++
)
printf
(
"%3d "
,
Vec_IntEntry
(
p
->
vDelays
,
pCut
->
pLeaves
[
i
])
-
Delay
);
printf
(
"%3d "
,
Vec_IntEntry
(
p
->
vDelays
,
pCut
->
pLeaves
[
i
])
-
Delay
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -585,12 +604,14 @@ void Sbd_StoMergeCuts( Sbd_Sto_t * p, int iObj )
...
@@ -585,12 +604,14 @@ void Sbd_StoMergeCuts( Sbd_Sto_t * p, int iObj )
Sbd_StoComputeSpec
(
p
,
iObj
,
pCutsR
,
nCutsR
);
Sbd_StoComputeSpec
(
p
,
iObj
,
pCutsR
,
nCutsR
);
p
->
CutCount
[
3
]
+=
nCutsR
;
p
->
CutCount
[
3
]
+=
nCutsR
;
p
->
nCutsOver
+=
nCutsR
==
nCutNum
-
1
;
p
->
nCutsOver
+=
nCutsR
==
nCutNum
-
1
;
p
->
nCutsR
=
nCutsR
;
p
->
Pivot
=
iObj
;
// debug printout
// debug printout
if
(
0
)
if
(
1
)
{
{
printf
(
"*** Obj = %4d Delay = %4d NumCuts = %4d
\n
"
,
iObj
,
Vec_IntEntry
(
p
->
vDelays
,
iObj
),
nCutsR
);
printf
(
"*** Obj = %4d Delay = %4d NumCuts = %4d
\n
"
,
iObj
,
Vec_IntEntry
(
p
->
vDelays
,
iObj
),
nCutsR
);
for
(
i
=
0
;
i
<
nCutsR
;
i
++
)
for
(
i
=
0
;
i
<
nCutsR
;
i
++
)
if
(
(
int
)
pCutsR
[
i
]
->
nLeaves
<=
p
->
nLutSize
||
pCutsR
[
i
]
->
fSpec
)
if
(
(
int
)
pCutsR
[
i
]
->
nLeaves
<=
p
->
nLutSize
||
pCutsR
[
i
]
->
nSlowLeaves
<
2
)
Sbd_CutPrint
(
p
,
iObj
,
pCutsR
[
i
]
);
Sbd_CutPrint
(
p
,
iObj
,
pCutsR
[
i
]
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -630,10 +651,10 @@ Sbd_Sto_t * Sbd_StoAlloc( Gia_Man_t * pGia, Vec_Int_t * vMirrors, int nLutSize,
...
@@ -630,10 +651,10 @@ Sbd_Sto_t * Sbd_StoAlloc( Gia_Man_t * pGia, Vec_Int_t * vMirrors, int nLutSize,
p
->
fVerbose
=
fVerbose
;
p
->
fVerbose
=
fVerbose
;
p
->
pGia
=
pGia
;
p
->
pGia
=
pGia
;
p
->
vMirrors
=
vMirrors
;
p
->
vMirrors
=
vMirrors
;
p
->
vDelays
=
Vec_Int
Alloc
(
Gia_ManObjNum
(
pGia
)
);
p
->
vDelays
=
Vec_Int
Start
(
Gia_ManObjNum
(
pGia
)
);
p
->
vLevels
=
Vec_Int
Alloc
(
Gia_ManObjNum
(
pGia
)
);
p
->
vLevels
=
Vec_Int
Start
(
Gia_ManObjNum
(
pGia
)
);
p
->
vRefs
=
Vec_IntAlloc
(
Gia_ManObjNum
(
pGia
)
);
p
->
vRefs
=
Vec_IntAlloc
(
Gia_ManObjNum
(
pGia
)
);
p
->
vCuts
=
Vec_Wec
Alloc
(
Gia_ManObjNum
(
pGia
)
);
p
->
vCuts
=
Vec_Wec
Start
(
Gia_ManObjNum
(
pGia
)
);
p
->
vTtMem
=
fCutMin
?
Vec_MemAllocForTT
(
nCutSize
,
0
)
:
NULL
;
p
->
vTtMem
=
fCutMin
?
Vec_MemAllocForTT
(
nCutSize
,
0
)
:
NULL
;
return
p
;
return
p
;
}
}
...
@@ -651,12 +672,20 @@ void Sbd_StoFree( Sbd_Sto_t * p )
...
@@ -651,12 +672,20 @@ void Sbd_StoFree( Sbd_Sto_t * p )
}
}
void
Sbd_StoComputeCutsObj
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
)
void
Sbd_StoComputeCutsObj
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
)
{
{
assert
(
iObj
==
Vec_IntSize
(
p
->
vDelays
)
);
if
(
iObj
<
Vec_IntSize
(
p
->
vDelays
)
)
assert
(
iObj
==
Vec_IntSize
(
p
->
vLevels
)
);
{
assert
(
iObj
==
Vec_WecSize
(
p
->
vCuts
)
);
Vec_IntWriteEntry
(
p
->
vDelays
,
iObj
,
Delay
);
Vec_IntPush
(
p
->
vDelays
,
Delay
);
Vec_IntWriteEntry
(
p
->
vLevels
,
iObj
,
Level
);
Vec_IntPush
(
p
->
vLevels
,
Level
);
}
Vec_WecPushLevel
(
p
->
vCuts
);
else
{
assert
(
iObj
==
Vec_IntSize
(
p
->
vDelays
)
);
assert
(
iObj
==
Vec_IntSize
(
p
->
vLevels
)
);
assert
(
iObj
==
Vec_WecSize
(
p
->
vCuts
)
);
Vec_IntPush
(
p
->
vDelays
,
Delay
);
Vec_IntPush
(
p
->
vLevels
,
Level
);
Vec_WecPushLevel
(
p
->
vCuts
);
}
}
}
void
Sbd_StoComputeCutsCi
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
)
void
Sbd_StoComputeCutsCi
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
)
{
{
...
@@ -698,6 +727,21 @@ void Sbd_StoDerefObj( Sbd_Sto_t * p, int iObj )
...
@@ -698,6 +727,21 @@ void Sbd_StoDerefObj( Sbd_Sto_t * p, int iObj )
Sbd_StoDerefObj
(
p
,
Gia_ObjFaninId0
(
pObj
,
iObj
)
);
Sbd_StoDerefObj
(
p
,
Gia_ObjFaninId0
(
pObj
,
iObj
)
);
Sbd_StoDerefObj
(
p
,
Gia_ObjFaninId1
(
pObj
,
iObj
)
);
Sbd_StoDerefObj
(
p
,
Gia_ObjFaninId1
(
pObj
,
iObj
)
);
}
}
int
Sbd_StoObjBestCut
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
*
pLeaves
)
{
Sbd_Cut_t
*
pCutBest
=
NULL
;
int
i
;
assert
(
p
->
Pivot
==
iObj
);
for
(
i
=
0
;
i
<
p
->
nCutsR
;
i
++
)
{
if
(
(
int
)
p
->
ppCuts
[
i
]
->
nLeaves
>
p
->
nLutSize
&&
(
pCutBest
==
NULL
||
Sbd_CutCompare2
(
pCutBest
,
p
->
ppCuts
[
i
])
==
1
)
)
pCutBest
=
p
->
ppCuts
[
i
];
}
Sbd_CutPrint
(
p
,
iObj
,
pCutBest
);
assert
(
pCutBest
->
nLeaves
<=
SBD_DIV_MAX
);
for
(
i
=
0
;
i
<
(
int
)
pCutBest
->
nLeaves
;
i
++
)
pLeaves
[
i
]
=
pCutBest
->
pLeaves
[
i
];
return
pCutBest
->
nLeaves
;
}
void
Sbd_StoComputeCutsTest
(
Gia_Man_t
*
pGia
)
void
Sbd_StoComputeCutsTest
(
Gia_Man_t
*
pGia
)
{
{
Sbd_Sto_t
*
p
=
Sbd_StoAlloc
(
pGia
,
NULL
,
4
,
8
,
100
,
1
,
1
);
Sbd_Sto_t
*
p
=
Sbd_StoAlloc
(
pGia
,
NULL
,
4
,
8
,
100
,
1
,
1
);
...
...
src/opt/sbd/sbdInt.h
View file @
4488ab83
...
@@ -54,7 +54,7 @@ ABC_NAMESPACE_HEADER_START
...
@@ -54,7 +54,7 @@ ABC_NAMESPACE_HEADER_START
#define SBD_LUTS_MAX 2
#define SBD_LUTS_MAX 2
#define SBD_SIZE_MAX 4
#define SBD_SIZE_MAX 4
#define SBD_DIV_MAX
7
#define SBD_DIV_MAX
8
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
/// BASIC TYPES ///
...
@@ -88,6 +88,8 @@ extern void Sbd_StoDefefObj( Sbd_Sto_t * p, int iObj );
...
@@ -88,6 +88,8 @@ extern void Sbd_StoDefefObj( Sbd_Sto_t * p, int iObj );
extern
void
Sbd_StoComputeCutsObj
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
);
extern
void
Sbd_StoComputeCutsObj
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
);
extern
void
Sbd_StoComputeCutsCi
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
);
extern
void
Sbd_StoComputeCutsCi
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
Delay
,
int
Level
);
extern
int
Sbd_StoComputeCutsNode
(
Sbd_Sto_t
*
p
,
int
iObj
);
extern
int
Sbd_StoComputeCutsNode
(
Sbd_Sto_t
*
p
,
int
iObj
);
extern
int
Sbd_StoObjBestCut
(
Sbd_Sto_t
*
p
,
int
iObj
,
int
*
pLeaves
);
ABC_NAMESPACE_HEADER_END
ABC_NAMESPACE_HEADER_END
...
...
src/sat/bsat/satSolver.h
View file @
4488ab83
...
@@ -229,7 +229,12 @@ static void sat_solver_compress(sat_solver* s)
...
@@ -229,7 +229,12 @@ static void sat_solver_compress(sat_solver* s)
(
void
)
RetValue
;
(
void
)
RetValue
;
}
}
}
}
static
void
sat_solver_delete_p
(
sat_solver
**
ps
)
{
if
(
*
ps
)
sat_solver_delete
(
*
ps
);
*
ps
=
NULL
;
}
static
void
sat_solver_clean_polarity
(
sat_solver
*
s
,
int
*
pVars
,
int
nVars
)
static
void
sat_solver_clean_polarity
(
sat_solver
*
s
,
int
*
pVars
,
int
nVars
)
{
{
int
i
;
int
i
;
...
...
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