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
5b9e520c
Commit
5b9e520c
authored
8 years ago
by
Mathias Soeken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfixes in exact synthesis.
parent
d3ec4493
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
20 deletions
+60
-20
src/base/abci/abcExact.c
+60
-20
No files found.
src/base/abci/abcExact.c
View file @
5b9e520c
...
@@ -165,6 +165,14 @@ static int Abc_NormalizeArrivalTimes( int * pArrTimeProfile, int nVars, int * ma
...
@@ -165,6 +165,14 @@ static int Abc_NormalizeArrivalTimes( int * pArrTimeProfile, int nVars, int * ma
return
delta
;
return
delta
;
}
}
static
inline
void
Abc_UnnormalizeArrivalTimes
(
int
*
pArrTimeProfile
,
int
nVars
,
int
nDelta
)
{
int
l
;
for
(
l
=
0
;
l
<
nVars
;
++
l
)
pArrTimeProfile
[
l
]
+=
nDelta
;
}
static
inline
Ses_Store_t
*
Ses_StoreAlloc
(
int
nBTLimit
,
int
fMakeAIG
,
int
fVerbose
)
static
inline
Ses_Store_t
*
Ses_StoreAlloc
(
int
nBTLimit
,
int
fMakeAIG
,
int
fVerbose
)
{
{
Ses_Store_t
*
pStore
=
ABC_CALLOC
(
Ses_Store_t
,
1
);
Ses_Store_t
*
pStore
=
ABC_CALLOC
(
Ses_Store_t
,
1
);
...
@@ -262,12 +270,10 @@ static inline void Ses_StoreTimesCopy( int * pTimesDest, int * pTimesSrc, int nV
...
@@ -262,12 +270,10 @@ static inline void Ses_StoreTimesCopy( int * pTimesDest, int * pTimesSrc, int nV
// returns 1 if and only if a new TimesEntry has been created
// returns 1 if and only if a new TimesEntry has been created
int
Ses_StoreAddEntry
(
Ses_Store_t
*
pStore
,
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
,
char
*
pSol
)
int
Ses_StoreAddEntry
(
Ses_Store_t
*
pStore
,
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
,
char
*
pSol
)
{
{
int
i
,
nDelta
,
maxNormalized
,
key
,
fAdded
;
int
key
,
fAdded
;
Ses_TruthEntry_t
*
pTEntry
;
Ses_TruthEntry_t
*
pTEntry
;
Ses_TimesEntry_t
*
pTiEntry
;
Ses_TimesEntry_t
*
pTiEntry
;
nDelta
=
Abc_NormalizeArrivalTimes
(
pArrTimeProfile
,
nVars
,
&
maxNormalized
);
key
=
Ses_StoreTableHash
(
pTruth
,
nVars
);
key
=
Ses_StoreTableHash
(
pTruth
,
nVars
);
pTEntry
=
pStore
->
pEntries
[
key
];
pTEntry
=
pStore
->
pEntries
[
key
];
...
@@ -316,8 +322,6 @@ int Ses_StoreAddEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int * pAr
...
@@ -316,8 +322,6 @@ int Ses_StoreAddEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int * pAr
/* item was already present */
/* item was already present */
fAdded
=
0
;
fAdded
=
0
;
for
(
i
=
0
;
i
<
nVars
;
++
i
)
pArrTimeProfile
[
i
]
+=
nDelta
;
return
fAdded
;
return
fAdded
;
}
}
...
@@ -325,7 +329,7 @@ int Ses_StoreAddEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int * pAr
...
@@ -325,7 +329,7 @@ int Ses_StoreAddEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int * pAr
// returns 0 if no solution was found
// returns 0 if no solution was found
char
*
Ses_StoreGetEntry
(
Ses_Store_t
*
pStore
,
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
)
char
*
Ses_StoreGetEntry
(
Ses_Store_t
*
pStore
,
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
)
{
{
int
i
,
nDelta
,
maxNormalized
,
key
;
int
key
;
Ses_TruthEntry_t
*
pTEntry
;
Ses_TruthEntry_t
*
pTEntry
;
Ses_TimesEntry_t
*
pTiEntry
;
Ses_TimesEntry_t
*
pTiEntry
;
...
@@ -345,8 +349,6 @@ char * Ses_StoreGetEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int *
...
@@ -345,8 +349,6 @@ char * Ses_StoreGetEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int *
if
(
!
pTEntry
)
if
(
!
pTEntry
)
return
0
;
return
0
;
nDelta
=
Abc_NormalizeArrivalTimes
(
pArrTimeProfile
,
nVars
,
&
maxNormalized
);
/* find times entry */
/* find times entry */
pTiEntry
=
pTEntry
->
head
;
pTiEntry
=
pTEntry
->
head
;
while
(
pTiEntry
)
while
(
pTiEntry
)
...
@@ -357,9 +359,6 @@ char * Ses_StoreGetEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int *
...
@@ -357,9 +359,6 @@ char * Ses_StoreGetEntry( Ses_Store_t * pStore, word * pTruth, int nVars, int *
pTiEntry
=
pTiEntry
->
next
;
pTiEntry
=
pTiEntry
->
next
;
}
}
for
(
i
=
0
;
i
<
nVars
;
++
i
)
pArrTimeProfile
[
i
]
+=
nDelta
;
/* no entry found? */
/* no entry found? */
if
(
!
pTiEntry
)
if
(
!
pTiEntry
)
return
0
;
return
0
;
...
@@ -738,7 +737,7 @@ static int Ses_ManCreateClauses( Ses_Man_t * pSes )
...
@@ -738,7 +737,7 @@ static int Ses_ManCreateClauses( Ses_Man_t * pSes )
}
}
/* EXTRA clauses: symmetric variables */
/* EXTRA clauses: symmetric variables */
if
(
pSes
->
nSpecFunc
==
1
)
/* only check if there is one output function */
if
(
pSes
->
n
MaxDepth
==
-
1
&&
pSes
->
n
SpecFunc
==
1
)
/* only check if there is one output function */
for
(
q
=
1
;
q
<
pSes
->
nSpecVars
;
++
q
)
for
(
q
=
1
;
q
<
pSes
->
nSpecVars
;
++
q
)
for
(
p
=
0
;
p
<
q
;
++
p
)
for
(
p
=
0
;
p
<
q
;
++
p
)
if
(
Extra_TruthVarsSymm
(
(
unsigned
*
)(
&
pSes
->
pSpec
[
h
<<
2
]
),
pSes
->
nSpecVars
,
p
,
q
)
)
if
(
Extra_TruthVarsSymm
(
(
unsigned
*
)(
&
pSes
->
pSpec
[
h
<<
2
]
),
pSes
->
nSpecVars
,
p
,
q
)
)
...
@@ -982,16 +981,18 @@ static char * Ses_ManExtractSolution( Ses_Man_t * pSes )
...
@@ -982,16 +981,18 @@ static char * Ses_ManExtractSolution( Ses_Man_t * pSes )
*
p
++
=
Abc_Var2Lit
(
i
,
(
pSes
->
bSpecInv
>>
h
)
&
1
);
*
p
++
=
Abc_Var2Lit
(
i
,
(
pSes
->
bSpecInv
>>
h
)
&
1
);
d
=
0
;
d
=
0
;
if
(
pSes
->
nMaxDepth
!=
-
1
)
if
(
pSes
->
nMaxDepth
!=
-
1
)
while
(
d
<
pSes
->
nArrTimeMax
+
i
&&
sat_solver_var_value
(
pSes
->
pSat
,
Ses_ManDepthVar
(
pSes
,
i
,
d
)
)
)
/* while ( d < pSes->nArrTimeMax + i && sat_solver_var_value( pSes->pSat, Ses_ManDepthVar( pSes, i, d ) ) ) */
++
d
;
/* ++d; */
*
p
++
=
d
+
pSes
->
nArrTimeDelta
;
for
(
l
=
0
;
l
<
pSes
->
nSpecVars
;
++
l
)
d
=
Abc_MaxInt
(
d
,
pSes
->
pArrTimeProfile
[
l
]
+
pPerm
[
i
*
pSes
->
nSpecVars
+
l
]
);
*
p
++
=
d
;
if
(
pSes
->
fVeryVerbose
)
if
(
pSes
->
fVeryVerbose
)
printf
(
"output %d points to %d and has normalized delay %d
\n
"
,
h
,
i
,
d
);
printf
(
"output %d points to %d and has normalized delay %d
(nArrTimeDelta = %d)
\n
"
,
h
,
i
,
d
,
pSes
->
nArrTimeDelta
);
for
(
l
=
0
;
l
<
pSes
->
nSpecVars
;
++
l
)
for
(
l
=
0
;
l
<
pSes
->
nSpecVars
;
++
l
)
{
{
d
=
(
pSes
->
nMaxDepth
!=
-
1
)
?
pPerm
[
i
*
pSes
->
nSpecVars
+
l
]
:
0
;
d
=
(
pSes
->
nMaxDepth
!=
-
1
)
?
pPerm
[
i
*
pSes
->
nSpecVars
+
l
]
:
0
;
if
(
pSes
->
fVeryVerbose
)
if
(
pSes
->
fVeryVerbose
)
printf
(
" pin-to-pin arrival time from input %d is %d
\n
"
,
l
,
d
);
printf
(
" pin-to-pin arrival time from input %d is %d
(pArrTimeProfile = %d)
\n
"
,
l
,
d
,
pSes
->
pArrTimeProfile
[
l
]
);
*
p
++
=
d
;
*
p
++
=
d
;
}
}
}
}
...
@@ -1494,7 +1495,7 @@ void Abc_ExactStats()
...
@@ -1494,7 +1495,7 @@ void Abc_ExactStats()
// the area cost should not exceed 2048, if the cut is implementable; otherwise, it should be ABC_INFINITY
// the area cost should not exceed 2048, if the cut is implementable; otherwise, it should be ABC_INFINITY
int
Abc_ExactDelayCost
(
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
,
char
*
pPerm
,
int
*
Cost
,
int
AigLevel
)
int
Abc_ExactDelayCost
(
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
,
char
*
pPerm
,
int
*
Cost
,
int
AigLevel
)
{
{
int
i
,
l
,
fExists
=
0
;
int
i
,
nDelta
,
nMaxArrival
,
l
,
fExists
=
0
;
Ses_Man_t
*
pSes
=
NULL
;
Ses_Man_t
*
pSes
=
NULL
;
char
*
pSol
=
NULL
,
*
p
;
char
*
pSol
=
NULL
,
*
p
;
int
Delay
=
ABC_INFINITY
,
nMaxDepth
;
int
Delay
=
ABC_INFINITY
,
nMaxDepth
;
...
@@ -1520,6 +1521,18 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
...
@@ -1520,6 +1521,18 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
return
pArrTimeProfile
[
0
];
return
pArrTimeProfile
[
0
];
}
}
nDelta
=
Abc_NormalizeArrivalTimes
(
pArrTimeProfile
,
nVars
,
&
nMaxArrival
);
if
(
s_pSesStore
->
fVerbose
)
{
printf
(
"compute delay for nontrivial truth table "
);
Abc_TtPrintHexRev
(
stdout
,
pTruth
,
nVars
);
printf
(
" with arrival times"
);
for
(
l
=
0
;
l
<
nVars
;
++
l
)
printf
(
" %d"
,
pArrTimeProfile
[
l
]
);
printf
(
"
\n
"
);
}
/* statistics */
/* statistics */
s_pSesStore
->
nCutCount
++
;
s_pSesStore
->
nCutCount
++
;
s_pSesStore
->
pCutCount
[
nVars
]
++
;
s_pSesStore
->
pCutCount
[
nVars
]
++
;
...
@@ -1527,6 +1540,8 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
...
@@ -1527,6 +1540,8 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
pSol
=
Ses_StoreGetEntry
(
s_pSesStore
,
pTruth
,
nVars
,
pArrTimeProfile
);
pSol
=
Ses_StoreGetEntry
(
s_pSesStore
,
pTruth
,
nVars
,
pArrTimeProfile
);
if
(
pSol
)
if
(
pSol
)
{
{
if
(
s_pSesStore
->
fVerbose
)
printf
(
" truth table already in store
\n
"
);
s_pSesStore
->
nCacheHit
++
;
s_pSesStore
->
nCacheHit
++
;
fExists
=
1
;
fExists
=
1
;
}
}
...
@@ -1543,6 +1558,7 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
...
@@ -1543,6 +1558,7 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
pSes
=
Ses_ManAlloc
(
pTruth
,
nVars
,
1
/* fSpecFunc */
,
nMaxDepth
,
pArrTimeProfile
,
s_pSesStore
->
fMakeAIG
,
s_pSesStore
->
fVerbose
);
pSes
=
Ses_ManAlloc
(
pTruth
,
nVars
,
1
/* fSpecFunc */
,
nMaxDepth
,
pArrTimeProfile
,
s_pSesStore
->
fMakeAIG
,
s_pSesStore
->
fVerbose
);
pSes
->
nBTLimit
=
s_pSesStore
->
nBTLimit
;
pSes
->
nBTLimit
=
s_pSesStore
->
nBTLimit
;
pSes
->
fVeryVerbose
=
0
;
while
(
1
)
/* there is improvement */
while
(
1
)
/* there is improvement */
{
{
...
@@ -1576,14 +1592,36 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
...
@@ -1576,14 +1592,36 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char *
Ses_StoreAddEntry
(
s_pSesStore
,
pTruth
,
nVars
,
pArrTimeProfile
,
pSol
);
Ses_StoreAddEntry
(
s_pSesStore
,
pTruth
,
nVars
,
pArrTimeProfile
,
pSol
);
}
}
return
Delay
;
//for ( l = 0; l < nVars; ++l )
// printf( "pArrTimeProfile[%d] = %d\n", l, pArrTimeProfile[l] );
if
(
pSol
)
{
int
Delay2
=
0
;
for
(
l
=
0
;
l
<
nVars
;
++
l
)
{
//printf( "%d ", pPerm[l] );
Delay2
=
Abc_MaxInt
(
Delay2
,
pArrTimeProfile
[
l
]
+
pPerm
[
l
]
);
}
//printf( " output arrival = %d recomputed = %d\n", Delay, Delay2 );
if
(
Delay
!=
Delay2
)
{
printf
(
"^--- BUG!
\n
"
);
assert
(
0
);
}
//Delay = Delay2;
}
Abc_UnnormalizeArrivalTimes
(
pArrTimeProfile
,
nVars
,
nDelta
);
return
nDelta
+
Delay
;
}
}
// this procedure returns a new node whose output in terms of the given fanins
// this procedure returns a new node whose output in terms of the given fanins
// has the smallest possible arrival time (in agreement with the above Abc_ExactDelayCost)
// has the smallest possible arrival time (in agreement with the above Abc_ExactDelayCost)
Abc_Obj_t
*
Abc_ExactBuildNode
(
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
,
Abc_Obj_t
**
pFanins
,
Abc_Ntk_t
*
pNtk
)
Abc_Obj_t
*
Abc_ExactBuildNode
(
word
*
pTruth
,
int
nVars
,
int
*
pArrTimeProfile
,
Abc_Obj_t
**
pFanins
,
Abc_Ntk_t
*
pNtk
)
{
{
char
*
pSol
;
char
*
pSol
;
int
i
,
j
;
int
i
,
j
,
nDelta
,
nMaxArrival
;
char
const
*
p
;
char
const
*
p
;
Abc_Obj_t
*
pObj
;
Abc_Obj_t
*
pObj
;
Vec_Ptr_t
*
pGates
;
Vec_Ptr_t
*
pGates
;
...
@@ -1595,7 +1633,9 @@ Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile,
...
@@ -1595,7 +1633,9 @@ Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile,
if
(
nVars
==
1
)
if
(
nVars
==
1
)
return
(
pTruth
[
0
]
&
1
)
?
Abc_NtkCreateNodeInv
(
pNtk
,
pFanins
[
0
])
:
Abc_NtkCreateNodeBuf
(
pNtk
,
pFanins
[
0
]);
return
(
pTruth
[
0
]
&
1
)
?
Abc_NtkCreateNodeInv
(
pNtk
,
pFanins
[
0
])
:
Abc_NtkCreateNodeBuf
(
pNtk
,
pFanins
[
0
]);
nDelta
=
Abc_NormalizeArrivalTimes
(
pArrTimeProfile
,
nVars
,
&
nMaxArrival
);
pSol
=
Ses_StoreGetEntry
(
s_pSesStore
,
pTruth
,
nVars
,
pArrTimeProfile
);
pSol
=
Ses_StoreGetEntry
(
s_pSesStore
,
pTruth
,
nVars
,
pArrTimeProfile
);
Abc_UnnormalizeArrivalTimes
(
pArrTimeProfile
,
nVars
,
nDelta
);
if
(
!
pSol
)
if
(
!
pSol
)
return
NULL
;
return
NULL
;
...
...
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