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
9df63f52
Commit
9df63f52
authored
Oct 13, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with precomputation and matching.
parent
20c46b5a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
8 deletions
+108
-8
src/opt/sfm/sfmDec.c
+0
-0
src/opt/sfm/sfmInt.h
+2
-1
src/opt/sfm/sfmLib.c
+106
-7
No files found.
src/opt/sfm/sfmDec.c
View file @
9df63f52
This diff is collapsed.
Click to expand it.
src/opt/sfm/sfmInt.h
View file @
9df63f52
...
@@ -189,10 +189,11 @@ extern Vec_Wec_t * Sfm_CreateCnf( Sfm_Ntk_t * p );
...
@@ -189,10 +189,11 @@ 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
,
int
iPivotVar
);
extern
void
Sfm_TranslateCnf
(
Vec_Wec_t
*
vRes
,
Vec_Str_t
*
vCnf
,
Vec_Int_t
*
vFaninMap
,
int
iPivotVar
);
/*=== sfmCore.c ==========================================================*/
/*=== sfmCore.c ==========================================================*/
/*=== sfmLib.c ==========================================================*/
/*=== sfmLib.c ==========================================================*/
extern
int
Sfm_LibFindComplInputGate
(
Vec_Wrd_t
*
vFuncs
,
int
iGate
,
int
nFanins
,
int
iFanin
,
int
*
piFaninNew
);
extern
Sfm_Lib_t
*
Sfm_LibPrepare
(
int
nVars
,
int
fTwo
,
int
fVerbose
);
extern
Sfm_Lib_t
*
Sfm_LibPrepare
(
int
nVars
,
int
fTwo
,
int
fVerbose
);
extern
void
Sfm_LibPrint
(
Sfm_Lib_t
*
p
);
extern
void
Sfm_LibPrint
(
Sfm_Lib_t
*
p
);
extern
void
Sfm_LibStop
(
Sfm_Lib_t
*
p
);
extern
void
Sfm_LibStop
(
Sfm_Lib_t
*
p
);
extern
int
Sfm_LibImplement
(
Sfm_Lib_t
*
p
,
word
uTruth
,
int
*
pFanins
,
int
nFanins
,
Vec_Int_t
*
vGates
,
Vec_Wec_t
*
vFanins
);
extern
int
Sfm_LibImplement
(
Sfm_Lib_t
*
p
,
word
uTruth
,
int
*
pFanins
,
int
nFanins
,
int
AreaMffc
,
Vec_Int_t
*
vGates
,
Vec_Wec_t
*
vFanins
);
/*=== sfmNtk.c ==========================================================*/
/*=== sfmNtk.c ==========================================================*/
extern
Sfm_Ntk_t
*
Sfm_ConstructNetwork
(
Vec_Wec_t
*
vFanins
,
int
nPis
,
int
nPos
);
extern
Sfm_Ntk_t
*
Sfm_ConstructNetwork
(
Vec_Wec_t
*
vFanins
,
int
nPis
,
int
nPos
);
extern
void
Sfm_NtkPrepare
(
Sfm_Ntk_t
*
p
);
extern
void
Sfm_NtkPrepare
(
Sfm_Ntk_t
*
p
);
...
...
src/opt/sfm/sfmLib.c
View file @
9df63f52
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "misc/extra/extra.h"
#include "misc/extra/extra.h"
#include "map/mio/exp.h"
#include "map/mio/exp.h"
#include "opt/dau/dau.h"
#include "opt/dau/dau.h"
#include "base/main/main.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -124,6 +125,47 @@ void Sfm_LibPreprocess( Mio_Library_t * pLib, Vec_Int_t * vGateSizes, Vec_Wrd_t
...
@@ -124,6 +125,47 @@ void Sfm_LibPreprocess( Mio_Library_t * pLib, Vec_Int_t * vGateSizes, Vec_Wrd_t
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Sfm_LibFindComplInputGate
(
Vec_Wrd_t
*
vFuncs
,
int
iGate
,
int
nFanins
,
int
iFanin
,
int
*
piFaninNew
)
{
word
uTruthGate
=
Vec_WrdEntry
(
vFuncs
,
iGate
);
word
uTruth
,
uTruthNew
=
Abc_Tt6Flip
(
uTruthGate
,
iFanin
);
int
i
;
assert
(
iFanin
>=
0
&&
iFanin
<
nFanins
);
if
(
piFaninNew
)
*
piFaninNew
=
iFanin
;
Vec_WrdForEachEntry
(
vFuncs
,
uTruth
,
i
)
if
(
uTruth
==
uTruthNew
)
return
i
;
if
(
iFanin
-
1
>=
0
&&
Abc_Tt6SwapAdjacent
(
uTruthGate
,
iFanin
-
1
)
==
uTruthGate
)
// symmetric with prev
{
if
(
piFaninNew
)
*
piFaninNew
=
iFanin
-
1
;
uTruthNew
=
Abc_Tt6Flip
(
uTruthGate
,
iFanin
-
1
);
Vec_WrdForEachEntry
(
vFuncs
,
uTruth
,
i
)
if
(
uTruth
==
uTruthNew
)
return
i
;
}
if
(
iFanin
+
1
<
nFanins
&&
Abc_Tt6SwapAdjacent
(
uTruthGate
,
iFanin
)
==
uTruthGate
)
// symmetric with next
{
if
(
piFaninNew
)
*
piFaninNew
=
iFanin
+
1
;
uTruthNew
=
Abc_Tt6Flip
(
uTruthGate
,
iFanin
+
1
);
Vec_WrdForEachEntry
(
vFuncs
,
uTruth
,
i
)
if
(
uTruth
==
uTruthNew
)
return
i
;
}
if
(
piFaninNew
)
*
piFaninNew
=
-
1
;
return
-
1
;
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -176,7 +218,10 @@ word Sfm_LibTruthTwo( Mio_Cell2_t * pCellBot, Mio_Cell2_t * pCellTop, int InTop
...
@@ -176,7 +218,10 @@ word Sfm_LibTruthTwo( Mio_Cell2_t * pCellBot, Mio_Cell2_t * pCellTop, int InTop
word
uFanins
[
6
];
int
i
,
k
;
word
uFanins
[
6
];
int
i
,
k
;
assert
(
InTop
>=
0
&&
InTop
<
(
int
)
pCellTop
->
nFanins
);
assert
(
InTop
>=
0
&&
InTop
<
(
int
)
pCellTop
->
nFanins
);
for
(
i
=
0
,
k
=
pCellBot
->
nFanins
;
i
<
(
int
)
pCellTop
->
nFanins
;
i
++
)
for
(
i
=
0
,
k
=
pCellBot
->
nFanins
;
i
<
(
int
)
pCellTop
->
nFanins
;
i
++
)
uFanins
[
i
]
=
(
i
==
InTop
)
?
uTruthBot
:
s_Truths6
[
k
++
];
if
(
i
==
InTop
)
uFanins
[
i
]
=
uTruthBot
;
else
uFanins
[
i
]
=
s_Truths6
[
k
++
];
assert
(
(
int
)
pCellBot
->
nFanins
+
(
int
)
pCellTop
->
nFanins
==
k
+
1
);
assert
(
(
int
)
pCellBot
->
nFanins
+
(
int
)
pCellTop
->
nFanins
==
k
+
1
);
uTruthBot
=
Exp_Truth6
(
pCellTop
->
nFanins
,
pCellTop
->
vExpr
,
uFanins
);
uTruthBot
=
Exp_Truth6
(
pCellTop
->
nFanins
,
pCellTop
->
vExpr
,
uFanins
);
return
uTruthBot
;
return
uTruthBot
;
...
@@ -196,7 +241,7 @@ word Sfm_LibTruthTwo( Mio_Cell2_t * pCellBot, Mio_Cell2_t * pCellTop, int InTop
...
@@ -196,7 +241,7 @@ word Sfm_LibTruthTwo( Mio_Cell2_t * pCellBot, Mio_Cell2_t * pCellTop, int InTop
void
Sfm_LibPrepareAdd
(
Sfm_Lib_t
*
p
,
word
uTruth
,
int
*
Perm
,
int
nFanins
,
Mio_Cell2_t
*
pCellBot
,
Mio_Cell2_t
*
pCellTop
,
int
InTop
)
void
Sfm_LibPrepareAdd
(
Sfm_Lib_t
*
p
,
word
uTruth
,
int
*
Perm
,
int
nFanins
,
Mio_Cell2_t
*
pCellBot
,
Mio_Cell2_t
*
pCellTop
,
int
InTop
)
{
{
Sfm_Fun_t
*
pObj
;
Sfm_Fun_t
*
pObj
;
int
Area
=
(
int
)(
pCellBot
->
Area
/
1000
)
+
(
pCellTop
?
(
int
)(
pCellTop
->
Area
/
1000
)
:
0
);
int
InvPerm
[
6
],
Area
=
(
int
)
pCellBot
->
Area
+
(
pCellTop
?
(
int
)
pCellTop
->
Area
:
0
);
int
i
,
k
,
iFunc
=
Vec_MemHashInsert
(
p
->
vTtMem
,
&
uTruth
);
int
i
,
k
,
iFunc
=
Vec_MemHashInsert
(
p
->
vTtMem
,
&
uTruth
);
if
(
iFunc
==
Vec_IntSize
(
&
p
->
vLists
)
)
if
(
iFunc
==
Vec_IntSize
(
&
p
->
vLists
)
)
{
{
...
@@ -210,6 +255,8 @@ void Sfm_LibPrepareAdd( Sfm_Lib_t * p, word uTruth, int * Perm, int nFanins, Mio
...
@@ -210,6 +255,8 @@ void Sfm_LibPrepareAdd( Sfm_Lib_t * p, word uTruth, int * Perm, int nFanins, Mio
if
(
Area
>=
pObj
->
Area
)
if
(
Area
>=
pObj
->
Area
)
return
;
return
;
}
}
for
(
k
=
0
;
k
<
nFanins
;
k
++
)
InvPerm
[
Perm
[
k
]]
=
k
;
// create new object
// create new object
if
(
p
->
nObjs
==
p
->
nObjsAlloc
)
if
(
p
->
nObjs
==
p
->
nObjsAlloc
)
{
{
...
@@ -227,13 +274,13 @@ void Sfm_LibPrepareAdd( Sfm_Lib_t * p, word uTruth, int * Perm, int nFanins, Mio
...
@@ -227,13 +274,13 @@ void Sfm_LibPrepareAdd( Sfm_Lib_t * p, word uTruth, int * Perm, int nFanins, Mio
assert
(
pCellBot
->
Id
<
128
);
assert
(
pCellBot
->
Id
<
128
);
pObj
->
pFansB
[
0
]
=
(
char
)
pCellBot
->
Id
;
pObj
->
pFansB
[
0
]
=
(
char
)
pCellBot
->
Id
;
for
(
k
=
0
;
k
<
(
int
)
pCellBot
->
nFanins
;
k
++
)
for
(
k
=
0
;
k
<
(
int
)
pCellBot
->
nFanins
;
k
++
)
pObj
->
pFansB
[
k
+
1
]
=
Perm
[
k
];
pObj
->
pFansB
[
k
+
1
]
=
Inv
Perm
[
k
];
if
(
pCellTop
==
NULL
)
if
(
pCellTop
==
NULL
)
return
;
return
;
assert
(
pCellTop
->
Id
<
128
);
assert
(
pCellTop
->
Id
<
128
);
pObj
->
pFansT
[
0
]
=
(
char
)
pCellTop
->
Id
;
pObj
->
pFansT
[
0
]
=
(
char
)
pCellTop
->
Id
;
for
(
i
=
0
;
i
<
(
int
)
pCellTop
->
nFanins
;
i
++
)
for
(
i
=
0
;
i
<
(
int
)
pCellTop
->
nFanins
;
i
++
)
pObj
->
pFansT
[
i
+
1
]
=
(
char
)(
i
==
InTop
?
16
:
Perm
[
k
++
]);
pObj
->
pFansT
[
i
+
1
]
=
(
char
)(
i
==
InTop
?
16
:
Inv
Perm
[
k
++
]);
assert
(
k
==
nFanins
);
assert
(
k
==
nFanins
);
}
}
Sfm_Lib_t
*
Sfm_LibPrepare
(
int
nVars
,
int
fTwo
,
int
fVerbose
)
Sfm_Lib_t
*
Sfm_LibPrepare
(
int
nVars
,
int
fTwo
,
int
fVerbose
)
...
@@ -340,7 +387,7 @@ void Sfm_LibPrintObj( Sfm_Lib_t * p, Sfm_Fun_t * pObj )
...
@@ -340,7 +387,7 @@ void Sfm_LibPrintObj( Sfm_Lib_t * p, Sfm_Fun_t * pObj )
Mio_Cell2_t
*
pCellB
=
p
->
pCells
+
(
int
)
pObj
->
pFansB
[
0
];
Mio_Cell2_t
*
pCellB
=
p
->
pCells
+
(
int
)
pObj
->
pFansB
[
0
];
Mio_Cell2_t
*
pCellT
=
p
->
pCells
+
(
int
)
pObj
->
pFansT
[
0
];
Mio_Cell2_t
*
pCellT
=
p
->
pCells
+
(
int
)
pObj
->
pFansT
[
0
];
int
nFanins
=
pCellB
->
nFanins
+
(
pCellT
==
p
->
pCells
?
0
:
pCellT
->
nFanins
);
int
nFanins
=
pCellB
->
nFanins
+
(
pCellT
==
p
->
pCells
?
0
:
pCellT
->
nFanins
);
printf
(
" Area = %6.2f Fanins = %d "
,
0
.
001
*
pObj
->
Area
,
nFanins
);
printf
(
" Area = %6.2f Fanins = %d "
,
MIO_NUMINV
*
pObj
->
Area
,
nFanins
);
if
(
pCellT
==
p
->
pCells
)
if
(
pCellT
==
p
->
pCells
)
Sfm_LibPrintGate
(
pCellB
,
pObj
->
pFansB
+
1
,
NULL
,
NULL
);
Sfm_LibPrintGate
(
pCellB
,
pObj
->
pFansB
+
1
,
NULL
,
NULL
);
else
else
...
@@ -381,9 +428,61 @@ void Sfm_LibTest( int nVars, int fTwo, int fVerbose )
...
@@ -381,9 +428,61 @@ void Sfm_LibTest( int nVars, int fTwo, int fVerbose )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
int
Sfm_LibImplement
(
Sfm_Lib_t
*
p
,
word
uTruth
,
int
*
pFanins
,
int
nFanins
,
Vec_Int_t
*
vGates
,
Vec_Wec_t
*
vFanins
)
int
Sfm_LibImplement
(
Sfm_Lib_t
*
p
,
word
uTruth
,
int
*
pFanins
,
int
nFanins
,
int
AreaMffc
,
Vec_Int_t
*
vGates
,
Vec_Wec_t
*
vFanins
)
{
{
return
0
;
Mio_Library_t
*
pLib
=
(
Mio_Library_t
*
)
Abc_FrameReadLibGen
();
Mio_Gate_t
*
pGate
;
Mio_Cell2_t
*
pCellB
,
*
pCellT
;
Vec_Int_t
*
vLevel
;
Sfm_Fun_t
*
pObj
,
*
pObjMin
=
NULL
;
int
i
,
iFunc
;
if
(
uTruth
==
0
||
uTruth
==
~
(
word
)
0
)
{
assert
(
nFanins
==
0
);
pGate
=
uTruth
?
Mio_LibraryReadConst1
(
pLib
)
:
Mio_LibraryReadConst0
(
pLib
);
Vec_IntPush
(
vGates
,
Mio_GateReadValue
(
pGate
)
);
vLevel
=
Vec_WecPushLevel
(
vFanins
);
return
1
;
}
if
(
uTruth
==
s_Truths6
[
0
]
||
uTruth
==
~
s_Truths6
[
0
]
)
{
assert
(
nFanins
==
1
);
pGate
=
uTruth
==
s_Truths6
[
0
]
?
Mio_LibraryReadBuf
(
pLib
)
:
Mio_LibraryReadInv
(
pLib
);
Vec_IntPush
(
vGates
,
Mio_GateReadValue
(
pGate
)
);
vLevel
=
Vec_WecPushLevel
(
vFanins
);
Vec_IntPush
(
vLevel
,
pFanins
[
0
]
);
return
1
;
}
// look for gate
iFunc
=
*
Vec_MemHashLookup
(
p
->
vTtMem
,
&
uTruth
);
if
(
iFunc
==
-
1
)
return
-
1
;
Sfm_LibForEachSuper
(
p
,
pObj
,
iFunc
)
if
(
!
pObjMin
||
pObjMin
->
Area
>
pObj
->
Area
)
pObjMin
=
pObj
;
if
(
pObjMin
==
NULL
||
pObjMin
->
Area
>=
AreaMffc
)
return
-
1
;
// get the gates
pCellB
=
p
->
pCells
+
(
int
)
pObjMin
->
pFansB
[
0
];
pCellT
=
p
->
pCells
+
(
int
)
pObjMin
->
pFansT
[
0
];
// create bottom gate
pGate
=
Mio_LibraryReadGateByName
(
pLib
,
pCellB
->
pName
,
NULL
);
Vec_IntPush
(
vGates
,
Mio_GateReadValue
(
pGate
)
);
vLevel
=
Vec_WecPushLevel
(
vFanins
);
for
(
i
=
0
;
i
<
(
int
)
pCellB
->
nFanins
;
i
++
)
Vec_IntPush
(
vLevel
,
pFanins
[(
int
)
pObjMin
->
pFansB
[
i
+
1
]]
);
if
(
pCellT
==
p
->
pCells
)
return
1
;
// create top gate
pGate
=
Mio_LibraryReadGateByName
(
pLib
,
pCellT
->
pName
,
NULL
);
Vec_IntPush
(
vGates
,
Mio_GateReadValue
(
pGate
)
);
vLevel
=
Vec_WecPushLevel
(
vFanins
);
for
(
i
=
0
;
i
<
(
int
)
pCellT
->
nFanins
;
i
++
)
if
(
pObjMin
->
pFansT
[
i
+
1
]
==
(
char
)
16
)
Vec_IntPush
(
vLevel
,
Vec_WecSize
(
vFanins
)
-
2
);
else
Vec_IntPush
(
vLevel
,
pFanins
[(
int
)
pObjMin
->
pFansT
[
i
+
1
]]
);
return
2
;
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
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