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
14606c47
Commit
14606c47
authored
Sep 12, 2013
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to the new technology mapper.
parent
0a346a36
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
17 deletions
+133
-17
src/aig/gia/gia.h
+1
-0
src/aig/gia/giaJf.c
+80
-15
src/base/abci/abc.c
+6
-2
src/misc/util/utilTruth.h
+46
-0
No files found.
src/aig/gia/gia.h
View file @
14606c47
...
...
@@ -244,6 +244,7 @@ struct Jf_Par_t_
int
fAreaOnly
;
int
fCoarsen
;
int
fCutMin
;
int
fUseTts
;
int
fVerbose
;
int
fVeryVerbose
;
int
nLutSizeMax
;
...
...
src/aig/gia/giaJf.c
View file @
14606c47
...
...
@@ -20,8 +20,10 @@
#include "gia.h"
#include "misc/vec/vecSet.h"
#include "misc/vec/vecMem.h"
#include "misc/extra/extra.h"
#include "bool/kit/kit.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
...
...
@@ -48,6 +50,7 @@ struct Jf_Man_t_
Gia_Man_t
*
pGia
;
// user's manager
Jf_Par_t
*
pPars
;
// users parameter
Sdm_Man_t
*
pDsd
;
// extern DSD manager
Vec_Mem_t
*
vTtMem
;
// truth table memory and hash table
Vec_Int_t
vCuts
;
// cuts for each node
Vec_Int_t
vArr
;
// arrival time
Vec_Int_t
vDep
;
// departure time
...
...
@@ -85,6 +88,9 @@ static inline int Jf_CutLit( int * pCut, int i ) { assert(i);return pCu
static
inline
int
Jf_CutVar
(
int
*
pCut
,
int
i
)
{
assert
(
i
);
return
Abc_Lit2Var
(
pCut
[
i
]);
}
static
inline
int
Jf_CutIsTriv
(
int
*
pCut
,
int
i
)
{
return
Jf_CutSize
(
pCut
)
==
1
&&
Jf_CutVar
(
pCut
,
1
)
==
i
;
}
static
inline
int
Jf_ObjFunc0
(
Gia_Obj_t
*
p
,
int
*
q
)
{
return
Abc_LitNotCond
(
Jf_CutFunc
(
q
),
Gia_ObjFaninC0
(
p
));
}
static
inline
int
Jf_ObjFunc1
(
Gia_Obj_t
*
p
,
int
*
q
)
{
return
Abc_LitNotCond
(
Jf_CutFunc
(
q
),
Gia_ObjFaninC1
(
p
));
}
#define Jf_ObjForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Jf_CutSize(pCut) + 1 )
#define Jf_CutForEachLit( pCut, Lit, i ) for ( i = 1; i <= Jf_CutSize(pCut) && (Lit = Jf_CutLit(pCut, i)); i++ )
#define Jf_CutForEachVar( pCut, Var, i ) for ( i = 1; i <= Jf_CutSize(pCut) && (Var = Jf_CutVar(pCut, i)); i++ )
...
...
@@ -220,7 +226,16 @@ Jf_Man_t * Jf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars )
p
=
ABC_CALLOC
(
Jf_Man_t
,
1
);
p
->
pGia
=
pGia
;
p
->
pPars
=
pPars
;
p
->
pDsd
=
pPars
->
fCutMin
?
Sdm_ManRead
()
:
NULL
;
if
(
pPars
->
fCutMin
&&
!
pPars
->
fUseTts
)
p
->
pDsd
=
Sdm_ManRead
();
else
if
(
pPars
->
fCutMin
&&
pPars
->
fUseTts
)
{
word
uTruth
;
int
Value
;
p
->
vTtMem
=
Vec_MemAlloc
(
1
,
12
);
// 32 KB/page for 6-var functions
Vec_MemHashAlloc
(
p
->
vTtMem
,
10000
);
uTruth
=
ABC_CONST
(
0x0000000000000000
);
Value
=
Vec_MemHashInsert
(
p
->
vTtMem
,
&
uTruth
);
assert
(
Value
==
0
);
uTruth
=
ABC_CONST
(
0xAAAAAAAAAAAAAAAA
);
Value
=
Vec_MemHashInsert
(
p
->
vTtMem
,
&
uTruth
);
assert
(
Value
==
1
);
}
Vec_IntFill
(
&
p
->
vCuts
,
Gia_ManObjNum
(
pGia
),
0
);
Vec_IntFill
(
&
p
->
vArr
,
Gia_ManObjNum
(
pGia
),
0
);
Vec_IntFill
(
&
p
->
vDep
,
Gia_ManObjNum
(
pGia
),
0
);
...
...
@@ -236,6 +251,8 @@ void Jf_ManFree( Jf_Man_t * p )
{
if
(
p
->
pPars
->
fVerbose
&&
p
->
pDsd
)
Sdm_ManPrintDsdStats
(
p
->
pDsd
,
0
);
if
(
p
->
pPars
->
fVerbose
&&
p
->
vTtMem
)
printf
(
"Unique truth tables = %d. Memory = %.2f MB
\n
"
,
Vec_MemEntryNum
(
p
->
vTtMem
),
Vec_MemMemory
(
p
->
vTtMem
)
/
(
1
<<
20
)
);
if
(
p
->
pPars
->
fVeryVerbose
&&
p
->
pPars
->
fCutMin
)
Jf_ManProfileClasses
(
p
);
if
(
p
->
pPars
->
fCoarsen
)
...
...
@@ -246,6 +263,11 @@ void Jf_ManFree( Jf_Man_t * p )
ABC_FREE
(
p
->
vDep
.
pArray
);
ABC_FREE
(
p
->
vFlow
.
pArray
);
ABC_FREE
(
p
->
vRefs
.
pArray
);
if
(
p
->
pPars
->
fCutMin
&&
p
->
pPars
->
fUseTts
)
{
Vec_MemHashFree
(
p
->
vTtMem
);
Vec_MemFree
(
p
->
vTtMem
);
}
Vec_SetFree_
(
&
p
->
pMem
);
Vec_IntFreeP
(
&
p
->
vTemp
);
ABC_FREE
(
p
);
...
...
@@ -853,6 +875,35 @@ static inline void Jf_ObjCheckStore( Jf_Man_t * p, Jf_Cut_t ** pSto, int c, int
/**Function*************************************************************
Synopsis [Cut minimization.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Jf_TtComputeForCut
(
Jf_Man_t
*
p
,
int
iFuncLit0
,
int
iFuncLit1
,
int
*
pCut0
,
int
*
pCut1
,
int
*
pCutOut
)
{
word
uTruth
;
int
fCompl
,
truthId
;
int
LutSize
=
p
->
pPars
->
nLutSize
;
word
*
pTruth0
=
Vec_MemReadEntry
(
p
->
vTtMem
,
Abc_Lit2Var
(
iFuncLit0
));
word
*
pTruth1
=
Vec_MemReadEntry
(
p
->
vTtMem
,
Abc_Lit2Var
(
iFuncLit1
));
word
uTruth0
=
Abc_LitIsCompl
(
iFuncLit0
)
?
~*
pTruth0
:
*
pTruth0
;
word
uTruth1
=
Abc_LitIsCompl
(
iFuncLit1
)
?
~*
pTruth1
:
*
pTruth1
;
Abc_TtStretch
(
&
uTruth0
,
LutSize
,
pCut0
+
1
,
Jf_CutSize
(
pCut0
),
pCutOut
+
1
,
Jf_CutSize
(
pCutOut
)
);
Abc_TtStretch
(
&
uTruth1
,
LutSize
,
pCut1
+
1
,
Jf_CutSize
(
pCut1
),
pCutOut
+
1
,
Jf_CutSize
(
pCutOut
)
);
Abc_TtAnd
(
&
uTruth
,
&
uTruth0
,
&
uTruth1
,
Abc_TtWordNum
(
LutSize
),
0
);
pCutOut
[
0
]
=
Abc_TtMinBase
(
&
uTruth
,
pCutOut
+
1
,
pCutOut
[
0
]
);
fCompl
=
(
uTruth
&
1
);
uTruth
=
fCompl
?
~
uTruth
:
uTruth
;
truthId
=
Vec_MemHashInsert
(
p
->
vTtMem
,
&
uTruth
);
return
Abc_Var2Lit
(
truthId
,
fCompl
);
}
/**Function*************************************************************
Synopsis [Cut enumeration.]
Description []
...
...
@@ -898,8 +949,7 @@ void Jf_ObjComputeCuts( Jf_Man_t * p, Gia_Obj_t * pObj, int fEdge )
Jf_Cut_t
Sto
[
JF_CUT_MAX
+
2
];
// cut storage
Jf_Cut_t
*
pSto
[
JF_CUT_MAX
+
2
];
// pointers to cut storage
int
*
pCut0
,
*
pCut1
,
*
pCuts0
,
*
pCuts1
;
int
iDsdLit0
,
iDsdLit1
,
nOldSupp
;
int
Config
,
i
,
k
,
c
=
0
;
int
nOldSupp
,
Config
,
i
,
k
,
c
=
0
;
// prepare cuts
for
(
i
=
0
;
i
<=
CutNum
+
1
;
i
++
)
pSto
[
i
]
=
Sto
+
i
,
pSto
[
i
]
->
iFunc
=
0
;
...
...
@@ -919,27 +969,36 @@ void Jf_ObjComputeCuts( Jf_Man_t * p, Gia_Obj_t * pObj, int fEdge )
if
(
Jf_CountBits
(
Sign0
[
i
]
|
Sign1
[
k
])
>
LutSize
)
continue
;
p
->
CutCount
[
1
]
++
;
if
(
p
->
pPars
->
fCutMin
)
if
(
!
p
->
pPars
->
fCutMin
)
{
if
(
!
(
Config
=
Jf_CutMerge2
(
pCut0
,
pCut1
,
pSto
[
c
]
->
pCut
,
LutSize
)
)
)
if
(
!
Jf_CutMergeOrder
(
pCut0
,
pCut1
,
pSto
[
c
]
->
pCut
,
LutSize
)
)
continue
;
pSto
[
c
]
->
Sign
=
Sign0
[
i
]
|
Sign1
[
k
];
nOldSupp
=
pSto
[
c
]
->
pCut
[
0
];
iDsdLit0
=
Abc_LitNotCond
(
Jf_CutFunc
(
pCut0
),
Gia_ObjFaninC0
(
pObj
)
);
iDsdLit1
=
Abc_LitNotCond
(
Jf_CutFunc
(
pCut1
),
Gia_ObjFaninC1
(
pObj
)
);
pSto
[
c
]
->
iFunc
=
Sdm_ManComputeFunc
(
p
->
pDsd
,
iDsdLit0
,
iDsdLit1
,
pSto
[
c
]
->
pCut
,
Config
,
0
);
if
(
pSto
[
c
]
->
iFunc
==
-
1
)
}
else
if
(
p
->
pPars
->
fUseTts
)
{
if
(
!
Jf_CutMergeOrder
(
pCut0
,
pCut1
,
pSto
[
c
]
->
pCut
,
LutSize
)
)
continue
;
pSto
[
c
]
->
Sign
=
Sign0
[
i
]
|
Sign1
[
k
];
nOldSupp
=
pSto
[
c
]
->
pCut
[
0
];
pSto
[
c
]
->
iFunc
=
Jf_TtComputeForCut
(
p
,
Jf_ObjFunc0
(
pObj
,
pCut0
),
Jf_ObjFunc1
(
pObj
,
pCut1
),
pCut0
,
pCut1
,
pSto
[
c
]
->
pCut
);
assert
(
pSto
[
c
]
->
pCut
[
0
]
<=
nOldSupp
);
if
(
pSto
[
c
]
->
pCut
[
0
]
<
nOldSupp
)
pSto
[
c
]
->
Sign
=
Jf_CutGetSign
(
pSto
[
c
]
->
pCut
);
//pSto[c]->Cost = Sdm_ManReadDsdClauseNum( p->pDsd, Abc_Lit2Var(pSto[c]->iFunc) );
}
else
{
if
(
!
Jf_CutMergeOrder
(
pCut0
,
pCut1
,
pSto
[
c
]
->
pCut
,
LutSize
)
)
if
(
!
(
Config
=
Jf_CutMerge2
(
pCut0
,
pCut1
,
pSto
[
c
]
->
pCut
,
LutSize
)
)
)
continue
;
pSto
[
c
]
->
Sign
=
Sign0
[
i
]
|
Sign1
[
k
];
nOldSupp
=
pSto
[
c
]
->
pCut
[
0
];
pSto
[
c
]
->
iFunc
=
Sdm_ManComputeFunc
(
p
->
pDsd
,
Jf_ObjFunc0
(
pObj
,
pCut0
),
Jf_ObjFunc1
(
pObj
,
pCut1
),
pSto
[
c
]
->
pCut
,
Config
,
0
);
if
(
pSto
[
c
]
->
iFunc
==
-
1
)
continue
;
assert
(
pSto
[
c
]
->
pCut
[
0
]
<=
nOldSupp
);
if
(
pSto
[
c
]
->
pCut
[
0
]
<
nOldSupp
)
pSto
[
c
]
->
Sign
=
Jf_CutGetSign
(
pSto
[
c
]
->
pCut
);
//pSto[c]->Cost = Sdm_ManReadDsdClauseNum( p->pDsd, Abc_Lit2Var(pSto[c]->iFunc) );
}
// Jf_CutCheck( pSto[c]->pCut );
p
->
CutCount
[
2
]
++
;
...
...
@@ -954,7 +1013,7 @@ void Jf_ObjComputeCuts( Jf_Man_t * p, Gia_Obj_t * pObj, int fEdge )
if
(
!
Jf_ObjIsUnit
(
pObj
)
&&
!
Jf_ObjHasCutWithSize
(
pSto
,
c
,
2
)
)
{
assert
(
Jf_ObjIsUnit
(
Gia_ObjFanin0
(
pObj
))
&&
Jf_ObjIsUnit
(
Gia_ObjFanin1
(
pObj
))
);
pSto
[
c
]
->
iFunc
=
p
->
pPars
->
fCutMin
?
4
:
0
;
// set function
pSto
[
c
]
->
iFunc
=
p
->
pPars
->
fCutMin
?
4
:
0
;
// set function
(DSD only!)
pSto
[
c
]
->
pCut
[
0
]
=
2
;
pSto
[
c
]
->
pCut
[
1
]
=
Jf_ObjLit
(
Gia_ObjFaninId0
(
pObj
,
iObj
),
Gia_ObjFaninC0
(
pObj
));
pSto
[
c
]
->
pCut
[
2
]
=
Jf_ObjLit
(
Gia_ObjFaninId1
(
pObj
,
iObj
),
Gia_ObjFaninC1
(
pObj
));
...
...
@@ -1188,8 +1247,12 @@ Gia_Man_t * Jf_ManDeriveMappingGia( Jf_Man_t * p )
continue
;
pCut
=
Jf_ObjCutBest
(
p
,
i
);
Class
=
Jf_CutFuncClass
(
pCut
);
if
(
p
->
pPars
->
fUseTts
)
uTruth
=
*
Vec_MemReadEntry
(
p
->
vTtMem
,
Class
);
else
uTruth
=
Sdm_ManReadDsdTruth
(
p
->
pDsd
,
Class
);
// printf( "Best cut of node %d: ", i ); Jf_CutPrint(pCut);
assert
(
Sdm_ManReadDsdVarNum
(
p
->
pDsd
,
Class
)
==
Jf_CutSize
(
pCut
)
);
//
assert( Sdm_ManReadDsdVarNum( p->pDsd, Class ) == Jf_CutSize(pCut) );
if
(
Jf_CutSize
(
pCut
)
==
0
)
{
assert
(
Class
==
0
);
...
...
@@ -1209,7 +1272,6 @@ Gia_Man_t * Jf_ManDeriveMappingGia( Jf_Man_t * p )
Jf_CutForEachLit
(
pCut
,
iLit
,
k
)
Vec_IntPush
(
vLeaves
,
Abc_Lit2LitL
(
Vec_IntArray
(
vCopies
),
iLit
)
);
// create GIA
uTruth
=
Sdm_ManReadDsdTruth
(
p
->
pDsd
,
Class
);
iLit
=
Kit_TruthToGia
(
pNew
,
(
unsigned
*
)
&
uTruth
,
Vec_IntSize
(
vLeaves
),
vCover
,
vLeaves
,
0
);
iLit
=
Abc_LitNotCond
(
iLit
,
Jf_CutFuncCompl
(
pCut
)
);
Vec_IntWriteEntry
(
vCopies
,
i
,
iLit
);
...
...
@@ -1291,6 +1353,7 @@ void Jf_ManSetDefaultPars( Jf_Par_t * pPars )
pPars
->
fAreaOnly
=
1
;
pPars
->
fCoarsen
=
0
;
pPars
->
fCutMin
=
0
;
pPars
->
fUseTts
=
0
;
pPars
->
fVerbose
=
0
;
pPars
->
fVeryVerbose
=
0
;
pPars
->
nLutSizeMax
=
JF_LEAF_MAX
;
...
...
@@ -1311,6 +1374,8 @@ Gia_Man_t * Jf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
{
Gia_Man_t
*
pNew
=
pGia
;
Jf_Man_t
*
p
;
int
i
;
if
(
pPars
->
fCutMin
&&
pPars
->
fUseTts
)
pPars
->
fCoarsen
=
0
;
p
=
Jf_ManAlloc
(
pGia
,
pPars
);
p
->
pCutCmp
=
pPars
->
fAreaOnly
?
Jf_CutCompareArea
:
Jf_CutCompareDelay
;
Jf_ManComputeCuts
(
p
,
0
);
...
...
src/base/abci/abc.c
View file @
14606c47
...
...
@@ -29847,7 +29847,7 @@ int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv )
int
c
;
Jf_ManSetDefaultPars
(
pPars
);
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"KCRDacmvwh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"KCRDacm
t
vwh"
)
)
!=
EOF
)
{
switch
(
c
)
{
...
...
@@ -29910,6 +29910,9 @@ int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv )
case
'm'
:
pPars
->
fCutMin
^=
1
;
break
;
case
't'
:
pPars
->
fUseTts
^=
1
;
break
;
case
'v'
:
pPars
->
fVerbose
^=
1
;
break
;
...
...
@@ -29948,7 +29951,7 @@ usage:
sprintf
(
Buffer
,
"best possible"
);
else
sprintf
(
Buffer
,
"%d"
,
pPars
->
DelayTarget
);
Abc_Print
(
-
2
,
"usage: &jf [-KCRD num] [-acvwh]
\n
"
);
Abc_Print
(
-
2
,
"usage: &jf [-KCRD num] [-ac
mt
vwh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
performs technology mapping of the network
\n
"
);
Abc_Print
(
-
2
,
"
\t
-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]
\n
"
,
pPars
->
nLutSizeMax
,
pPars
->
nLutSize
);
Abc_Print
(
-
2
,
"
\t
-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]
\n
"
,
pPars
->
nCutNumMax
,
pPars
->
nCutNum
);
...
...
@@ -29957,6 +29960,7 @@ usage:
Abc_Print
(
-
2
,
"
\t
-a : toggles area-oriented mapping [default = %s]
\n
"
,
pPars
->
fAreaOnly
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-c : toggles coarsening the subject graph [default = %s]
\n
"
,
pPars
->
fCoarsen
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-m : toggles cut minimization [default = %s]
\n
"
,
pPars
->
fCutMin
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-t : toggles truth tables for minimization [default = %s]
\n
"
,
pPars
->
fUseTts
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-v : toggles verbose output [default = %s]
\n
"
,
pPars
->
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-w : toggles very verbose output [default = %s]
\n
"
,
pPars
->
fVeryVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : prints the command usage
\n
"
);
src/misc/util/utilTruth.h
View file @
14606c47
...
...
@@ -1111,6 +1111,52 @@ static inline int Abc_TtMinimumBase( word * t, int * pSupp, int nVarsAll, int *
/**Function*************************************************************
Synopsis [Cut minimization.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Abc_TtMinBase
(
word
*
pTruth
,
int
*
pVars
,
int
nVars
)
{
int
i
,
k
;
for
(
i
=
k
=
0
;
i
<
nVars
;
i
++
)
{
if
(
!
Abc_TtHasVar
(
pTruth
,
nVars
,
i
)
)
continue
;
if
(
k
<
i
)
{
pVars
[
k
]
=
pVars
[
i
];
Abc_TtSwapVars
(
pTruth
,
nVars
,
k
,
i
);
}
k
++
;
}
if
(
k
==
nVars
)
return
k
;
assert
(
k
<
nVars
);
// assert( k == Abc_TtSupportSize(pTruth, nVars) );
return
k
;
}
static
inline
void
Abc_TtStretch
(
word
*
pTruth0
,
int
nVars
,
int
*
pCut0
,
int
nCutSize0
,
int
*
pCut
,
int
nCutSize
)
{
int
i
,
k
;
for
(
i
=
nCutSize
-
1
,
k
=
nCutSize0
-
1
;
i
>=
0
&&
k
>=
0
;
i
--
)
{
if
(
pCut
[
i
]
>
pCut0
[
k
]
)
continue
;
assert
(
pCut
[
i
]
==
pCut0
[
k
]
);
if
(
k
<
i
)
Abc_TtSwapVars
(
pTruth0
,
nVars
,
k
,
i
);
k
--
;
}
assert
(
k
==
-
1
);
}
/**Function*************************************************************
Synopsis [Implemeting given NPN config.]
Description []
...
...
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