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
372a348c
Commit
372a348c
authored
Nov 09, 2014
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detecting full-adder chains and putting them into white boxes.
parent
153e8887
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
593 additions
and
93 deletions
+593
-93
abclib.dsp
+4
-0
src/aig/gia/gia.h
+7
-0
src/aig/gia/giaFadds.c
+483
-55
src/aig/gia/giaTim.c
+38
-38
src/aig/gia/module.make
+1
-0
src/base/abci/abc.c
+60
-0
No files found.
abclib.dsp
View file @
372a348c
...
@@ -3815,6 +3815,10 @@ SOURCE=.\src\aig\gia\giaEra2.c
...
@@ -3815,6 +3815,10 @@ SOURCE=.\src\aig\gia\giaEra2.c
# End Source File
# End Source File
# Begin Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaFadds.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaFalse.c
SOURCE=.\src\aig\gia\giaFalse.c
# End Source File
# End Source File
# Begin Source File
# Begin Source File
...
...
src/aig/gia/gia.h
View file @
372a348c
...
@@ -719,6 +719,13 @@ static inline int Gia_ManAppendMux( Gia_Man_t * p, int iCtrl, int iData1, int iD
...
@@ -719,6 +719,13 @@ static inline int Gia_ManAppendMux( Gia_Man_t * p, int iCtrl, int iData1, int iD
int
iTemp1
=
Gia_ManAppendAnd
(
p
,
iCtrl
,
iData1
);
int
iTemp1
=
Gia_ManAppendAnd
(
p
,
iCtrl
,
iData1
);
return
Abc_LitNotCond
(
Gia_ManAppendAnd
(
p
,
Abc_LitNot
(
iTemp0
),
Abc_LitNot
(
iTemp1
)
),
1
);
return
Abc_LitNotCond
(
Gia_ManAppendAnd
(
p
,
Abc_LitNot
(
iTemp0
),
Abc_LitNot
(
iTemp1
)
),
1
);
}
}
static
inline
int
Gia_ManAppendMaj
(
Gia_Man_t
*
p
,
int
iData0
,
int
iData1
,
int
iData2
)
{
int
iTemp0
=
Gia_ManAppendOr
(
p
,
iData1
,
iData2
);
int
iTemp1
=
Gia_ManAppendAnd
(
p
,
iData0
,
iTemp0
);
int
iTemp2
=
Gia_ManAppendAnd
(
p
,
iData1
,
iData2
);
return
Gia_ManAppendOr
(
p
,
iTemp1
,
iTemp2
);
}
static
inline
int
Gia_ManAppendXor
(
Gia_Man_t
*
p
,
int
iLit0
,
int
iLit1
)
static
inline
int
Gia_ManAppendXor
(
Gia_Man_t
*
p
,
int
iLit0
,
int
iLit1
)
{
{
return
Gia_ManAppendMux
(
p
,
iLit0
,
Abc_LitNot
(
iLit1
),
iLit1
);
return
Gia_ManAppendMux
(
p
,
iLit0
,
Abc_LitNot
(
iLit1
),
iLit1
);
...
...
src/aig/gia/giaFadds.c
View file @
372a348c
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
***********************************************************************/
***********************************************************************/
#include "gia.h"
#include "gia.h"
#include "misc/vec/vecWec.h"
#include "misc/tim/tim.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -27,14 +29,63 @@ ABC_NAMESPACE_IMPL_START
...
@@ -27,14 +29,63 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#define Dtc_ForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += pCut[0] + 1 )
#define Dtc_ForEachFadd( vFadds, i ) for ( i = 0; i < Vec_IntSize(vFadds)/5; i++ )
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Derive GIA with boxes containing adder-chains.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Gia_ManIllustrateBoxes
(
Gia_Man_t
*
p
)
{
Tim_Man_t
*
pManTime
=
(
Tim_Man_t
*
)
p
->
pManTime
;
int
nBoxes
=
Tim_ManBoxNum
(
pManTime
);
int
i
,
k
,
curCi
,
curCo
,
nBoxIns
,
nBoxOuts
;
Gia_Obj_t
*
pObj
;
// walk through the boxes
curCi
=
Tim_ManPiNum
(
pManTime
);
curCo
=
0
;
for
(
i
=
0
;
i
<
Tim_ManBoxNum
(
pManTime
);
i
++
)
{
nBoxIns
=
Tim_ManBoxInputNum
(
pManTime
,
i
);
nBoxOuts
=
Tim_ManBoxOutputNum
(
pManTime
,
i
);
printf
(
"Box %4d [%d x %d] : "
,
i
,
nBoxIns
,
nBoxOuts
);
printf
(
"Input obj IDs = "
);
for
(
k
=
0
;
k
<
nBoxIns
;
k
++
)
{
pObj
=
Gia_ManCo
(
p
,
curCo
+
k
);
printf
(
"%d "
,
Gia_ObjId
(
p
,
pObj
)
);
}
printf
(
" Output obj IDs = "
);
for
(
k
=
0
;
k
<
nBoxOuts
;
k
++
)
{
pObj
=
Gia_ManCi
(
p
,
curCi
+
k
);
printf
(
"%d "
,
Gia_ObjId
(
p
,
pObj
)
);
}
curCo
+=
nBoxIns
;
curCi
+=
nBoxOuts
;
printf
(
"
\n
"
);
}
curCo
+=
Tim_ManPoNum
(
pManTime
);
// verify counts
assert
(
curCi
==
Gia_ManCiNum
(
p
)
);
assert
(
curCo
==
Gia_ManCoNum
(
p
)
);
}
/**Function*************************************************************
/**Function*************************************************************
Synopsis []
Synopsis [
Detecting FADDs in the AIG.
]
Description []
Description []
...
@@ -43,7 +94,6 @@ ABC_NAMESPACE_IMPL_START
...
@@ -43,7 +94,6 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
#define Dtc_ForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += pCut[0] + 1 )
int
Dtc_ManCutMergeOne
(
int
*
pCut0
,
int
*
pCut1
,
int
*
pCut
)
int
Dtc_ManCutMergeOne
(
int
*
pCut0
,
int
*
pCut1
,
int
*
pCut
)
{
{
int
i
,
k
;
int
i
,
k
;
...
@@ -108,21 +158,20 @@ void Dtc_ObjCleanTruth_rec( Gia_Obj_t * pObj )
...
@@ -108,21 +158,20 @@ void Dtc_ObjCleanTruth_rec( Gia_Obj_t * pObj )
Dtc_ObjCleanTruth_rec
(
Gia_ObjFanin0
(
pObj
)
);
Dtc_ObjCleanTruth_rec
(
Gia_ObjFanin0
(
pObj
)
);
Dtc_ObjCleanTruth_rec
(
Gia_ObjFanin1
(
pObj
)
);
Dtc_ObjCleanTruth_rec
(
Gia_ObjFanin1
(
pObj
)
);
}
}
int
Dtc_ObjComputeTruth
(
Gia_Man_t
*
p
,
int
iObj
,
int
*
pCut
)
int
Dtc_ObjComputeTruth
(
Gia_Man_t
*
p
,
int
iObj
,
int
*
pCut
,
int
*
pTruth
)
{
{
unsigned
Truth
,
Truths
[
3
]
=
{
0xAA
,
0xCC
,
0xF0
};
int
i
;
unsigned
Truth
,
Truths
[
3
]
=
{
0xAA
,
0xCC
,
0xF0
};
int
i
;
for
(
i
=
1
;
i
<=
pCut
[
0
];
i
++
)
for
(
i
=
1
;
i
<=
pCut
[
0
];
i
++
)
Gia_ManObj
(
p
,
pCut
[
i
])
->
Value
=
Truths
[
i
-
1
];
Gia_ManObj
(
p
,
pCut
[
i
])
->
Value
=
Truths
[
i
-
1
];
Truth
=
0xFF
&
Dtc_ObjComputeTruth_rec
(
Gia_ManObj
(
p
,
iObj
)
);
Truth
=
0xFF
&
Dtc_ObjComputeTruth_rec
(
Gia_ManObj
(
p
,
iObj
)
);
Dtc_ObjCleanTruth_rec
(
Gia_ManObj
(
p
,
iObj
)
);
Dtc_ObjCleanTruth_rec
(
Gia_ManObj
(
p
,
iObj
)
);
if
(
Truth
==
0x69
||
Truth
==
0x96
)
if
(
pTruth
)
*
pTruth
=
Truth
;
if
(
Truth
==
0x96
||
Truth
==
0x69
)
return
1
;
return
1
;
if
(
Truth
==
0x8E
||
Truth
==
0x4D
||
Truth
==
0x2B
||
Truth
==
0xE8
||
if
(
Truth
==
0xE8
||
Truth
==
0xD4
||
Truth
==
0xB2
||
Truth
==
0x71
||
Truth
==
0x71
||
Truth
==
0xB2
||
Truth
==
0xD4
||
Truth
==
0x17
)
Truth
==
0x17
||
Truth
==
0x2B
||
Truth
==
0x4D
||
Truth
==
0x8E
)
{
// printf( "%2x ", Truth );
return
2
;
return
2
;
}
return
0
;
return
0
;
}
}
void
Dtc_ManCutMerge
(
Gia_Man_t
*
p
,
int
iObj
,
int
*
pList0
,
int
*
pList1
,
Vec_Int_t
*
vCuts
,
Vec_Int_t
*
vCutsXor
,
Vec_Int_t
*
vCutsMaj
)
void
Dtc_ManCutMerge
(
Gia_Man_t
*
p
,
int
iObj
,
int
*
pList0
,
int
*
pList1
,
Vec_Int_t
*
vCuts
,
Vec_Int_t
*
vCutsXor
,
Vec_Int_t
*
vCutsMaj
)
...
@@ -143,7 +192,7 @@ void Dtc_ManCutMerge( Gia_Man_t * p, int iObj, int * pList0, int * pList1, Vec_I
...
@@ -143,7 +192,7 @@ void Dtc_ManCutMerge( Gia_Man_t * p, int iObj, int * pList0, int * pList1, Vec_I
Vec_IntPush
(
vCuts
,
pCut
[
c
]
);
Vec_IntPush
(
vCuts
,
pCut
[
c
]
);
if
(
pCut
[
0
]
!=
3
)
if
(
pCut
[
0
]
!=
3
)
continue
;
continue
;
Type
=
Dtc_ObjComputeTruth
(
p
,
iObj
,
pCut
);
Type
=
Dtc_ObjComputeTruth
(
p
,
iObj
,
pCut
,
NULL
);
if
(
Type
==
0
)
if
(
Type
==
0
)
continue
;
continue
;
vTemp
=
Type
==
1
?
vCutsXor
:
vCutsMaj
;
vTemp
=
Type
==
1
?
vCutsXor
:
vCutsMaj
;
...
@@ -152,7 +201,7 @@ void Dtc_ManCutMerge( Gia_Man_t * p, int iObj, int * pList0, int * pList1, Vec_I
...
@@ -152,7 +201,7 @@ void Dtc_ManCutMerge( Gia_Man_t * p, int iObj, int * pList0, int * pList1, Vec_I
Vec_IntPush
(
vTemp
,
iObj
);
Vec_IntPush
(
vTemp
,
iObj
);
}
}
}
}
void
Dtc_ManComputeCuts
(
Gia_Man_t
*
p
,
Vec_Int_t
**
pvCutsXor
,
Vec_Int_t
**
pvCutsMaj
)
void
Dtc_ManComputeCuts
(
Gia_Man_t
*
p
,
Vec_Int_t
**
pvCutsXor
,
Vec_Int_t
**
pvCutsMaj
,
int
fVerbose
)
{
{
Gia_Obj_t
*
pObj
;
Gia_Obj_t
*
pObj
;
int
*
pList0
,
*
pList1
,
i
,
nCuts
=
0
;
int
*
pList0
,
*
pList1
,
i
,
nCuts
=
0
;
...
@@ -178,6 +227,7 @@ void Dtc_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvCutsXor, Vec_Int_t ** pvC
...
@@ -178,6 +227,7 @@ void Dtc_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvCutsXor, Vec_Int_t ** pvC
Vec_IntAppend
(
vCuts
,
vTemp
);
Vec_IntAppend
(
vCuts
,
vTemp
);
nCuts
+=
Vec_IntSize
(
vTemp
);
nCuts
+=
Vec_IntSize
(
vTemp
);
}
}
if
(
fVerbose
)
printf
(
"Nodes = %d. Cuts = %d. Cuts/Node = %.2f. Ints/Node = %.2f.
\n
"
,
printf
(
"Nodes = %d. Cuts = %d. Cuts/Node = %.2f. Ints/Node = %.2f.
\n
"
,
Gia_ManAndNum
(
p
),
nCuts
,
1
.
0
*
nCuts
/
Gia_ManAndNum
(
p
),
1
.
0
*
Vec_IntSize
(
vCuts
)
/
Gia_ManAndNum
(
p
)
);
Gia_ManAndNum
(
p
),
nCuts
,
1
.
0
*
nCuts
/
Gia_ManAndNum
(
p
),
1
.
0
*
Vec_IntSize
(
vCuts
)
/
Gia_ManAndNum
(
p
)
);
Vec_IntFree
(
vTemp
);
Vec_IntFree
(
vTemp
);
...
@@ -185,16 +235,6 @@ void Dtc_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvCutsXor, Vec_Int_t ** pvC
...
@@ -185,16 +235,6 @@ void Dtc_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvCutsXor, Vec_Int_t ** pvC
*
pvCutsXor
=
vCutsXor
;
*
pvCutsXor
=
vCutsXor
;
*
pvCutsMaj
=
vCutsMaj
;
*
pvCutsMaj
=
vCutsMaj
;
}
}
int
Dtc_ManCompare
(
int
*
pCut0
,
int
*
pCut1
)
{
if
(
pCut0
[
0
]
<
pCut1
[
0
]
)
return
-
1
;
if
(
pCut0
[
0
]
>
pCut1
[
0
]
)
return
1
;
if
(
pCut0
[
1
]
<
pCut1
[
1
]
)
return
-
1
;
if
(
pCut0
[
1
]
>
pCut1
[
1
]
)
return
1
;
if
(
pCut0
[
2
]
<
pCut1
[
2
]
)
return
-
1
;
if
(
pCut0
[
2
]
>
pCut1
[
2
]
)
return
1
;
return
0
;
}
Vec_Int_t
*
Dtc_ManFindCommonCuts
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vCutsXor
,
Vec_Int_t
*
vCutsMaj
)
Vec_Int_t
*
Dtc_ManFindCommonCuts
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vCutsXor
,
Vec_Int_t
*
vCutsMaj
)
{
{
int
*
pCuts0
=
Vec_IntArray
(
vCutsXor
);
int
*
pCuts0
=
Vec_IntArray
(
vCutsXor
);
...
@@ -222,13 +262,13 @@ Vec_Int_t * Dtc_ManFindCommonCuts( Gia_Man_t * p, Vec_Int_t * vCutsXor, Vec_Int_
...
@@ -222,13 +262,13 @@ Vec_Int_t * Dtc_ManFindCommonCuts( Gia_Man_t * p, Vec_Int_t * vCutsXor, Vec_Int_
else
if
(
pCuts0
[
i
]
>
pCuts1
[
i
]
)
else
if
(
pCuts0
[
i
]
>
pCuts1
[
i
]
)
pCuts1
+=
4
;
pCuts1
+=
4
;
}
}
assert
(
Vec_IntSize
(
vFadds
)
%
5
==
0
);
return
vFadds
;
return
vFadds
;
}
}
void
Dtc_ManPrintFadds
(
Vec_Int_t
*
vFadds
)
void
Dtc_ManPrintFadds
(
Vec_Int_t
*
vFadds
)
{
{
int
i
,
nObjs
=
Vec_IntSize
(
vFadds
)
/
5
;
int
i
;
assert
(
Vec_IntSize
(
vFadds
)
%
5
==
0
);
Dtc_ForEachFadd
(
vFadds
,
i
)
for
(
i
=
0
;
i
<
nObjs
;
i
++
)
{
{
printf
(
"%6d : "
,
i
);
printf
(
"%6d : "
,
i
);
printf
(
"%6d "
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
0
)
);
printf
(
"%6d "
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
0
)
);
...
@@ -240,34 +280,213 @@ void Dtc_ManPrintFadds( Vec_Int_t * vFadds )
...
@@ -240,34 +280,213 @@ void Dtc_ManPrintFadds( Vec_Int_t * vFadds )
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
}
}
void
Dtc_ManSortChains
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
)
int
Dtc_ManCompare
(
int
*
pCut0
,
int
*
pCut1
)
{
{
Vec_Int_t
*
vMap
=
Vec_IntStartFull
(
Gia_ManObjNum
(
p
)
);
if
(
pCut0
[
0
]
<
pCut1
[
0
]
)
return
-
1
;
int
i
,
iFadd
,
Count
=
0
,
nObjs
=
Vec_IntSize
(
vFadds
)
/
5
;
if
(
pCut0
[
0
]
>
pCut1
[
0
]
)
return
1
;
assert
(
Vec_IntSize
(
vFadds
)
%
5
==
0
);
if
(
pCut0
[
1
]
<
pCut1
[
1
]
)
return
-
1
;
for
(
i
=
0
;
i
<
nObjs
;
i
++
)
if
(
pCut0
[
1
]
>
pCut1
[
1
]
)
return
1
;
if
(
pCut0
[
2
]
<
pCut1
[
2
]
)
return
-
1
;
if
(
pCut0
[
2
]
>
pCut1
[
2
]
)
return
1
;
return
0
;
}
int
Dtc_ManCompare2
(
int
*
pCut0
,
int
*
pCut1
)
{
if
(
pCut0
[
4
]
<
pCut1
[
4
]
)
return
-
1
;
if
(
pCut0
[
4
]
>
pCut1
[
4
]
)
return
1
;
return
0
;
}
// returns array of 5-tuples containing inputs/sum/cout of each full adder
Vec_Int_t
*
Gia_ManDetectFullAdders
(
Gia_Man_t
*
p
,
int
fVerbose
)
{
Vec_Int_t
*
vCutsXor
,
*
vCutsMaj
,
*
vFadds
;
Dtc_ManComputeCuts
(
p
,
&
vCutsXor
,
&
vCutsMaj
,
fVerbose
);
qsort
(
Vec_IntArray
(
vCutsXor
),
Vec_IntSize
(
vCutsXor
)
/
4
,
16
,
(
int
(
*
)(
const
void
*
,
const
void
*
))
Dtc_ManCompare
);
qsort
(
Vec_IntArray
(
vCutsMaj
),
Vec_IntSize
(
vCutsMaj
)
/
4
,
16
,
(
int
(
*
)(
const
void
*
,
const
void
*
))
Dtc_ManCompare
);
vFadds
=
Dtc_ManFindCommonCuts
(
p
,
vCutsXor
,
vCutsMaj
);
qsort
(
Vec_IntArray
(
vFadds
),
Vec_IntSize
(
vFadds
)
/
5
,
20
,
(
int
(
*
)(
const
void
*
,
const
void
*
))
Dtc_ManCompare2
);
if
(
fVerbose
)
printf
(
"XOR3 cuts = %d. MAJ cuts = %d. Fadds = %d.
\n
"
,
Vec_IntSize
(
vCutsXor
)
/
4
,
Vec_IntSize
(
vCutsMaj
)
/
4
,
Vec_IntSize
(
vFadds
)
/
5
);
//Dtc_ManPrintFadds( vFadds );
Vec_IntFree
(
vCutsXor
);
Vec_IntFree
(
vCutsMaj
);
return
vFadds
;
}
/**Function*************************************************************
Synopsis [Map each MAJ into the topmost MAJ of its chain.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
// maps MAJ nodes into FADD indexes
Vec_Int_t
*
Gia_ManCreateMap
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
)
{
Vec_Int_t
*
vMap
=
Vec_IntStartFull
(
Gia_ManObjNum
(
p
)
);
int
i
;
Dtc_ForEachFadd
(
vFadds
,
i
)
Vec_IntWriteEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
4
),
i
);
Vec_IntWriteEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
4
),
i
);
for
(
i
=
0
;
i
<
nObjs
;
i
++
)
return
vMap
;
{
}
int
fFound
=
0
;
// find chain length (for each MAJ, how many FADDs are rooted in its first input)
if
(
(
iFadd
=
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
0
)
))
>=
0
)
int
Gia_ManFindChains_rec
(
Gia_Man_t
*
p
,
int
iMaj
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vLength
)
printf
(
"%d -> %d
\n
"
,
iFadd
,
i
),
fFound
++
;
{
if
(
(
iFadd
=
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
1
)
))
>=
0
)
assert
(
Vec_IntEntry
(
vMap
,
iMaj
)
>=
0
);
// MAJ
printf
(
"%d -> %d
\n
"
,
iFadd
,
i
),
fFound
++
;
if
(
Vec_IntEntry
(
vLength
,
iMaj
)
>=
0
)
if
(
(
iFadd
=
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
2
)
))
>=
0
)
return
Vec_IntEntry
(
vLength
,
iMaj
);
printf
(
"%d -> %d
\n
"
,
iFadd
,
i
),
fFound
++
;
assert
(
Gia_ObjIsAnd
(
Gia_ManObj
(
p
,
iMaj
))
);
if
(
!
fFound
)
{
int
iFadd
=
Vec_IntEntry
(
vMap
,
iMaj
);
int
iXor0
=
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
0
);
int
iXor1
=
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
1
);
int
iXor2
=
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
2
);
int
iLen0
=
Vec_IntEntry
(
vMap
,
iXor0
)
==
-
1
?
0
:
Gia_ManFindChains_rec
(
p
,
iXor0
,
vFadds
,
vMap
,
vLength
);
int
iLen1
=
Vec_IntEntry
(
vMap
,
iXor1
)
==
-
1
?
0
:
Gia_ManFindChains_rec
(
p
,
iXor1
,
vFadds
,
vMap
,
vLength
);
int
iLen2
=
Vec_IntEntry
(
vMap
,
iXor2
)
==
-
1
?
0
:
Gia_ManFindChains_rec
(
p
,
iXor2
,
vFadds
,
vMap
,
vLength
);
int
iLen
=
Abc_MaxInt
(
iLen0
,
Abc_MaxInt
(
iLen1
,
iLen2
)
);
if
(
iLen0
<
iLen
)
{
if
(
iLen
==
iLen1
)
{
ABC_SWAP
(
int
,
Vec_IntArray
(
vFadds
)[
5
*
iFadd
+
0
],
Vec_IntArray
(
vFadds
)[
5
*
iFadd
+
1
]
);
}
else
if
(
iLen
==
iLen2
)
{
ABC_SWAP
(
int
,
Vec_IntArray
(
vFadds
)[
5
*
iFadd
+
0
],
Vec_IntArray
(
vFadds
)[
5
*
iFadd
+
2
]
);
}
}
Vec_IntWriteEntry
(
vLength
,
iMaj
,
iLen
+
1
);
return
iLen
+
1
;
}
}
// for each FADD find the longest chain and reorder its inputs
void
Gia_ManFindChains
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
)
{
int
i
;
// for each FADD find the longest chain rooted in it
Vec_Int_t
*
vLength
=
Vec_IntStartFull
(
Gia_ManObjNum
(
p
)
);
Dtc_ForEachFadd
(
vFadds
,
i
)
Gia_ManFindChains_rec
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
4
),
vFadds
,
vMap
,
vLength
);
Vec_IntFree
(
vLength
);
}
// collect one carry-chain
void
Gia_ManCollectOneChain
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
,
int
iFaddTop
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vChain
)
{
int
iFadd
;
Vec_IntClear
(
vChain
);
for
(
iFadd
=
iFaddTop
;
iFadd
>=
0
&&
!
Gia_ObjIsTravIdCurrentId
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
3
))
&&
!
Gia_ObjIsTravIdCurrentId
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
));
iFadd
=
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
0
))
)
{
Vec_IntPush
(
vChain
,
iFadd
);
}
Vec_IntReverseOrder
(
vChain
);
}
void
Gia_ManMarkWithTravId_rec
(
Gia_Man_t
*
p
,
int
Id
)
{
Gia_Obj_t
*
pObj
;
if
(
Gia_ObjIsTravIdCurrentId
(
p
,
Id
)
)
return
;
Gia_ObjSetTravIdCurrentId
(
p
,
Id
);
pObj
=
Gia_ManObj
(
p
,
Id
);
if
(
Gia_ObjIsAnd
(
pObj
)
)
Gia_ManMarkWithTravId_rec
(
p
,
Gia_ObjFaninId0
(
pObj
,
Id
)
);
if
(
Gia_ObjIsAnd
(
pObj
)
)
Gia_ManMarkWithTravId_rec
(
p
,
Gia_ObjFaninId1
(
pObj
,
Id
)
);
}
// returns mapping of each MAJ into the topmost elements of its chain
Vec_Wec_t
*
Gia_ManCollectTopmost
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
int
nFaddMin
)
{
int
i
,
j
,
iFadd
;
Vec_Int_t
*
vChain
=
Vec_IntAlloc
(
100
);
Vec_Wec_t
*
vChains
=
Vec_WecAlloc
(
Vec_IntSize
(
vFadds
)
/
5
);
// erase elements appearing as FADD inputs
Vec_Bit_t
*
vMarksTop
=
Vec_BitStart
(
Vec_IntSize
(
vFadds
)
/
5
);
Dtc_ForEachFadd
(
vFadds
,
i
)
if
(
(
iFadd
=
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
0
)))
>=
0
)
Vec_BitWriteEntry
(
vMarksTop
,
iFadd
,
1
);
// compress the remaining ones
Gia_ManIncrementTravId
(
p
);
Dtc_ForEachFadd
(
vFadds
,
i
)
{
if
(
Vec_BitEntry
(
vMarksTop
,
i
)
)
continue
;
Gia_ManCollectOneChain
(
p
,
vFadds
,
i
,
vMap
,
vChain
);
if
(
Vec_IntSize
(
vChain
)
<
nFaddMin
)
continue
;
Vec_IntAppend
(
Vec_WecPushLevel
(
vChains
),
vChain
);
Vec_IntForEachEntry
(
vChain
,
iFadd
,
j
)
{
assert
(
!
Gia_ObjIsTravIdCurrentId
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
3
))
);
assert
(
!
Gia_ObjIsTravIdCurrentId
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
))
);
Gia_ManMarkWithTravId_rec
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
3
)
);
Gia_ManMarkWithTravId_rec
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
)
);
}
}
// cleanup
Vec_BitFree
(
vMarksTop
);
Vec_IntFree
(
vChain
);
return
vChains
;
}
// prints chains beginning in majority nodes contained in vTops
void
Gia_ManPrintChains
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
Vec_Wec_t
*
vChains
)
{
Vec_Int_t
*
vChain
;
int
i
,
k
,
iFadd
,
Count
=
0
;
Vec_WecForEachLevel
(
vChains
,
vChain
,
i
)
{
Count
+=
Vec_IntSize
(
vChain
);
if
(
i
<
10
)
{
printf
(
"Chain %4d : %4d "
,
i
,
Vec_IntSize
(
vChain
)
);
Vec_IntForEachEntry
(
vChain
,
iFadd
,
k
)
{
printf
(
"%d(%d) "
,
iFadd
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
)
);
if
(
k
!=
Vec_IntSize
(
vChain
)
-
1
)
printf
(
"-> "
);
if
(
k
>
6
)
{
printf
(
"..."
);
break
;
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
if
(
fFound
>
1
)
Count
++
;
}
}
// printf( "%d \n", Count );
else
if
(
i
==
10
)
Vec_IntFree
(
vMap
);
printf
(
"...
\n
"
);
}
printf
(
"Total chains = %d. Total full-adders = %d.
\n
"
,
Vec_WecSize
(
vChains
),
Count
);
}
// map SUM bits and topmost MAJ into topmost FADD number
Vec_Int_t
*
Gia_ManFindMapping
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
Vec_Wec_t
*
vChains
)
{
Vec_Int_t
*
vChain
;
int
i
,
k
,
iFadd
;
Vec_Int_t
*
vMap2Chain
=
Vec_IntStartFull
(
Gia_ManObjNum
(
p
)
);
Vec_WecForEachLevel
(
vChains
,
vChain
,
i
)
{
Vec_IntForEachEntry
(
vChain
,
iFadd
,
k
)
{
//printf( "Chain %d: setting SUM %d (obj %d)\n", i, k, Vec_IntEntry(vFadds, 5*iFadd+3) );
assert
(
Vec_IntEntry
(
vMap2Chain
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
3
))
==
-
1
);
Vec_IntWriteEntry
(
vMap2Chain
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
3
),
i
);
}
//printf( "Chain %d: setting CARRY (obj %d)\n", i, Vec_IntEntry(vFadds, 5*iFadd+4) );
assert
(
Vec_IntEntry
(
vMap2Chain
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
))
==
-
1
);
Vec_IntWriteEntry
(
vMap2Chain
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
),
i
);
}
return
vMap2Chain
;
}
}
/**Function*************************************************************
/**Function*************************************************************
Synopsis []
Synopsis [
Derive GIA with boxes containing adder-chains.
]
Description []
Description []
...
@@ -276,19 +495,228 @@ void Dtc_ManSortChains( Gia_Man_t * p, Vec_Int_t * vFadds )
...
@@ -276,19 +495,228 @@ void Dtc_ManSortChains( Gia_Man_t * p, Vec_Int_t * vFadds )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Gia_ManDetectCarryChains
(
Gia_Man_t
*
p
)
Vec_Int_t
*
Gia_ManCollectTruthTables
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vFadds
)
{
{
Vec_Int_t
*
vCutsXor
,
*
vCutsMaj
,
*
vFadds
;
int
i
,
k
,
Type
,
Truth
,
pCut
[
4
]
=
{
3
};
Dtc_ManComputeCuts
(
p
,
&
vCutsXor
,
&
vCutsMaj
);
Vec_Int_t
*
vTruths
=
Vec_IntAlloc
(
2
*
Vec_IntSize
(
vFadds
)
/
5
);
qsort
(
Vec_IntArray
(
vCutsXor
),
Vec_IntSize
(
vCutsXor
)
/
4
,
16
,
(
int
(
*
)(
const
void
*
,
const
void
*
))
Dtc_ManCompare
);
Gia_ManCleanValue
(
p
);
qsort
(
Vec_IntArray
(
vCutsMaj
),
Vec_IntSize
(
vCutsMaj
)
/
4
,
16
,
(
int
(
*
)(
const
void
*
,
const
void
*
))
Dtc_ManCompare
);
Dtc_ForEachFadd
(
vFadds
,
i
)
vFadds
=
Dtc_ManFindCommonCuts
(
p
,
vCutsXor
,
vCutsMaj
);
{
printf
(
"XOR3 cuts = %d. MAJ cuts = %d. Fadds = %d.
\n
"
,
Vec_IntSize
(
vCutsXor
)
/
4
,
Vec_IntSize
(
vCutsMaj
)
/
4
,
Vec_IntSize
(
vFadds
)
/
5
);
for
(
k
=
0
;
k
<
3
;
k
++
)
// Dtc_ManPrintFadds( vFadds );
pCut
[
k
+
1
]
=
Vec_IntEntry
(
vFadds
,
5
*
i
+
k
);
Dtc_ManSortChains
(
p
,
vFadds
);
Type
=
Dtc_ObjComputeTruth
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
3
),
pCut
,
&
Truth
);
Vec_IntFree
(
vCutsXor
);
assert
(
Type
==
1
);
Vec_IntFree
(
vCutsMaj
);
Vec_IntPush
(
vTruths
,
Truth
);
Type
=
Dtc_ObjComputeTruth
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
i
+
4
),
pCut
,
&
Truth
);
assert
(
Type
==
2
);
Vec_IntPush
(
vTruths
,
Truth
);
}
return
vTruths
;
}
float
*
Gia_ManGenerateDelayTableFloat
(
int
nIns
,
int
nOuts
)
{
int
i
,
Total
=
nIns
*
nOuts
;
float
*
pDelayTable
=
ABC_ALLOC
(
float
,
Total
+
3
);
pDelayTable
[
0
]
=
0
;
pDelayTable
[
1
]
=
nIns
;
pDelayTable
[
2
]
=
nOuts
;
for
(
i
=
0
;
i
<
Total
;
i
++
)
pDelayTable
[
i
+
3
]
=
1
;
pDelayTable
[
i
+
3
-
nIns
]
=
-
ABC_INFINITY
;
return
pDelayTable
;
}
Tim_Man_t
*
Gia_ManGenerateTim
(
int
nPis
,
int
nPos
,
int
nBoxes
,
int
nIns
,
int
nOuts
)
{
Tim_Man_t
*
pMan
;
int
i
,
curPi
,
curPo
;
Vec_Ptr_t
*
vDelayTables
=
Vec_PtrAlloc
(
1
);
Vec_PtrPush
(
vDelayTables
,
Gia_ManGenerateDelayTableFloat
(
nIns
,
nOuts
)
);
pMan
=
Tim_ManStart
(
nPis
+
nOuts
*
nBoxes
,
nPos
+
nIns
*
nBoxes
);
Tim_ManSetDelayTables
(
pMan
,
vDelayTables
);
curPi
=
nPis
;
curPo
=
0
;
for
(
i
=
0
;
i
<
nBoxes
;
i
++
)
{
Tim_ManCreateBox
(
pMan
,
curPo
,
nIns
,
curPi
,
nOuts
,
0
);
curPi
+=
nOuts
;
curPo
+=
nIns
;
}
curPo
+=
nPos
;
assert
(
curPi
==
Tim_ManCiNum
(
pMan
)
);
assert
(
curPo
==
Tim_ManCoNum
(
pMan
)
);
//Tim_ManPrint( pMan );
return
pMan
;
}
Gia_Man_t
*
Gia_ManGenerateExtraAig
(
int
nBoxes
,
int
nIns
,
int
nOuts
)
{
Gia_Man_t
*
pNew
=
Gia_ManStart
(
nBoxes
*
20
);
int
i
,
k
,
pInLits
[
16
],
pOutLits
[
16
];
assert
(
nIns
<
16
&&
nOuts
<
16
);
for
(
i
=
0
;
i
<
nIns
;
i
++
)
pInLits
[
i
]
=
Gia_ManAppendCi
(
pNew
);
pOutLits
[
0
]
=
Gia_ManAppendXor
(
pNew
,
Gia_ManAppendXor
(
pNew
,
pInLits
[
0
],
pInLits
[
1
]),
pInLits
[
2
]
);
pOutLits
[
1
]
=
Gia_ManAppendMaj
(
pNew
,
pInLits
[
0
],
pInLits
[
1
],
pInLits
[
2
]
);
for
(
i
=
0
;
i
<
nBoxes
;
i
++
)
for
(
k
=
0
;
k
<
nOuts
;
k
++
)
Gia_ManAppendCo
(
pNew
,
pOutLits
[
k
]
);
return
pNew
;
}
void
Gia_ManDupFadd
(
Gia_Man_t
*
pNew
,
Gia_Man_t
*
p
,
Vec_Int_t
*
vChain
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
Vec_Wec_t
*
vChains
,
Vec_Int_t
*
vMap2Chain
,
Vec_Int_t
*
vTruths
)
{
extern
void
Gia_ManDupWithFaddBoxes_rec
(
Gia_Man_t
*
pNew
,
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
Vec_Wec_t
*
vChains
,
Vec_Int_t
*
vMap2Chain
,
Vec_Int_t
*
vTruths
);
int
i
,
k
,
iFadd
,
iCiLit
,
pLits
[
3
];
Gia_Obj_t
*
pObj
;
// construct FADD inputs
Vec_IntForEachEntry
(
vChain
,
iFadd
,
i
)
for
(
k
=
0
;
k
<
3
;
k
++
)
{
if
(
i
&&
!
k
)
continue
;
pObj
=
Gia_ManObj
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
k
)
);
Gia_ManDupWithFaddBoxes_rec
(
pNew
,
p
,
pObj
,
vFadds
,
vMap
,
vChains
,
vMap2Chain
,
vTruths
);
}
// construct boxes
iCiLit
=
0
;
Vec_IntForEachEntry
(
vChain
,
iFadd
,
i
)
{
int
iXorTruth
=
Vec_IntEntry
(
vTruths
,
2
*
iFadd
+
0
);
int
iMajTruth
=
Vec_IntEntry
(
vTruths
,
2
*
iFadd
+
1
);
for
(
k
=
0
;
k
<
3
;
k
++
)
{
pObj
=
Gia_ManObj
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
k
)
);
pLits
[
k
]
=
(
!
k
&&
iCiLit
)
?
iCiLit
:
pObj
->
Value
;
assert
(
pLits
[
k
]
>=
0
);
}
// normalize truth table
// if ( Truth == 0xE8 || Truth == 0xD4 || Truth == 0xB2 || Truth == 0x71 ||
// Truth == 0x17 || Truth == 0x2B || Truth == 0x4D || Truth == 0x8E )
if
(
iMajTruth
==
0x4D
)
pLits
[
0
]
=
Abc_LitNot
(
pLits
[
0
]),
iMajTruth
=
0x8E
,
iXorTruth
=
0xFF
&
~
iXorTruth
;
else
if
(
iMajTruth
==
0xD4
)
pLits
[
0
]
=
Abc_LitNot
(
pLits
[
0
]),
iMajTruth
=
0xE8
,
iXorTruth
=
0xFF
&
~
iXorTruth
;
else
if
(
iMajTruth
==
0x2B
)
pLits
[
1
]
=
Abc_LitNot
(
pLits
[
1
]),
iMajTruth
=
0x8E
,
iXorTruth
=
0xFF
&
~
iXorTruth
;
else
if
(
iMajTruth
==
0xB2
)
pLits
[
1
]
=
Abc_LitNot
(
pLits
[
1
]),
iMajTruth
=
0xE8
,
iXorTruth
=
0xFF
&
~
iXorTruth
;
if
(
iMajTruth
==
0x8E
)
pLits
[
2
]
=
Abc_LitNot
(
pLits
[
2
]),
iMajTruth
=
0xE8
,
iXorTruth
=
0xFF
&
~
iXorTruth
;
else
if
(
iMajTruth
==
0x71
)
pLits
[
2
]
=
Abc_LitNot
(
pLits
[
2
]),
iMajTruth
=
0x17
,
iXorTruth
=
0xFF
&
~
iXorTruth
;
else
assert
(
iMajTruth
==
0xE8
||
iMajTruth
==
0x17
);
// normalize carry-in
if
(
Abc_LitIsCompl
(
pLits
[
0
])
)
{
for
(
k
=
0
;
k
<
3
;
k
++
)
pLits
[
k
]
=
Abc_LitNot
(
pLits
[
k
]);
iXorTruth
=
0xFF
&
~
iXorTruth
;
iMajTruth
=
0xFF
&
~
iMajTruth
;
}
// add COs
assert
(
!
Abc_LitIsCompl
(
pLits
[
0
])
);
for
(
k
=
0
;
k
<
3
;
k
++
)
Gia_ManAppendCo
(
pNew
,
pLits
[
k
]
);
// create CI
assert
(
iXorTruth
==
0x96
||
iXorTruth
==
0x69
);
pObj
=
Gia_ManObj
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
3
)
);
pObj
->
Value
=
Abc_LitNotCond
(
Gia_ManAppendCi
(
pNew
),
(
int
)(
iXorTruth
==
0x69
)
);
// create CI
assert
(
iMajTruth
==
0xE8
||
iMajTruth
==
0x17
);
iCiLit
=
Abc_LitNotCond
(
Gia_ManAppendCi
(
pNew
),
(
int
)(
iMajTruth
==
0x17
)
);
}
// assign carry out
assert
(
iFadd
==
Vec_IntEntryLast
(
vChain
)
);
pObj
=
Gia_ManObj
(
p
,
Vec_IntEntry
(
vFadds
,
5
*
iFadd
+
4
)
);
pObj
->
Value
=
iCiLit
;
}
void
Gia_ManDupWithFaddBoxes_rec
(
Gia_Man_t
*
pNew
,
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
,
Vec_Int_t
*
vFadds
,
Vec_Int_t
*
vMap
,
Vec_Wec_t
*
vChains
,
Vec_Int_t
*
vMap2Chain
,
Vec_Int_t
*
vTruths
)
{
int
iChain
;
if
(
~
pObj
->
Value
)
return
;
assert
(
Gia_ObjIsAnd
(
pObj
)
);
iChain
=
Vec_IntEntry
(
vMap2Chain
,
Gia_ObjId
(
p
,
pObj
)
);
/*
assert( iChain == -1 );
if ( iChain >= 0 )
{
Gia_ManDupFadd( pNew, p, Vec_WecEntry(vChains, iChain), vFadds, vMap, vChains, vMap2Chain, vTruths );
assert( ~pObj->Value );
return;
}
*/
Gia_ManDupWithFaddBoxes_rec
(
pNew
,
p
,
Gia_ObjFanin0
(
pObj
),
vFadds
,
vMap
,
vChains
,
vMap2Chain
,
vTruths
);
Gia_ManDupWithFaddBoxes_rec
(
pNew
,
p
,
Gia_ObjFanin1
(
pObj
),
vFadds
,
vMap
,
vChains
,
vMap2Chain
,
vTruths
);
pObj
->
Value
=
Gia_ManAppendAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
}
Gia_Man_t
*
Gia_ManDupWithFaddBoxes
(
Gia_Man_t
*
p
,
int
nFaddMin
,
int
fVerbose
)
{
Gia_Man_t
*
pNew
,
*
pTemp
;
Vec_Int_t
*
vFadds
,
*
vMap
,
*
vMap2Chain
,
*
vTruths
,
*
vChain
;
Vec_Wec_t
*
vChains
;
Gia_Obj_t
*
pObj
;
int
i
,
nBoxes
;
// detect FADDs
vFadds
=
Gia_ManDetectFullAdders
(
p
,
fVerbose
);
assert
(
Vec_IntSize
(
vFadds
)
%
5
==
0
);
// map MAJ into its FADD
vMap
=
Gia_ManCreateMap
(
p
,
vFadds
);
// for each FADD, find the longest chain and reorder its inputs
Gia_ManFindChains
(
p
,
vFadds
,
vMap
);
// returns the set of topmost MAJ nodes
vChains
=
Gia_ManCollectTopmost
(
p
,
vFadds
,
vMap
,
nFaddMin
);
if
(
fVerbose
)
Gia_ManPrintChains
(
p
,
vFadds
,
vMap
,
vChains
);
if
(
Vec_WecSize
(
vChains
)
==
0
)
{
Vec_IntFree
(
vFadds
);
Vec_IntFree
(
vFadds
);
Vec_IntFree
(
vMap
);
Vec_WecFree
(
vChains
);
return
Gia_ManDup
(
p
);
}
// returns mapping of each MAJ into the topmost elements of its chain
vMap2Chain
=
Gia_ManFindMapping
(
p
,
vFadds
,
vMap
,
vChains
);
// compute truth tables for FADDs
vTruths
=
Gia_ManCollectTruthTables
(
p
,
vFadds
);
// duplicate
Gia_ManFillValue
(
p
);
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Abc_UtilStrsav
(
p
->
pName
);
pNew
->
pSpec
=
Abc_UtilStrsav
(
p
->
pSpec
);
Gia_ManConst0
(
p
)
->
Value
=
0
;
Gia_ManForEachCi
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
Vec_WecForEachLevel
(
vChains
,
vChain
,
i
)
Gia_ManDupFadd
(
pNew
,
p
,
vChain
,
vFadds
,
vMap
,
vChains
,
vMap2Chain
,
vTruths
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ManDupWithFaddBoxes_rec
(
pNew
,
p
,
Gia_ObjFanin0
(
pObj
),
vFadds
,
vMap
,
vChains
,
vMap2Chain
,
vTruths
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
assert
(
!
Gia_ManHasDangling
(
pNew
)
);
// cleanup
Vec_IntFree
(
vFadds
);
Vec_IntFree
(
vMap
);
Vec_WecFree
(
vChains
);
Vec_IntFree
(
vMap2Chain
);
Vec_IntFree
(
vTruths
);
// normalize
pNew
=
Gia_ManDupNormalize
(
pTemp
=
pNew
);
Gia_ManStop
(
pTemp
);
// other information
nBoxes
=
(
Gia_ManCiNum
(
pNew
)
-
Gia_ManCiNum
(
p
))
/
2
;
assert
(
nBoxes
==
(
Gia_ManCoNum
(
pNew
)
-
Gia_ManCoNum
(
p
))
/
3
);
pNew
->
pManTime
=
Gia_ManGenerateTim
(
Gia_ManCiNum
(
p
),
Gia_ManCoNum
(
p
),
nBoxes
,
3
,
2
);
pNew
->
pAigExtra
=
Gia_ManGenerateExtraAig
(
nBoxes
,
3
,
2
);
//pNew = Gia_ManDupCollapse( pTemp = pNew, pNew->pAigExtra, NULL );
//Gia_ManStop( pTemp );
//Gia_ManIllustrateBoxes( pNew );
return
pNew
;
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
src/aig/gia/giaTim.c
View file @
372a348c
...
@@ -117,7 +117,7 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
...
@@ -117,7 +117,7 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
// include primary inputs
// include primary inputs
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
i
);
pObj
=
Gia_Man
C
i
(
p
,
i
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
assert
(
Gia_ObjId
(
p
,
pObj
)
==
i
+
1
);
assert
(
Gia_ObjId
(
p
,
pObj
)
==
i
+
1
);
...
@@ -130,7 +130,7 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
...
@@ -130,7 +130,7 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
// add internal nodes
// add internal nodes
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
curCo
+
k
);
pObj
=
Gia_Man
C
o
(
p
,
curCo
+
k
);
if
(
Gia_ManOrderWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
vNodes
)
)
if
(
Gia_ManOrderWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
vNodes
)
)
{
{
int
iCiNum
=
p
->
iData2
;
int
iCiNum
=
p
->
iData2
;
...
@@ -151,14 +151,14 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
...
@@ -151,14 +151,14 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
// add POs corresponding to box inputs
// add POs corresponding to box inputs
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
curCo
+
k
);
pObj
=
Gia_Man
C
o
(
p
,
curCo
+
k
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
}
}
curCo
+=
Tim_ManBoxInputNum
(
pManTime
,
i
);
curCo
+=
Tim_ManBoxInputNum
(
pManTime
,
i
);
// add PIs corresponding to box outputs
// add PIs corresponding to box outputs
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
curCi
+
k
);
pObj
=
Gia_Man
C
i
(
p
,
curCi
+
k
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
}
}
...
@@ -167,19 +167,19 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
...
@@ -167,19 +167,19 @@ Vec_Int_t * Gia_ManOrderWithBoxes( Gia_Man_t * p )
// add remaining nodes
// add remaining nodes
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
i
);
pObj
=
Gia_Man
C
o
(
p
,
i
);
Gia_ManOrderWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
vNodes
);
Gia_ManOrderWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
vNodes
);
}
}
// add POs
// add POs
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
i
);
pObj
=
Gia_Man
C
o
(
p
,
i
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
Vec_IntPush
(
vNodes
,
Gia_ObjId
(
p
,
pObj
)
);
}
}
curCo
+=
Tim_ManPoNum
(
pManTime
);
curCo
+=
Tim_ManPoNum
(
pManTime
);
// verify counts
// verify counts
assert
(
curCi
==
Gia_Man
P
iNum
(
p
)
);
assert
(
curCi
==
Gia_Man
C
iNum
(
p
)
);
assert
(
curCo
==
Gia_Man
P
oNum
(
p
)
);
assert
(
curCo
==
Gia_Man
C
oNum
(
p
)
);
assert
(
Vec_IntSize
(
vNodes
)
==
Gia_ManObjNum
(
p
)
);
assert
(
Vec_IntSize
(
vNodes
)
==
Gia_ManObjNum
(
p
)
);
return
vNodes
;
return
vNodes
;
}
}
...
@@ -292,8 +292,8 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
...
@@ -292,8 +292,8 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
Gia_Man_t
*
pNew
,
*
pTemp
;
Gia_Man_t
*
pNew
,
*
pTemp
;
Gia_Obj_t
*
pObj
,
*
pObjBox
;
Gia_Obj_t
*
pObj
,
*
pObjBox
;
int
i
,
k
,
curCi
,
curCo
;
int
i
,
k
,
curCi
,
curCo
;
assert
(
Gia_ManRegNum
(
p
)
==
0
);
//
assert( Gia_ManRegNum(p) == 0 );
assert
(
Gia_Man
PiNum
(
p
)
==
Tim_ManPiNum
(
pManTime
)
+
Gia_ManP
oNum
(
pBoxes
)
);
assert
(
Gia_Man
CiNum
(
p
)
==
Tim_ManPiNum
(
pManTime
)
+
Gia_ManC
oNum
(
pBoxes
)
);
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Abc_UtilStrsav
(
p
->
pName
);
pNew
->
pName
=
Abc_UtilStrsav
(
p
->
pName
);
pNew
->
pSpec
=
Abc_UtilStrsav
(
p
->
pSpec
);
pNew
->
pSpec
=
Abc_UtilStrsav
(
p
->
pSpec
);
...
@@ -307,7 +307,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
...
@@ -307,7 +307,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
Gia_ObjSetTravIdCurrent
(
p
,
Gia_ManConst0
(
p
)
);
Gia_ObjSetTravIdCurrent
(
p
,
Gia_ManConst0
(
p
)
);
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
i
);
pObj
=
Gia_Man
C
i
(
p
,
i
);
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
}
}
...
@@ -326,13 +326,13 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
...
@@ -326,13 +326,13 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
int
fSkip
=
(
vBoxPres
!=
NULL
&&
!
Vec_IntEntry
(
vBoxPres
,
i
));
int
fSkip
=
(
vBoxPres
!=
NULL
&&
!
Vec_IntEntry
(
vBoxPres
,
i
));
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
curCo
+
k
);
pObj
=
Gia_Man
C
o
(
p
,
curCo
+
k
);
Gia_ManDupCollapse_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
pNew
);
Gia_ManDupCollapse_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
pNew
);
pObj
->
Value
=
fSkip
?
-
1
:
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
pObj
->
Value
=
fSkip
?
-
1
:
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
}
}
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
curCi
+
k
);
pObj
=
Gia_Man
C
i
(
p
,
curCi
+
k
);
pObj
->
Value
=
fSkip
?
0
:
Gia_ManAppendCi
(
pNew
);
pObj
->
Value
=
fSkip
?
0
:
Gia_ManAppendCi
(
pNew
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
}
}
...
@@ -342,20 +342,20 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
...
@@ -342,20 +342,20 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxInputNum
(
pManTime
,
i
);
k
++
)
{
{
// build logic
// build logic
pObj
=
Gia_Man
P
o
(
p
,
curCo
+
k
);
pObj
=
Gia_Man
C
o
(
p
,
curCo
+
k
);
Gia_ManDupCollapse_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
pNew
);
Gia_ManDupCollapse_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
pNew
);
// transfer to the PI
// transfer to the PI
pObjBox
=
Gia_Man
P
i
(
pBoxes
,
k
);
pObjBox
=
Gia_Man
C
i
(
pBoxes
,
k
);
pObjBox
->
Value
=
Gia_ObjFanin0Copy
(
pObj
);
pObjBox
->
Value
=
Gia_ObjFanin0Copy
(
pObj
);
Gia_ObjSetTravIdCurrent
(
pBoxes
,
pObjBox
);
Gia_ObjSetTravIdCurrent
(
pBoxes
,
pObjBox
);
}
}
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
{
{
// build logic
// build logic
pObjBox
=
Gia_Man
P
o
(
pBoxes
,
curCi
-
Tim_ManPiNum
(
pManTime
)
+
k
);
pObjBox
=
Gia_Man
C
o
(
pBoxes
,
curCi
-
Tim_ManPiNum
(
pManTime
)
+
k
);
Gia_ManDupCollapse_rec
(
pBoxes
,
Gia_ObjFanin0
(
pObjBox
),
pNew
);
Gia_ManDupCollapse_rec
(
pBoxes
,
Gia_ObjFanin0
(
pObjBox
),
pNew
);
// transfer to the PI
// transfer to the PI
pObj
=
Gia_Man
P
i
(
p
,
curCi
+
k
);
pObj
=
Gia_Man
C
i
(
p
,
curCi
+
k
);
pObj
->
Value
=
Gia_ObjFanin0Copy
(
pObjBox
);
pObj
->
Value
=
Gia_ObjFanin0Copy
(
pObjBox
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
}
}
...
@@ -366,21 +366,21 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
...
@@ -366,21 +366,21 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
// add remaining nodes
// add remaining nodes
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
i
);
pObj
=
Gia_Man
C
o
(
p
,
i
);
Gia_ManDupCollapse_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
pNew
);
Gia_ManDupCollapse_rec
(
p
,
Gia_ObjFanin0
(
pObj
),
pNew
);
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
}
}
curCo
+=
Tim_ManPoNum
(
pManTime
);
curCo
+=
Tim_ManPoNum
(
pManTime
);
// verify counts
// verify counts
assert
(
curCi
==
Gia_Man
P
iNum
(
p
)
);
assert
(
curCi
==
Gia_Man
C
iNum
(
p
)
);
assert
(
curCo
==
Gia_Man
P
oNum
(
p
)
);
assert
(
curCo
==
Gia_Man
C
oNum
(
p
)
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
Gia_ManHashStop
(
pNew
);
Gia_ManHashStop
(
pNew
);
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
Gia_ManCleanupRemap
(
p
,
pTemp
);
Gia_ManCleanupRemap
(
p
,
pTemp
);
Gia_ManStop
(
pTemp
);
Gia_ManStop
(
pTemp
);
assert
(
Tim_ManPoNum
(
pManTime
)
==
Gia_Man
P
oNum
(
pNew
)
);
assert
(
Tim_ManPoNum
(
pManTime
)
==
Gia_Man
C
oNum
(
pNew
)
);
assert
(
Tim_ManPiNum
(
pManTime
)
==
Gia_Man
P
iNum
(
pNew
)
);
assert
(
Tim_ManPiNum
(
pManTime
)
==
Gia_Man
C
iNum
(
pNew
)
);
return
pNew
;
return
pNew
;
}
}
...
@@ -426,7 +426,7 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
...
@@ -426,7 +426,7 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
Gia_ObjSetTravIdCurrent
(
p
,
Gia_ManConst0
(
p
)
);
Gia_ObjSetTravIdCurrent
(
p
,
Gia_ManConst0
(
p
)
);
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
i
);
pObj
=
Gia_Man
C
i
(
p
,
i
);
Gia_ObjSetLevel
(
p
,
pObj
,
Tim_ManGetCiArrival
(
pManTime
,
i
)
/
nAnd2Delay
);
Gia_ObjSetLevel
(
p
,
pObj
,
Tim_ManGetCiArrival
(
pManTime
,
i
)
/
nAnd2Delay
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
}
}
...
@@ -441,7 +441,7 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
...
@@ -441,7 +441,7 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
// compute level for TFI of box inputs
// compute level for TFI of box inputs
for
(
k
=
0
;
k
<
nBoxInputs
;
k
++
)
for
(
k
=
0
;
k
<
nBoxInputs
;
k
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
curCo
+
k
);
pObj
=
Gia_Man
C
o
(
p
,
curCo
+
k
);
if
(
Gia_ManLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
)
)
if
(
Gia_ManLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
)
)
{
{
printf
(
"Boxes are not in a topological order. Switching to level computation without boxes.
\n
"
);
printf
(
"Boxes are not in a topological order. Switching to level computation without boxes.
\n
"
);
...
@@ -453,12 +453,12 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
...
@@ -453,12 +453,12 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
// compute level for box outputs
// compute level for box outputs
for
(
k
=
0
;
k
<
nBoxOutputs
;
k
++
)
for
(
k
=
0
;
k
<
nBoxOutputs
;
k
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
curCi
+
k
);
pObj
=
Gia_Man
C
i
(
p
,
curCi
+
k
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
// evaluate delay of this output
// evaluate delay of this output
LevelMax
=
0
;
LevelMax
=
0
;
assert
(
nBoxInputs
==
(
int
)
pDelayTable
[
1
]
);
assert
(
nBoxInputs
==
(
int
)
pDelayTable
[
1
]
);
for
(
j
=
0
;
j
<
nBoxInputs
&&
(
pObjIn
=
Gia_Man
P
o
(
p
,
curCo
+
j
));
j
++
)
for
(
j
=
0
;
j
<
nBoxInputs
&&
(
pObjIn
=
Gia_Man
C
o
(
p
,
curCo
+
j
));
j
++
)
if
(
(
int
)
pDelayTable
[
3
+
k
*
nBoxInputs
+
j
]
!=
-
ABC_INFINITY
)
if
(
(
int
)
pDelayTable
[
3
+
k
*
nBoxInputs
+
j
]
!=
-
ABC_INFINITY
)
LevelMax
=
Abc_MaxInt
(
LevelMax
,
Gia_ObjLevel
(
p
,
pObjIn
)
+
((
int
)
pDelayTable
[
3
+
k
*
nBoxInputs
+
j
]
/
nAnd2Delay
)
);
LevelMax
=
Abc_MaxInt
(
LevelMax
,
Gia_ObjLevel
(
p
,
pObjIn
)
+
((
int
)
pDelayTable
[
3
+
k
*
nBoxInputs
+
j
]
/
nAnd2Delay
)
);
// set box output level
// set box output level
...
@@ -471,15 +471,15 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
...
@@ -471,15 +471,15 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p )
p
->
nLevels
=
0
;
p
->
nLevels
=
0
;
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
i
);
pObj
=
Gia_Man
C
o
(
p
,
i
);
Gia_ManLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ManLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ObjSetCoLevel
(
p
,
pObj
);
Gia_ObjSetCoLevel
(
p
,
pObj
);
p
->
nLevels
=
Abc_MaxInt
(
p
->
nLevels
,
Gia_ObjLevel
(
p
,
pObj
)
);
p
->
nLevels
=
Abc_MaxInt
(
p
->
nLevels
,
Gia_ObjLevel
(
p
,
pObj
)
);
}
}
curCo
+=
Tim_ManPoNum
(
pManTime
);
curCo
+=
Tim_ManPoNum
(
pManTime
);
// verify counts
// verify counts
assert
(
curCi
==
Gia_Man
P
iNum
(
p
)
);
assert
(
curCi
==
Gia_Man
C
iNum
(
p
)
);
assert
(
curCo
==
Gia_Man
P
oNum
(
p
)
);
assert
(
curCo
==
Gia_Man
C
oNum
(
p
)
);
// printf( "Max level is %d.\n", p->nLevels );
// printf( "Max level is %d.\n", p->nLevels );
return
p
->
nLevels
;
return
p
->
nLevels
;
}
}
...
@@ -528,7 +528,7 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
...
@@ -528,7 +528,7 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
Gia_ObjSetTravIdCurrent
(
p
,
Gia_ManConst0
(
p
)
);
Gia_ObjSetTravIdCurrent
(
p
,
Gia_ManConst0
(
p
)
);
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
for
(
i
=
0
;
i
<
Tim_ManPiNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
i
);
pObj
=
Gia_Man
C
i
(
p
,
i
);
// Gia_ObjSetLevel( p, pObj, Tim_ManGetCiArrival(pManTime, i) / nAnd2Delay );
// Gia_ObjSetLevel( p, pObj, Tim_ManGetCiArrival(pManTime, i) / nAnd2Delay );
Gia_ObjSetLevel
(
p
,
pObj
,
0
);
Gia_ObjSetLevel
(
p
,
pObj
,
0
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
...
@@ -544,7 +544,7 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
...
@@ -544,7 +544,7 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
// compute level for TFI of box inputs
// compute level for TFI of box inputs
for
(
k
=
0
;
k
<
nBoxInputs
;
k
++
)
for
(
k
=
0
;
k
<
nBoxInputs
;
k
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
curCo
+
k
);
pObj
=
Gia_Man
C
o
(
p
,
curCo
+
k
);
if
(
Gia_ManLutLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
)
)
if
(
Gia_ManLutLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
)
)
{
{
printf
(
"Boxes are not in a topological order. Switching to level computation without boxes.
\n
"
);
printf
(
"Boxes are not in a topological order. Switching to level computation without boxes.
\n
"
);
...
@@ -556,12 +556,12 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
...
@@ -556,12 +556,12 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
// compute level for box outputs
// compute level for box outputs
for
(
k
=
0
;
k
<
nBoxOutputs
;
k
++
)
for
(
k
=
0
;
k
<
nBoxOutputs
;
k
++
)
{
{
pObj
=
Gia_Man
P
i
(
p
,
curCi
+
k
);
pObj
=
Gia_Man
C
i
(
p
,
curCi
+
k
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
Gia_ObjSetTravIdCurrent
(
p
,
pObj
);
// evaluate delay of this output
// evaluate delay of this output
LevelMax
=
0
;
LevelMax
=
0
;
assert
(
nBoxInputs
==
(
int
)
pDelayTable
[
1
]
);
assert
(
nBoxInputs
==
(
int
)
pDelayTable
[
1
]
);
for
(
j
=
0
;
j
<
nBoxInputs
&&
(
pObjIn
=
Gia_Man
P
o
(
p
,
curCo
+
j
));
j
++
)
for
(
j
=
0
;
j
<
nBoxInputs
&&
(
pObjIn
=
Gia_Man
C
o
(
p
,
curCo
+
j
));
j
++
)
if
(
(
int
)
pDelayTable
[
3
+
k
*
nBoxInputs
+
j
]
!=
-
ABC_INFINITY
)
if
(
(
int
)
pDelayTable
[
3
+
k
*
nBoxInputs
+
j
]
!=
-
ABC_INFINITY
)
// LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + ((int)pDelayTable[3+k*nBoxInputs+j] / nAnd2Delay) );
// LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + ((int)pDelayTable[3+k*nBoxInputs+j] / nAnd2Delay) );
LevelMax
=
Abc_MaxInt
(
LevelMax
,
Gia_ObjLevel
(
p
,
pObjIn
)
+
1
);
LevelMax
=
Abc_MaxInt
(
LevelMax
,
Gia_ObjLevel
(
p
,
pObjIn
)
+
1
);
...
@@ -575,15 +575,15 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
...
@@ -575,15 +575,15 @@ int Gia_ManLutLevelWithBoxes( Gia_Man_t * p )
p
->
nLevels
=
0
;
p
->
nLevels
=
0
;
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
for
(
i
=
Tim_ManCoNum
(
pManTime
)
-
Tim_ManPoNum
(
pManTime
);
i
<
Tim_ManCoNum
(
pManTime
);
i
++
)
{
{
pObj
=
Gia_Man
P
o
(
p
,
i
);
pObj
=
Gia_Man
C
o
(
p
,
i
);
Gia_ManLutLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ManLutLevelWithBoxes_rec
(
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ObjSetCoLevel
(
p
,
pObj
);
Gia_ObjSetCoLevel
(
p
,
pObj
);
p
->
nLevels
=
Abc_MaxInt
(
p
->
nLevels
,
Gia_ObjLevel
(
p
,
pObj
)
);
p
->
nLevels
=
Abc_MaxInt
(
p
->
nLevels
,
Gia_ObjLevel
(
p
,
pObj
)
);
}
}
curCo
+=
Tim_ManPoNum
(
pManTime
);
curCo
+=
Tim_ManPoNum
(
pManTime
);
// verify counts
// verify counts
assert
(
curCi
==
Gia_Man
P
iNum
(
p
)
);
assert
(
curCi
==
Gia_Man
C
iNum
(
p
)
);
assert
(
curCo
==
Gia_Man
P
oNum
(
p
)
);
assert
(
curCo
==
Gia_Man
C
oNum
(
p
)
);
// printf( "Max level is %d.\n", p->nLevels );
// printf( "Max level is %d.\n", p->nLevels );
return
p
->
nLevels
;
return
p
->
nLevels
;
}
}
...
@@ -714,14 +714,14 @@ Gia_Man_t * Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * p, Vec_Int_t * vBox
...
@@ -714,14 +714,14 @@ Gia_Man_t * Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * p, Vec_Int_t * vBox
Vec_Int_t
*
vOutPres
=
Vec_IntAlloc
(
100
);
Vec_Int_t
*
vOutPres
=
Vec_IntAlloc
(
100
);
int
i
,
k
,
curPo
=
0
;
int
i
,
k
,
curPo
=
0
;
assert
(
Vec_IntSize
(
vBoxPres
)
==
Tim_ManBoxNum
(
pManTime
)
);
assert
(
Vec_IntSize
(
vBoxPres
)
==
Tim_ManBoxNum
(
pManTime
)
);
assert
(
Gia_Man
P
oNum
(
p
)
==
Tim_ManCiNum
(
pManTime
)
-
Tim_ManPiNum
(
pManTime
)
);
assert
(
Gia_Man
C
oNum
(
p
)
==
Tim_ManCiNum
(
pManTime
)
-
Tim_ManPiNum
(
pManTime
)
);
for
(
i
=
0
;
i
<
Tim_ManBoxNum
(
pManTime
);
i
++
)
for
(
i
=
0
;
i
<
Tim_ManBoxNum
(
pManTime
);
i
++
)
{
{
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
for
(
k
=
0
;
k
<
Tim_ManBoxOutputNum
(
pManTime
,
i
);
k
++
)
Vec_IntPush
(
vOutPres
,
Vec_IntEntry
(
vBoxPres
,
i
)
);
Vec_IntPush
(
vOutPres
,
Vec_IntEntry
(
vBoxPres
,
i
)
);
curPo
+=
Tim_ManBoxOutputNum
(
pManTime
,
i
);
curPo
+=
Tim_ManBoxOutputNum
(
pManTime
,
i
);
}
}
assert
(
curPo
==
Gia_Man
P
oNum
(
p
)
);
assert
(
curPo
==
Gia_Man
C
oNum
(
p
)
);
// if ( Vec_IntSize(vOutPres) > 0 )
// if ( Vec_IntSize(vOutPres) > 0 )
pNew
=
Gia_ManDupOutputVec
(
p
,
vOutPres
);
pNew
=
Gia_ManDupOutputVec
(
p
,
vOutPres
);
Vec_IntFree
(
vOutPres
);
Vec_IntFree
(
vOutPres
);
...
...
src/aig/gia/module.make
View file @
372a348c
...
@@ -21,6 +21,7 @@ SRC += src/aig/gia/giaAig.c \
...
@@ -21,6 +21,7 @@ SRC += src/aig/gia/giaAig.c \
src/aig/gia/giaEquiv.c
\
src/aig/gia/giaEquiv.c
\
src/aig/gia/giaEra.c
\
src/aig/gia/giaEra.c
\
src/aig/gia/giaEra2.c
\
src/aig/gia/giaEra2.c
\
src/aig/gia/giaFadds.c
\
src/aig/gia/giaFalse.c
\
src/aig/gia/giaFalse.c
\
src/aig/gia/giaFanout.c
\
src/aig/gia/giaFanout.c
\
src/aig/gia/giaForce.c
\
src/aig/gia/giaForce.c
\
...
...
src/base/abci/abc.c
View file @
372a348c
...
@@ -439,6 +439,7 @@ static int Abc_CommandAbc9Maxi ( Abc_Frame_t * pAbc, int argc, cha
...
@@ -439,6 +439,7 @@ static int Abc_CommandAbc9Maxi ( Abc_Frame_t * pAbc, int argc, cha
static
int
Abc_CommandAbc9Bmci
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Bmci
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9PoXsim
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9PoXsim
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Demiter
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Demiter
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Fadds
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
//static int Abc_CommandAbc9PoPart2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
//static int Abc_CommandAbc9PoPart2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
//static int Abc_CommandAbc9CexCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
//static int Abc_CommandAbc9CexCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
//static int Abc_CommandAbc9CexMerge ( Abc_Frame_t * pAbc, int argc, char ** argv );
//static int Abc_CommandAbc9CexMerge ( Abc_Frame_t * pAbc, int argc, char ** argv );
...
@@ -1040,6 +1041,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
...
@@ -1040,6 +1041,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&bmci"
,
Abc_CommandAbc9Bmci
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&bmci"
,
Abc_CommandAbc9Bmci
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&poxsim"
,
Abc_CommandAbc9PoXsim
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&poxsim"
,
Abc_CommandAbc9PoXsim
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&demiter"
,
Abc_CommandAbc9Demiter
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&demiter"
,
Abc_CommandAbc9Demiter
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&fadds"
,
Abc_CommandAbc9Fadds
,
0
);
// Cmd_CommandAdd( pAbc, "ABC9", "&popart2", Abc_CommandAbc9PoPart2, 0 );
// Cmd_CommandAdd( pAbc, "ABC9", "&popart2", Abc_CommandAbc9PoPart2, 0 );
// Cmd_CommandAdd( pAbc, "ABC9", "&cexcut", Abc_CommandAbc9CexCut, 0 );
// Cmd_CommandAdd( pAbc, "ABC9", "&cexcut", Abc_CommandAbc9CexCut, 0 );
// Cmd_CommandAdd( pAbc, "ABC9", "&cexmerge", Abc_CommandAbc9CexMerge, 0 );
// Cmd_CommandAdd( pAbc, "ABC9", "&cexmerge", Abc_CommandAbc9CexMerge, 0 );
...
@@ -36557,6 +36559,64 @@ usage:
...
@@ -36557,6 +36559,64 @@ usage:
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
int
Abc_CommandAbc9Fadds
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
Gia_Man_t
*
Gia_ManDupWithFaddBoxes
(
Gia_Man_t
*
p
,
int
nFaddMin
,
int
fVerbose
);
Gia_Man_t
*
pTemp
;
int
c
,
nFaddMin
=
3
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"Nvh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'N'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-N
\"
should be followed by an integer.
\n
"
);
goto
usage
;
}
nFaddMin
=
atoi
(
argv
[
globalUtilOptind
]);
globalUtilOptind
++
;
if
(
nFaddMin
<
0
)
goto
usage
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
if
(
pAbc
->
pGia
==
NULL
)
{
Abc_Print
(
-
1
,
"Abc_CommandAbc9Fadds(): There is no AIG.
\n
"
);
return
0
;
}
pTemp
=
Gia_ManDupWithFaddBoxes
(
pAbc
->
pGia
,
nFaddMin
,
fVerbose
);
Abc_FrameUpdateGia
(
pAbc
,
pTemp
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: &fadds [-N num] [-vh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
detects full-adder chains and puts them into white boxes
\n
"
);
Abc_Print
(
-
2
,
"
\t
-N num : the minimum length of full-adder chain to box [default = %d]
\n
"
,
nFaddMin
);
Abc_Print
(
-
2
,
"
\t
-v : toggles printing verbose information [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Abc_CommandAbc9CexCut
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
int
Abc_CommandAbc9CexCut
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
{
return
-
1
;
return
-
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