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
bf75d7ab
Commit
bf75d7ab
authored
Aug 31, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experimenting with area recovery.
parent
ddf182da
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
134 deletions
+90
-134
src/aig/gia/giaNf.c
+90
-134
No files found.
src/aig/gia/giaNf.c
View file @
bf75d7ab
...
@@ -96,7 +96,6 @@ struct Nf_Man_t_
...
@@ -96,7 +96,6 @@ struct Nf_Man_t_
Vec_Flt_t
vCutFlows
;
// temporary cut area
Vec_Flt_t
vCutFlows
;
// temporary cut area
Vec_Int_t
vCutDelays
;
// temporary cut delay
Vec_Int_t
vCutDelays
;
// temporary cut delay
Vec_Int_t
vBackup
;
// backup literals
Vec_Int_t
vBackup
;
// backup literals
Vec_Int_t
vBackup2
;
// backup literals
int
iCur
;
// current position
int
iCur
;
// current position
int
Iter
;
// mapping iterations
int
Iter
;
// mapping iterations
int
fUseEla
;
// use exact area
int
fUseEla
;
// use exact area
...
@@ -143,7 +142,7 @@ static inline Nf_Mat_t * Nf_ObjMatchBest( Nf_Man_t * p, int i, int c )
...
@@ -143,7 +142,7 @@ static inline Nf_Mat_t * Nf_ObjMatchBest( Nf_Man_t * p, int i, int c )
Nf_Mat_t
*
pD
=
Nf_ObjMatchD
(
p
,
i
,
c
);
Nf_Mat_t
*
pD
=
Nf_ObjMatchD
(
p
,
i
,
c
);
Nf_Mat_t
*
pA
=
Nf_ObjMatchA
(
p
,
i
,
c
);
Nf_Mat_t
*
pA
=
Nf_ObjMatchA
(
p
,
i
,
c
);
assert
(
pD
->
fBest
!=
pA
->
fBest
);
assert
(
pD
->
fBest
!=
pA
->
fBest
);
assert
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
>
0
);
//
assert( Nf_ObjMapRefNum(p, i, c) > 0 );
if
(
pA
->
fBest
)
if
(
pA
->
fBest
)
return
pA
;
return
pA
;
if
(
pD
->
fBest
)
if
(
pD
->
fBest
)
...
@@ -350,7 +349,6 @@ Nf_Man_t * Nf_StoCreate( Gia_Man_t * pGia, Jf_Par_t * pPars )
...
@@ -350,7 +349,6 @@ Nf_Man_t * Nf_StoCreate( Gia_Man_t * pGia, Jf_Par_t * pPars )
Vec_FltFill
(
&
p
->
vCutFlows
,
Gia_ManObjNum
(
pGia
),
0
);
// cut area
Vec_FltFill
(
&
p
->
vCutFlows
,
Gia_ManObjNum
(
pGia
),
0
);
// cut area
Vec_IntFill
(
&
p
->
vCutDelays
,
Gia_ManObjNum
(
pGia
),
0
);
// cut delay
Vec_IntFill
(
&
p
->
vCutDelays
,
Gia_ManObjNum
(
pGia
),
0
);
// cut delay
Vec_IntGrow
(
&
p
->
vBackup
,
1000
);
Vec_IntGrow
(
&
p
->
vBackup
,
1000
);
Vec_IntGrow
(
&
p
->
vBackup2
,
1000
);
// references
// references
vFlowRefs
=
Vec_IntAlloc
(
0
);
vFlowRefs
=
Vec_IntAlloc
(
0
);
Mf_ManSetFlowRefs
(
pGia
,
vFlowRefs
);
Mf_ManSetFlowRefs
(
pGia
,
vFlowRefs
);
...
@@ -385,7 +383,6 @@ void Nf_StoDelete( Nf_Man_t * p )
...
@@ -385,7 +383,6 @@ void Nf_StoDelete( Nf_Man_t * p )
ABC_FREE
(
p
->
vCutFlows
.
pArray
);
ABC_FREE
(
p
->
vCutFlows
.
pArray
);
ABC_FREE
(
p
->
vCutDelays
.
pArray
);
ABC_FREE
(
p
->
vCutDelays
.
pArray
);
ABC_FREE
(
p
->
vBackup
.
pArray
);
ABC_FREE
(
p
->
vBackup
.
pArray
);
ABC_FREE
(
p
->
vBackup2
.
pArray
);
ABC_FREE
(
p
->
pNfObjs
);
ABC_FREE
(
p
->
pNfObjs
);
// matching
// matching
Vec_WecFree
(
p
->
vTt2Match
);
Vec_WecFree
(
p
->
vTt2Match
);
...
@@ -975,6 +972,7 @@ void Nf_ManPrintInit( Nf_Man_t * p )
...
@@ -975,6 +972,7 @@ void Nf_ManPrintInit( Nf_Man_t * p )
printf
(
"Cells = %d "
,
p
->
nCells
);
printf
(
"Cells = %d "
,
p
->
nCells
);
printf
(
"Funcs = %d "
,
Vec_MemEntryNum
(
p
->
vTtMem
)
);
printf
(
"Funcs = %d "
,
Vec_MemEntryNum
(
p
->
vTtMem
)
);
printf
(
"Matches = %d "
,
Vec_WecSizeSize
(
p
->
vTt2Match
)
/
2
);
printf
(
"Matches = %d "
,
Vec_WecSizeSize
(
p
->
vTt2Match
)
/
2
);
printf
(
"And = %d "
,
Gia_ManAndNum
(
p
->
pGia
)
);
nChoices
=
Gia_ManChoiceNum
(
p
->
pGia
);
nChoices
=
Gia_ManChoiceNum
(
p
->
pGia
);
if
(
nChoices
)
if
(
nChoices
)
printf
(
"Choices = %d "
,
nChoices
);
printf
(
"Choices = %d "
,
nChoices
);
...
@@ -1013,78 +1011,6 @@ void Nf_ManPrintQuit( Nf_Man_t * p )
...
@@ -1013,78 +1011,6 @@ void Nf_ManPrintQuit( Nf_Man_t * p )
/**Function*************************************************************
/**Function*************************************************************
Synopsis [Technology mappping.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
word
Nf_MatchDeref2_rec
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
)
{
int
k
,
iVar
,
fCompl
,
*
pCut
;
word
Area
=
0
;
if
(
pM
->
fCompl
)
{
assert
(
Nf_ObjMapRefNum
(
p
,
i
,
!
c
)
>
0
);
if
(
!
Nf_ObjMapRefDec
(
p
,
i
,
!
c
)
)
Area
+=
Nf_MatchDeref2_rec
(
p
,
i
,
!
c
,
Nf_ObjMatchBest
(
p
,
i
,
!
c
)
);
return
Area
+
p
->
InvArea
;
}
if
(
Nf_ObjCutSetId
(
p
,
i
)
==
0
)
return
0
;
pCut
=
Nf_CutFromHandle
(
Nf_ObjCutSet
(
p
,
i
),
pM
->
CutH
);
Nf_CutForEachVar
(
pCut
,
pM
->
Conf
,
iVar
,
fCompl
,
k
)
{
assert
(
Nf_ObjMapRefNum
(
p
,
iVar
,
fCompl
)
>
0
);
if
(
!
Nf_ObjMapRefDec
(
p
,
iVar
,
fCompl
)
)
Area
+=
Nf_MatchDeref2_rec
(
p
,
iVar
,
fCompl
,
Nf_ObjMatchBest
(
p
,
iVar
,
fCompl
)
);
}
return
Area
+
Nf_ManCell
(
p
,
pM
->
Gate
)
->
Area
;
}
word
Nf_MatchRef2_rec
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
,
Vec_Int_t
*
vBackup
)
{
int
k
,
iVar
,
fCompl
,
*
pCut
;
word
Area
=
0
;
if
(
pM
->
fCompl
)
{
if
(
vBackup
)
Vec_IntPush
(
vBackup
,
Abc_Var2Lit
(
i
,
!
c
)
);
assert
(
Nf_ObjMapRefNum
(
p
,
i
,
!
c
)
>=
0
);
if
(
!
Nf_ObjMapRefInc
(
p
,
i
,
!
c
)
)
Area
+=
Nf_MatchRef2_rec
(
p
,
i
,
!
c
,
Nf_ObjMatchBest
(
p
,
i
,
!
c
),
vBackup
);
return
Area
+
p
->
InvArea
;
}
if
(
Nf_ObjCutSetId
(
p
,
i
)
==
0
)
return
0
;
pCut
=
Nf_CutFromHandle
(
Nf_ObjCutSet
(
p
,
i
),
pM
->
CutH
);
Nf_CutForEachVar
(
pCut
,
pM
->
Conf
,
iVar
,
fCompl
,
k
)
{
if
(
vBackup
)
Vec_IntPush
(
vBackup
,
Abc_Var2Lit
(
iVar
,
fCompl
)
);
assert
(
Nf_ObjMapRefNum
(
p
,
iVar
,
fCompl
)
>=
0
);
if
(
!
Nf_ObjMapRefInc
(
p
,
iVar
,
fCompl
)
)
Area
+=
Nf_MatchRef2_rec
(
p
,
iVar
,
fCompl
,
Nf_ObjMatchBest
(
p
,
iVar
,
fCompl
),
vBackup
);
}
return
Area
+
Nf_ManCell
(
p
,
pM
->
Gate
)
->
Area
;
}
word
Nf_MatchRef2Area
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
)
{
word
Area
;
int
iLit
,
k
;
Vec_IntClear
(
&
p
->
vBackup
);
Area
=
Nf_MatchRef2_rec
(
p
,
i
,
c
,
pM
,
&
p
->
vBackup
);
Vec_IntForEachEntry
(
&
p
->
vBackup
,
iLit
,
k
)
{
assert
(
Nf_ObjMapRefNum
(
p
,
Abc_Lit2Var
(
iLit
),
Abc_LitIsCompl
(
iLit
))
>
0
);
Nf_ObjMapRefDec
(
p
,
Abc_Lit2Var
(
iLit
),
Abc_LitIsCompl
(
iLit
)
);
}
return
Area
;
}
/**Function*************************************************************
Synopsis []
Synopsis []
Description []
Description []
...
@@ -1337,10 +1263,6 @@ void Nf_ManCutMatch( Nf_Man_t * p, int iObj )
...
@@ -1337,10 +1263,6 @@ void Nf_ManCutMatch( Nf_Man_t * p, int iObj )
Required
[
0
]
=
Nf_ObjRequired
(
p
,
iObj
,
0
);
Required
[
0
]
=
Nf_ObjRequired
(
p
,
iObj
,
0
);
Required
[
1
]
=
Nf_ObjRequired
(
p
,
iObj
,
1
);
Required
[
1
]
=
Nf_ObjRequired
(
p
,
iObj
,
1
);
}
}
// if ( p->fUseEla && Nf_ObjMapRefNum(p, iObj, 0) > 0 )
// ValueBeg[0] = Nf_MatchDeref2_rec( p, iObj, 0, Nf_ObjMatchBest(p, iObj, 0) );
// if ( p->fUseEla && Nf_ObjMapRefNum(p, iObj, 1) > 0 )
// ValueBeg[1] = Nf_MatchDeref2_rec( p, iObj, 1, Nf_ObjMatchBest(p, iObj, 1) );
memset
(
pBest
,
0
,
sizeof
(
Nf_Obj_t
)
);
memset
(
pBest
,
0
,
sizeof
(
Nf_Obj_t
)
);
pDp
->
D
=
pDp
->
A
=
NF_INFINITY
;
pDp
->
D
=
pDp
->
A
=
NF_INFINITY
;
pDn
->
D
=
pDn
->
A
=
NF_INFINITY
;
pDn
->
D
=
pDn
->
A
=
NF_INFINITY
;
...
@@ -1444,28 +1366,6 @@ void Nf_ManCutMatch( Nf_Man_t * p, int iObj )
...
@@ -1444,28 +1366,6 @@ void Nf_ManCutMatch( Nf_Man_t * p, int iObj )
assert
(
pDn
->
A
<
NF_INFINITY
);
assert
(
pDn
->
A
<
NF_INFINITY
);
assert
(
pAp
->
A
<
NF_INFINITY
);
assert
(
pAp
->
A
<
NF_INFINITY
);
assert
(
pAn
->
A
<
NF_INFINITY
);
assert
(
pAn
->
A
<
NF_INFINITY
);
/*
if ( p->fUseEla )
{
// set the first good cut
Index = (pAp->D != NF_INFINITY && pAp->D < Nf_ObjRequired(p, iObj, 0));
assert( !pDp->fBest && !pAp->fBest );
pBest->M[0][Index].fBest = 1;
assert( pDp->fBest != pAp->fBest );
// set the second good cut
Index = (pAn->D != NF_INFINITY && pAn->D < Nf_ObjRequired(p, iObj, 1));
assert( !pDn->fBest && !pAn->fBest );
pBest->M[1][Index].fBest = 1;
assert( pDn->fBest != pAn->fBest );
// reference if needed
if ( Nf_ObjMapRefNum(p, iObj, 0) > 0 )
ValueEnd[0] = Nf_MatchRef2_rec( p, iObj, 0, Nf_ObjMatchBest(p, iObj, 0), NULL );
if ( Nf_ObjMapRefNum(p, iObj, 1) > 0 )
ValueEnd[1] = Nf_MatchRef2_rec( p, iObj, 1, Nf_ObjMatchBest(p, iObj, 1), NULL );
// assert( ValueBeg[0] > ValueEnd[0] );
// assert( ValueBeg[1] > ValueEnd[1] );
}
*/
/*
/*
if ( p->Iter && (pDp->D > Required[0] + 1 || pDn->D > Required[1] + 1) )
if ( p->Iter && (pDp->D > Required[0] + 1 || pDn->D > Required[1] + 1) )
...
@@ -1519,7 +1419,7 @@ void Nf_ManSetOutputRequireds( Nf_Man_t * p )
...
@@ -1519,7 +1419,7 @@ void Nf_ManSetOutputRequireds( Nf_Man_t * p )
p
->
pPars
->
WordMapDelay
=
Abc_MaxWord
(
p
->
pPars
->
WordMapDelay
,
Required
);
p
->
pPars
->
WordMapDelay
=
Abc_MaxWord
(
p
->
pPars
->
WordMapDelay
,
Required
);
}
}
// check delay target
// check delay target
if
(
p
->
pPars
->
WordMapDelayTarget
>
0
&&
p
->
pPars
->
nRelaxRatio
)
if
(
p
->
pPars
->
WordMapDelayTarget
==
0
&&
p
->
pPars
->
nRelaxRatio
)
p
->
pPars
->
WordMapDelayTarget
=
p
->
pPars
->
WordMapDelay
*
(
100
+
p
->
pPars
->
nRelaxRatio
)
/
100
;
p
->
pPars
->
WordMapDelayTarget
=
p
->
pPars
->
WordMapDelay
*
(
100
+
p
->
pPars
->
nRelaxRatio
)
/
100
;
if
(
p
->
pPars
->
WordMapDelayTarget
>
0
)
if
(
p
->
pPars
->
WordMapDelayTarget
>
0
)
{
{
...
@@ -1577,6 +1477,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
...
@@ -1577,6 +1477,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
Nf_Mat_t
*
pDs
[
2
],
*
pAs
[
2
],
*
pMs
[
2
];
Nf_Mat_t
*
pDs
[
2
],
*
pAs
[
2
],
*
pMs
[
2
];
Gia_Obj_t
*
pObj
;
Gia_Obj_t
*
pObj
;
word
Required
=
0
,
Requireds
[
2
];
word
Required
=
0
,
Requireds
[
2
];
assert
(
!
p
->
fUseEla
);
/*
/*
if ( p->Iter == 0 )
if ( p->Iter == 0 )
...
@@ -1602,12 +1503,10 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
...
@@ -1602,12 +1503,10 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
}
}
*/
*/
// clean references
assert
(
!
p
->
fUseEla
);
memset
(
pMapRefs
,
0
,
sizeof
(
int
)
*
nLits
);
// set the output required times
// set the output required times
Nf_ManSetOutputRequireds
(
p
);
Nf_ManSetOutputRequireds
(
p
);
// set output references
// set output references
memset
(
pMapRefs
,
0
,
sizeof
(
int
)
*
nLits
);
Gia_ManForEachCo
(
p
->
pGia
,
pObj
,
i
)
Gia_ManForEachCo
(
p
->
pGia
,
pObj
,
i
)
Nf_ObjMapRefInc
(
p
,
Gia_ObjFaninId0p
(
p
->
pGia
,
pObj
),
Gia_ObjFaninC0
(
pObj
));
Nf_ObjMapRefInc
(
p
,
Gia_ObjFaninId0p
(
p
->
pGia
,
pObj
),
Gia_ObjFaninC0
(
pObj
));
...
@@ -1671,7 +1570,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
...
@@ -1671,7 +1570,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
assert
(
pMs
[
c
]
->
fCompl
&&
!
pMs
[
!
c
]
->
fCompl
);
assert
(
pMs
[
c
]
->
fCompl
&&
!
pMs
[
!
c
]
->
fCompl
);
//printf( "Using inverter at node %d in phase %d\n", i, c );
//printf( "Using inverter at node %d in phase %d\n", i, c );
// update this phase
phase
// update this phase
pM
=
pMs
[
c
];
pM
=
pMs
[
c
];
pM
->
fBest
=
1
;
pM
->
fBest
=
1
;
Required
=
Requireds
[
c
];
Required
=
Requireds
[
c
];
...
@@ -1680,7 +1579,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
...
@@ -1680,7 +1579,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
Nf_ObjMapRefInc
(
p
,
i
,
!
c
);
Nf_ObjMapRefInc
(
p
,
i
,
!
c
);
Nf_ObjUpdateRequired
(
p
,
i
,
!
c
,
Required
-
p
->
InvDelay
);
Nf_ObjUpdateRequired
(
p
,
i
,
!
c
,
Required
-
p
->
InvDelay
);
// select opposit
v
e phase
// select opposite phase
Required
=
Nf_ObjRequired
(
p
,
i
,
!
c
);
Required
=
Nf_ObjRequired
(
p
,
i
,
!
c
);
//assert( Required < NF_INFINITY );
//assert( Required < NF_INFINITY );
pD
=
Nf_ObjMatchD
(
p
,
i
,
!
c
);
pD
=
Nf_ObjMatchD
(
p
,
i
,
!
c
);
...
@@ -1717,7 +1616,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
...
@@ -1717,7 +1616,7 @@ int Nf_ManSetMapRefs( Nf_Man_t * p )
// update opposite phase
// update opposite phase
Nf_ObjMapRefInc
(
p
,
i
,
!
c
);
Nf_ObjMapRefInc
(
p
,
i
,
!
c
);
Nf_ObjUpdateRequired
(
p
,
i
,
!
c
,
Required
-
p
->
InvDelay
);
Nf_ObjUpdateRequired
(
p
,
i
,
!
c
,
Required
-
p
->
InvDelay
);
// select opposit
v
e phase
// select opposite phase
Required
=
Nf_ObjRequired
(
p
,
i
,
!
c
);
Required
=
Nf_ObjRequired
(
p
,
i
,
!
c
);
//assert( Required < NF_INFINITY );
//assert( Required < NF_INFINITY );
pD
=
Nf_ObjMatchD
(
p
,
i
,
!
c
);
pD
=
Nf_ObjMatchD
(
p
,
i
,
!
c
);
...
@@ -1774,16 +1673,26 @@ static inline Nf_Mat_t * Nf_ObjMatchBestReq( Nf_Man_t * p, int i, int c, word r
...
@@ -1774,16 +1673,26 @@ static inline Nf_Mat_t * Nf_ObjMatchBestReq( Nf_Man_t * p, int i, int c, word r
{
{
Nf_Mat_t
*
pD
=
Nf_ObjMatchD
(
p
,
i
,
c
);
Nf_Mat_t
*
pD
=
Nf_ObjMatchD
(
p
,
i
,
c
);
Nf_Mat_t
*
pA
=
Nf_ObjMatchA
(
p
,
i
,
c
);
Nf_Mat_t
*
pA
=
Nf_ObjMatchA
(
p
,
i
,
c
);
assert
(
!
pD
->
fBest
&&
!
pA
->
fBest
);
assert
(
!
pD
->
fBest
||
!
pA
->
fBest
);
assert
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
==
0
);
if
(
pD
->
fBest
)
if
(
pA
->
D
<=
r
)
{
return
pA
;
assert
(
pD
->
D
<=
r
)
;
return
pD
;
return
pD
;
}
if
(
pA
->
fBest
)
{
assert
(
pA
->
D
<=
r
);
return
pA
;
}
assert
(
!
pD
->
fBest
&&
!
pA
->
fBest
);
assert
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
==
1
);
assert
(
pD
->
D
<=
r
);
return
pA
->
D
<=
r
?
pA
:
pD
;
}
}
word
Nf_MatchDeref_rec
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
)
word
Nf_MatchDeref_rec
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
)
{
{
int
k
,
iVar
,
fCompl
,
*
pCut
;
word
Area
=
0
;
word
Area
=
0
;
int
k
,
iVar
,
fCompl
,
*
pCut
;
int
Value
=
pM
->
fBest
;
int
Value
=
pM
->
fBest
;
pM
->
fBest
=
0
;
pM
->
fBest
=
0
;
if
(
pM
->
fCompl
)
if
(
pM
->
fCompl
)
...
@@ -1807,9 +1716,9 @@ word Nf_MatchDeref_rec( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM )
...
@@ -1807,9 +1716,9 @@ word Nf_MatchDeref_rec( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM )
}
}
word
Nf_MatchRef_rec
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
,
word
Required
,
Vec_Int_t
*
vBackup
)
word
Nf_MatchRef_rec
(
Nf_Man_t
*
p
,
int
i
,
int
c
,
Nf_Mat_t
*
pM
,
word
Required
,
Vec_Int_t
*
vBackup
)
{
{
int
k
,
iVar
,
fCompl
,
*
pCut
;
word
ReqFanin
,
Area
=
0
;
word
ReqFanin
,
Area
=
0
;
assert
(
pM
->
fBest
==
0
);
int
k
,
iVar
,
fCompl
,
*
pCut
;
//assert( pM->fBest == 0 );
if
(
vBackup
==
NULL
)
if
(
vBackup
==
NULL
)
pM
->
fBest
=
1
;
pM
->
fBest
=
1
;
if
(
pM
->
fCompl
)
if
(
pM
->
fCompl
)
...
@@ -1850,7 +1759,7 @@ word Nf_MatchRefArea( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM, word Required )
...
@@ -1850,7 +1759,7 @@ word Nf_MatchRefArea( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM, word Required )
}
}
void
Nf_ManElaBestMatchOne
(
Nf_Man_t
*
p
,
int
iObj
,
int
c
,
int
*
pCut
,
int
*
pCutSet
,
Nf_Mat_t
*
pRes
,
word
Required
)
void
Nf_ManElaBestMatchOne
(
Nf_Man_t
*
p
,
int
iObj
,
int
c
,
int
*
pCut
,
int
*
pCutSet
,
Nf_Mat_t
*
pRes
,
word
Required
)
{
{
Nf_Mat_t
Mb
,
*
pMb
=
&
Mb
;
Nf_Mat_t
Mb
,
*
pMb
=
&
Mb
,
*
pMd
,
*
pMa
;
Nf_Obj_t
*
pBest
=
Nf_ManObj
(
p
,
iObj
);
Nf_Obj_t
*
pBest
=
Nf_ManObj
(
p
,
iObj
);
int
*
pFans
=
Nf_CutLeaves
(
pCut
);
int
*
pFans
=
Nf_CutLeaves
(
pCut
);
int
nFans
=
Nf_CutSize
(
pCut
);
int
nFans
=
Nf_CutSize
(
pCut
);
...
@@ -1858,7 +1767,6 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
...
@@ -1858,7 +1767,6 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
int
fComplExt
=
Abc_LitIsCompl
(
iFuncLit
);
int
fComplExt
=
Abc_LitIsCompl
(
iFuncLit
);
Vec_Int_t
*
vArr
=
Vec_WecEntry
(
p
->
vTt2Match
,
Abc_Lit2Var
(
iFuncLit
)
);
Vec_Int_t
*
vArr
=
Vec_WecEntry
(
p
->
vTt2Match
,
Abc_Lit2Var
(
iFuncLit
)
);
int
i
,
k
,
Info
,
Offset
,
iFanin
,
fComplF
;
int
i
,
k
,
Info
,
Offset
,
iFanin
,
fComplF
;
word
ArrivalD
,
ArrivalA
;
// assign fanins matches
// assign fanins matches
Nf_Obj_t
*
pBestF
[
NF_LEAF_MAX
];
Nf_Obj_t
*
pBestF
[
NF_LEAF_MAX
];
for
(
i
=
0
;
i
<
nFans
;
i
++
)
for
(
i
=
0
;
i
<
nFans
;
i
++
)
...
@@ -1866,6 +1774,7 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
...
@@ -1866,6 +1774,7 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
// special cases
// special cases
if
(
nFans
<
2
)
if
(
nFans
<
2
)
{
{
assert
(
0
);
*
pRes
=
*
Nf_ObjMatchBestReq
(
p
,
iObj
,
c
,
Required
);
*
pRes
=
*
Nf_ObjMatchBestReq
(
p
,
iObj
,
c
,
Required
);
return
;
return
;
}
}
...
@@ -1878,24 +1787,26 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
...
@@ -1878,24 +1787,26 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
Pf_Mat_t
Mat
=
Pf_Int2Mat
(
Offset
);
Pf_Mat_t
Mat
=
Pf_Int2Mat
(
Offset
);
Mio_Cell2_t
*
pC
=
Nf_ManCell
(
p
,
Info
);
Mio_Cell2_t
*
pC
=
Nf_ManCell
(
p
,
Info
);
int
fCompl
=
Mat
.
fCompl
^
fComplExt
;
int
fCompl
=
Mat
.
fCompl
^
fComplExt
;
word
Required
=
Nf_ObjRequired
(
p
,
iObj
,
fCompl
);
Nf_Mat_t
*
pD
=
&
pBest
->
M
[
fCompl
][
0
];
Nf_Mat_t
*
pD
=
&
pBest
->
M
[
fCompl
][
0
];
Nf_Mat_t
*
pA
=
&
pBest
->
M
[
fCompl
][
1
];
Nf_Mat_t
*
pA
=
&
pBest
->
M
[
fCompl
][
1
];
word
Area
=
pC
->
Area
,
Delay
;
word
Area
=
pC
->
Area
,
Arrival
,
Delay
=
0
;
assert
(
nFans
==
(
int
)
pC
->
nFanins
);
assert
(
nFans
==
(
int
)
pC
->
nFanins
);
if
(
fCompl
!=
c
)
if
(
fCompl
!=
c
)
continue
;
continue
;
Delay
=
0
;
for
(
k
=
0
;
k
<
nFans
;
k
++
)
for
(
k
=
0
;
k
<
nFans
;
k
++
)
{
{
iFanin
=
(
Mat
.
Perm
>>
(
3
*
k
))
&
7
;
iFanin
=
(
Mat
.
Perm
>>
(
3
*
k
))
&
7
;
fComplF
=
(
Mat
.
Phase
>>
k
)
&
1
;
fComplF
=
(
Mat
.
Phase
>>
k
)
&
1
;
ArrivalD
=
pBestF
[
k
]
->
M
[
fComplF
][
0
].
D
;
pMd
=
&
pBestF
[
k
]
->
M
[
fComplF
][
0
];
ArrivalA
=
pBestF
[
k
]
->
M
[
fComplF
][
1
].
D
;
pMa
=
&
pBestF
[
k
]
->
M
[
fComplF
][
1
];
if
(
ArrivalA
+
pC
->
Delays
[
iFanin
]
<=
Required
&&
Required
!=
NF_INFINITY
)
assert
(
!
pMd
->
fBest
||
!
pMa
->
fBest
);
Delay
=
Abc_MaxWord
(
Delay
,
ArrivalA
+
pC
->
Delays
[
iFanin
]
);
if
(
pMd
->
fBest
)
Arrival
=
pMd
->
D
;
else
if
(
pMa
->
fBest
)
Arrival
=
pMa
->
D
;
else
else
Delay
=
Abc_MaxWord
(
Delay
,
ArrivalD
+
pC
->
Delays
[
iFanin
]
);
Arrival
=
pMd
->
D
;
Delay
=
Abc_MaxWord
(
Delay
,
Arrival
+
pC
->
Delays
[
iFanin
]
);
if
(
Delay
>
Required
)
if
(
Delay
>
Required
)
break
;
break
;
}
}
...
@@ -1904,6 +1815,7 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
...
@@ -1904,6 +1815,7 @@ void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCu
// create match
// create match
pMb
->
D
=
Delay
;
pMb
->
D
=
Delay
;
pMb
->
A
=
NF_INFINITY
;
pMb
->
A
=
NF_INFINITY
;
pMb
->
fCompl
=
0
;
pMb
->
CutH
=
Nf_CutHandle
(
pCutSet
,
pCut
);
pMb
->
CutH
=
Nf_CutHandle
(
pCutSet
,
pCut
);
pMb
->
Gate
=
pC
->
Id
;
pMb
->
Gate
=
pC
->
Id
;
pMb
->
Conf
=
0
;
pMb
->
Conf
=
0
;
...
@@ -1932,13 +1844,14 @@ void Nf_ManElaBestMatch( Nf_Man_t * p, int iObj, int c, Nf_Mat_t * pRes, word Re
...
@@ -1932,13 +1844,14 @@ void Nf_ManElaBestMatch( Nf_Man_t * p, int iObj, int c, Nf_Mat_t * pRes, word Re
// area is never compared
// area is never compared
void
Nf_ManComputeMappingEla
(
Nf_Man_t
*
p
)
void
Nf_ManComputeMappingEla
(
Nf_Man_t
*
p
)
{
{
int
fVerbose
=
1
;
Mio_Cell2_t
*
pCell
;
Mio_Cell2_t
*
pCell
;
Nf_Mat_t
Mb
,
*
pMb
=
&
Mb
,
*
pM
;
Nf_Mat_t
Mb
,
*
pMb
=
&
Mb
,
*
pM
;
word
AreaBef
,
AreaAft
,
Required
,
MapArea
;
word
AreaBef
,
AreaAft
,
Required
,
WordMapArea
,
Gain
=
0
;
int
i
,
c
,
iVar
,
Id
,
fCompl
,
k
,
*
pCut
;
int
i
,
c
,
iVar
,
Id
,
fCompl
,
k
,
*
pCut
;
Nf_ManSetOutputRequireds
(
p
);
Nf_ManSetOutputRequireds
(
p
);
// compute area and edges
// compute area and edges
MapArea
=
p
->
pPars
->
WordMapArea
;
Word
MapArea
=
p
->
pPars
->
WordMapArea
;
p
->
pPars
->
WordMapArea
=
0
;
p
->
pPars
->
WordMapArea
=
0
;
p
->
pPars
->
Area
=
p
->
pPars
->
Edge
=
0
;
p
->
pPars
->
Area
=
p
->
pPars
->
Edge
=
0
;
Gia_ManForEachAndReverseId
(
p
->
pGia
,
i
)
Gia_ManForEachAndReverseId
(
p
->
pGia
,
i
)
...
@@ -1946,27 +1859,60 @@ void Nf_ManComputeMappingEla( Nf_Man_t * p )
...
@@ -1946,27 +1859,60 @@ void Nf_ManComputeMappingEla( Nf_Man_t * p )
if
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
)
if
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
)
{
{
pM
=
Nf_ObjMatchBest
(
p
,
i
,
c
);
pM
=
Nf_ObjMatchBest
(
p
,
i
,
c
);
if
(
pM
->
fCompl
)
continue
;
// if ( i < 750 )
// break;
// if ( i == 777 )
// {
// int s = 0;
// }
Required
=
Nf_ObjRequired
(
p
,
i
,
c
);
Required
=
Nf_ObjRequired
(
p
,
i
,
c
);
assert
(
pM
->
D
<=
Required
);
assert
(
pM
->
D
<=
Required
);
// try different cuts at this node and find best match
// try different cuts at this node and find best match
Vec_IntClear
(
&
p
->
vBackup2
);
AreaBef
=
Nf_MatchDeref_rec
(
p
,
i
,
c
,
pM
);
AreaBef
=
Nf_MatchDeref_rec
(
p
,
i
,
c
,
pM
);
assert
(
pM
->
fBest
==
0
);
Nf_ManElaBestMatch
(
p
,
i
,
c
,
pMb
,
Required
);
Nf_ManElaBestMatch
(
p
,
i
,
c
,
pMb
,
Required
);
assert
(
pMb
->
fBest
==
0
);
AreaAft
=
Nf_MatchRef_rec
(
p
,
i
,
c
,
pMb
,
Required
,
NULL
);
AreaAft
=
Nf_MatchRef_rec
(
p
,
i
,
c
,
pMb
,
Required
,
NULL
);
assert
(
pMb
->
fBest
==
1
);
assert
(
pMb
->
A
==
AreaAft
);
assert
(
pMb
->
A
==
AreaAft
);
Gain
+=
AreaBef
-
AreaAft
;
if
(
fVerbose
&&
Nf_ManCell
(
p
,
pM
->
Gate
)
->
pName
!=
Nf_ManCell
(
p
,
pMb
->
Gate
)
->
pName
)
{
printf
(
"%4d (%d) "
,
i
,
c
);
printf
(
"%8s ->%8s "
,
Nf_ManCell
(
p
,
pM
->
Gate
)
->
pName
,
Nf_ManCell
(
p
,
pMb
->
Gate
)
->
pName
);
printf
(
"%d -> %d "
,
Nf_ManCell
(
p
,
pM
->
Gate
)
->
nFanins
,
Nf_ManCell
(
p
,
pMb
->
Gate
)
->
nFanins
);
printf
(
"D: %7.2f -> %7.2f "
,
Nf_Wrd2Flt
(
pM
->
D
),
Nf_Wrd2Flt
(
pMb
->
D
)
);
printf
(
"R: %7.2f "
,
Required
==
NF_INFINITY
?
9999
.
99
:
Nf_Wrd2Flt
(
Required
)
);
printf
(
"A: %7.2f -> %7.2f "
,
Nf_Wrd2Flt
(
AreaBef
),
Nf_Wrd2Flt
(
AreaAft
)
);
printf
(
"G: %7.2f (%7.2f) "
,
AreaBef
>=
AreaAft
?
Nf_Wrd2Flt
(
AreaBef
-
AreaAft
)
:
-
Nf_Wrd2Flt
(
AreaAft
-
AreaBef
),
Nf_Wrd2Flt
(
Gain
)
);
printf
(
"
\n
"
);
}
assert
(
AreaBef
>=
AreaAft
);
assert
(
AreaBef
>=
AreaAft
);
MapArea
+=
AreaAft
-
AreaBef
;
WordMapArea
+=
AreaAft
-
AreaBef
;
// printf( "%8.2f %8.2f\n", AreaBef, AreaAft );
// set match
// set match
assert
(
pMb
->
D
<=
Required
);
assert
(
pMb
->
D
<=
Required
);
assert
(
pMb
->
fBest
==
0
);
*
Nf_ObjMatchA
(
p
,
i
,
c
)
=
*
pMb
;
*
Nf_ObjMatchA
(
p
,
i
,
c
)
=
*
pMb
;
assert
(
Nf_ObjMatchA
(
p
,
i
,
c
)
==
Nf_ObjMatchBest
(
p
,
i
,
c
)
);
assert
(
Nf_ObjMatchA
(
p
,
i
,
c
)
==
Nf_ObjMatchBest
(
p
,
i
,
c
)
);
// count status
// count status
pCell
=
Nf_ManCell
(
p
,
pMb
->
Gate
);
pCell
=
Nf_ManCell
(
p
,
pMb
->
Gate
);
pCut
=
Nf_CutFromHandle
(
Nf_ObjCutSet
(
p
,
i
),
pMb
->
CutH
);
pCut
=
Nf_CutFromHandle
(
Nf_ObjCutSet
(
p
,
i
),
pMb
->
CutH
);
Nf_CutForEachVar
(
pCut
,
pMb
->
Conf
,
iVar
,
fCompl
,
k
)
Nf_CutForEachVar
(
pCut
,
pMb
->
Conf
,
iVar
,
fCompl
,
k
)
{
pM
=
Nf_ObjMatchBest
(
p
,
iVar
,
fCompl
);
assert
(
pM
->
D
<=
Required
-
pCell
->
Delays
[
k
]
);
Nf_ObjUpdateRequired
(
p
,
iVar
,
fCompl
,
Required
-
pCell
->
Delays
[
k
]
);
Nf_ObjUpdateRequired
(
p
,
iVar
,
fCompl
,
Required
-
pCell
->
Delays
[
k
]
);
if
(
pM
->
fCompl
)
{
pM
=
Nf_ObjMatchBest
(
p
,
iVar
,
!
fCompl
);
assert
(
pM
->
D
<=
Required
-
pCell
->
Delays
[
k
]
-
p
->
InvDelay
);
Nf_ObjUpdateRequired
(
p
,
iVar
,
!
fCompl
,
Required
-
pCell
->
Delays
[
k
]
-
p
->
InvDelay
);
}
}
p
->
pPars
->
WordMapArea
+=
pCell
->
Area
;
p
->
pPars
->
WordMapArea
+=
pCell
->
Area
;
p
->
pPars
->
Edge
+=
Nf_CutSize
(
pCut
);
p
->
pPars
->
Edge
+=
Nf_CutSize
(
pCut
);
p
->
pPars
->
Area
++
;
p
->
pPars
->
Area
++
;
...
@@ -1982,7 +1928,7 @@ void Nf_ManComputeMappingEla( Nf_Man_t * p )
...
@@ -1982,7 +1928,7 @@ void Nf_ManComputeMappingEla( Nf_Man_t * p )
}
}
// Nf_ManUpdateStats( p );
// Nf_ManUpdateStats( p );
// if ( MapArea != p->pPars->WordMapArea )
// if ( MapArea != p->pPars->WordMapArea )
// printf( "Mismatch: Estimated = %.2f Real = %.2f\n", MapArea, p->pPars->WordMapArea );
// printf( "Mismatch: Estimated = %.2f Real = %.2f\n",
Word
MapArea, p->pPars->WordMapArea );
// Nf_ManPrintStats( p, "Ela " );
// Nf_ManPrintStats( p, "Ela " );
}
}
...
@@ -2058,17 +2004,27 @@ void Nf_ManUpdateStats( Nf_Man_t * p )
...
@@ -2058,17 +2004,27 @@ void Nf_ManUpdateStats( Nf_Man_t * p )
}
}
p
->
pPars
->
WordMapArea
=
0
;
p
->
pPars
->
WordMapArea
=
0
;
p
->
pPars
->
Area
=
p
->
pPars
->
Edge
=
0
;
p
->
pPars
->
Area
=
p
->
pPars
->
Edge
=
0
;
Gia_ManForEachAndId
(
p
->
pGia
,
i
)
Gia_ManForEachAnd
Reverse
Id
(
p
->
pGia
,
i
)
for
(
c
=
0
;
c
<
2
;
c
++
)
for
(
c
=
0
;
c
<
2
;
c
++
)
if
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
)
if
(
Nf_ObjMapRefNum
(
p
,
i
,
c
)
)
{
{
pM
=
Nf_ObjMatchBest
(
p
,
i
,
c
);
pM
=
Nf_ObjMatchBest
(
p
,
i
,
c
);
if
(
pM
->
fCompl
)
{
p
->
pPars
->
WordMapArea
+=
p
->
InvArea
;
p
->
pPars
->
Edge
++
;
p
->
pPars
->
Area
++
;
continue
;
}
pCut
=
Nf_CutFromHandle
(
Nf_ObjCutSet
(
p
,
i
),
pM
->
CutH
);
pCut
=
Nf_CutFromHandle
(
Nf_ObjCutSet
(
p
,
i
),
pM
->
CutH
);
pCell
=
Nf_ManCell
(
p
,
pM
->
Gate
);
pCell
=
Nf_ManCell
(
p
,
pM
->
Gate
);
assert
(
Nf_CutSize
(
pCut
)
==
(
int
)
pCell
->
nFanins
);
assert
(
Nf_CutSize
(
pCut
)
==
(
int
)
pCell
->
nFanins
);
p
->
pPars
->
WordMapArea
+=
pCell
->
Area
;
p
->
pPars
->
WordMapArea
+=
pCell
->
Area
;
p
->
pPars
->
Edge
+=
Nf_CutSize
(
pCut
);
p
->
pPars
->
Edge
+=
Nf_CutSize
(
pCut
);
p
->
pPars
->
Area
++
;
p
->
pPars
->
Area
++
;
//printf( "%5d (%d) : ", i, c );
//printf( "Gate = %7s ", pCell->pName );
//printf( "\n" );
}
}
Gia_ManForEachCiId
(
p
->
pGia
,
Id
,
i
)
Gia_ManForEachCiId
(
p
->
pGia
,
Id
,
i
)
if
(
Nf_ObjMapRefNum
(
p
,
Id
,
1
)
)
if
(
Nf_ObjMapRefNum
(
p
,
Id
,
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