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
a3ada00d
Commit
a3ada00d
authored
May 10, 2020
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding new utility procedures.
parent
a7871d24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
9 deletions
+172
-9
src/base/acb/acb.h
+6
-0
src/base/acb/acbFunc.c
+33
-9
src/base/acb/acbUtil.c
+133
-0
No files found.
src/base/acb/acb.h
View file @
a3ada00d
...
@@ -1019,6 +1019,12 @@ static inline void Acb_ManPrintStats( Acb_Man_t * p, int nModules, int fVerbose
...
@@ -1019,6 +1019,12 @@ static inline void Acb_ManPrintStats( Acb_Man_t * p, int nModules, int fVerbose
extern
Vec_Int_t
*
Acb_ObjCollectTfi
(
Acb_Ntk_t
*
p
,
int
iObj
,
int
fTerm
);
extern
Vec_Int_t
*
Acb_ObjCollectTfi
(
Acb_Ntk_t
*
p
,
int
iObj
,
int
fTerm
);
extern
Vec_Int_t
*
Acb_ObjCollectTfo
(
Acb_Ntk_t
*
p
,
int
iObj
,
int
fTerm
);
extern
Vec_Int_t
*
Acb_ObjCollectTfo
(
Acb_Ntk_t
*
p
,
int
iObj
,
int
fTerm
);
extern
Vec_Int_t
*
Acb_ObjCollectTfiVec
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
);
extern
Vec_Int_t
*
Acb_ObjCollectTfoVec
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
);
extern
int
Acb_NtkCountPiBuffers
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
);
extern
int
Acb_NtkCountPoDrivers
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
);
extern
int
Acb_NtkFindMffcSize
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
,
int
nGates
[
5
]
);
extern
int
Acb_ObjComputeLevelD
(
Acb_Ntk_t
*
p
,
int
iObj
);
extern
int
Acb_ObjComputeLevelD
(
Acb_Ntk_t
*
p
,
int
iObj
);
extern
int
Acb_NtkComputeLevelD
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vTfo
);
extern
int
Acb_NtkComputeLevelD
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vTfo
);
extern
void
Acb_NtkUpdateLevelD
(
Acb_Ntk_t
*
p
,
int
iObj
);
extern
void
Acb_NtkUpdateLevelD
(
Acb_Ntk_t
*
p
,
int
iObj
);
...
...
src/base/acb/acbFunc.c
View file @
a3ada00d
...
@@ -1897,6 +1897,14 @@ Vec_Ptr_t * Acb_GenerateSignalNames( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t
...
@@ -1897,6 +1897,14 @@ Vec_Ptr_t * Acb_GenerateSignalNames( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t
Vec_StrFree
(
vStr
);
Vec_StrFree
(
vStr
);
return
vRes
;
return
vRes
;
}
}
Vec_Int_t
*
Acb_GetUsedDivs
(
Vec_Int_t
*
vDivs
,
Vec_Int_t
*
vUsed
)
{
int
i
,
iObj
;
Vec_Int_t
*
vRes
=
Vec_IntAlloc
(
Vec_IntSize
(
vUsed
)
);
Vec_IntForEachEntryInVec
(
vDivs
,
vUsed
,
iObj
,
i
)
Vec_IntPush
(
vRes
,
iObj
);
return
vRes
;
}
Vec_Str_t
*
Acb_GeneratePatch
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vDivs
,
Vec_Int_t
*
vUsed
,
Vec_Ptr_t
*
vSops
,
Vec_Ptr_t
*
vGias
,
Vec_Int_t
*
vTars
)
Vec_Str_t
*
Acb_GeneratePatch
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vDivs
,
Vec_Int_t
*
vUsed
,
Vec_Ptr_t
*
vSops
,
Vec_Ptr_t
*
vGias
,
Vec_Int_t
*
vTars
)
{
{
extern
Vec_Wec_t
*
Abc_SopSynthesize
(
Vec_Ptr_t
*
vSops
);
extern
Vec_Wec_t
*
Abc_SopSynthesize
(
Vec_Ptr_t
*
vSops
);
...
@@ -1904,10 +1912,16 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
...
@@ -1904,10 +1912,16 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
Vec_Wec_t
*
vGates
=
vGias
?
Abc_GiaSynthesize
(
vGias
,
NULL
)
:
Abc_SopSynthesize
(
vSops
);
Vec_Int_t
*
vGate
;
Vec_Wec_t
*
vGates
=
vGias
?
Abc_GiaSynthesize
(
vGias
,
NULL
)
:
Abc_SopSynthesize
(
vSops
);
Vec_Int_t
*
vGate
;
int
nOuts
=
vGias
?
Vec_PtrSize
(
vGias
)
:
Vec_PtrSize
(
vSops
);
int
nOuts
=
vGias
?
Vec_PtrSize
(
vGias
)
:
Vec_PtrSize
(
vSops
);
int
i
,
k
,
iObj
,
nWires
=
Vec_WecSize
(
vGates
)
-
Vec_IntSize
(
vUsed
)
-
nOuts
,
fFirst
=
1
;
int
i
,
k
,
iObj
,
nWires
=
Vec_WecSize
(
vGates
)
-
Vec_IntSize
(
vUsed
)
-
nOuts
,
fFirst
=
1
;
int
nGates
[
5
]
=
{
0
},
nInvs
=
0
,
nBufs
=
0
,
nNodes
=
0
,
nConst
[
2
]
=
{
0
};
Vec_Ptr_t
*
vNames
=
Acb_GenerateSignalNames
(
p
,
vDivs
,
vUsed
,
nWires
,
vTars
,
vGates
);
Vec_Ptr_t
*
vNames
=
Acb_GenerateSignalNames
(
p
,
vDivs
,
vUsed
,
nWires
,
vTars
,
vGates
);
Vec_Str_t
*
vStr
=
Vec_StrAlloc
(
100
);
Vec_Str_t
*
vStr
=
Vec_StrAlloc
(
100
);
Vec_Int_t
*
vSup
=
Acb_GetUsedDivs
(
vDivs
,
vUsed
);
int
nInvs
=
0
,
nBufs
=
0
,
nNodes
=
0
,
nConst
=
0
;
Vec_Int_t
*
vTfi
=
Acb_ObjCollectTfiVec
(
p
,
vSup
);
Vec_Int_t
*
vTfo
=
Acb_ObjCollectTfoVec
(
p
,
vTars
);
int
nPiCount
=
Acb_NtkCountPiBuffers
(
p
,
vSup
);
int
nPoCount
=
Acb_NtkCountPoDrivers
(
p
,
vTars
);
int
nMffc
=
Acb_NtkFindMffcSize
(
p
,
vSup
,
nGates
);
Vec_IntFree
(
vSup
);
Vec_WecForEachLevelStartStop
(
vGates
,
vGate
,
i
,
Vec_IntSize
(
vUsed
),
Vec_IntSize
(
vUsed
)
+
nWires
)
Vec_WecForEachLevelStartStop
(
vGates
,
vGate
,
i
,
Vec_IntSize
(
vUsed
),
Vec_IntSize
(
vUsed
)
+
nWires
)
{
{
if
(
Vec_IntSize
(
vGate
)
>
2
)
if
(
Vec_IntSize
(
vGate
)
>
2
)
...
@@ -1918,13 +1932,17 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
...
@@ -1918,13 +1932,17 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
else
if
(
!
strcmp
(
pName
,
"not"
)
)
else
if
(
!
strcmp
(
pName
,
"not"
)
)
nInvs
++
;
nInvs
++
;
else
else
nNodes
++
;
nNodes
+=
Vec_IntSize
(
vGate
)
-
3
;
}
}
else
else
nConst
++
;
nConst
[
Vec_IntEntry
(
vGate
,
0
)
==
ABC_OPER_CONST_T
]
++
;
}
}
Vec_StrPrintF
(
vStr
,
"// Patch statistics: in = %d out = %d gate = %d (const = %d buf = %d inv = %d other = %d)
\n\n
"
,
Vec_IntSize
(
vUsed
),
nOuts
,
nWires
,
nConst
,
nBufs
,
nInvs
,
nNodes
);
Vec_StrPrintF
(
vStr
,
"// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d
\n
"
,
Vec_IntSize
(
vUsed
),
nOuts
,
nPiCount
,
nPoCount
,
Vec_IntSize
(
vTfi
),
Vec_IntSize
(
vTfo
)
);
Vec_StrPrintF
(
vStr
,
"// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d
\n
"
,
nWires
,
nConst
[
0
],
nConst
[
1
],
nBufs
,
nInvs
,
nNodes
);
Vec_StrPrintF
(
vStr
,
"// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d
\n
"
,
nMffc
,
nGates
[
0
],
nGates
[
1
],
nGates
[
2
],
nGates
[
3
],
nGates
[
4
]
);
Vec_StrPrintF
(
vStr
,
"// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d
\n\n
"
,
nWires
-
nMffc
,
nConst
[
0
]
-
nGates
[
0
],
nConst
[
1
]
-
nGates
[
1
],
nBufs
-
nGates
[
2
],
nInvs
-
nGates
[
3
],
nNodes
-
nGates
[
4
]
);
Vec_StrAppend
(
vStr
,
"module patch ("
);
Vec_StrAppend
(
vStr
,
"module patch ("
);
assert
(
Vec_IntSize
(
vTars
)
==
nOuts
);
assert
(
Vec_IntSize
(
vTars
)
==
nOuts
);
...
@@ -1980,8 +1998,14 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
...
@@ -1980,8 +1998,14 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
Vec_PtrFreeFree
(
vNames
);
Vec_PtrFreeFree
(
vNames
);
Vec_WecFree
(
vGates
);
Vec_WecFree
(
vGates
);
printf
(
"Synthesized patch with %d inputs, %d outputs and %d gates (const = %d buf = %d inv = %d other = %d).
\n
"
,
// printf( "Synthesized patch with %d inputs, %d outputs and %d gates (const = %d buf = %d inv = %d other = %d).\n",
Vec_IntSize
(
vUsed
),
nOuts
,
nWires
,
nConst
,
nBufs
,
nInvs
,
nNodes
);
// Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes );
// printf( "Summary of the results\n" );
printf
(
"
\n
"
);
printf
(
"Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d
\n
"
,
Vec_IntSize
(
vUsed
),
nOuts
,
nPiCount
,
nPoCount
,
Vec_IntSize
(
vTfi
),
Vec_IntSize
(
vTfo
)
);
printf
(
"Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d
\n
"
,
nWires
,
nConst
[
0
],
nConst
[
1
],
nBufs
,
nInvs
,
nNodes
);
printf
(
"Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d
\n
"
,
nMffc
,
nGates
[
0
],
nGates
[
1
],
nGates
[
2
],
nGates
[
3
],
nGates
[
4
]
);
printf
(
"TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d
\n
"
,
nWires
-
nMffc
,
nConst
[
0
]
-
nGates
[
0
],
nConst
[
1
]
-
nGates
[
1
],
nBufs
-
nGates
[
2
],
nInvs
-
nGates
[
3
],
nNodes
-
nGates
[
4
]
);
return
vStr
;
return
vStr
;
}
}
...
@@ -2479,7 +2503,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps,
...
@@ -2479,7 +2503,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps,
Vec_IntWriteEntry
(
vMap
,
iVar
,
Vec_IntSize
(
vUsed
)
);
Vec_IntWriteEntry
(
vMap
,
iVar
,
Vec_IntSize
(
vUsed
)
);
Vec_IntPush
(
vUsed
,
iVar
);
Vec_IntPush
(
vUsed
,
iVar
);
}
}
printf
(
"The number of used variables %d (out of %d).
\n
"
,
Vec_IntSum
(
vPres
),
Vec_IntSize
(
vPres
)
);
//
printf( "The number of used variables %d (out of %d).\n", Vec_IntSum(vPres), Vec_IntSize(vPres) );
// remap SOPs
// remap SOPs
Vec_WecForEachLevel
(
vSupps
,
vLevel
,
i
)
Vec_WecForEachLevel
(
vSupps
,
vLevel
,
i
)
{
{
...
...
src/base/acb/acbUtil.c
View file @
a3ada00d
...
@@ -71,6 +71,15 @@ Vec_Int_t * Acb_ObjCollectTfi( Acb_Ntk_t * p, int iObj, int fTerm )
...
@@ -71,6 +71,15 @@ Vec_Int_t * Acb_ObjCollectTfi( Acb_Ntk_t * p, int iObj, int fTerm )
Acb_ObjCollectTfi_rec
(
p
,
iObj
,
fTerm
);
Acb_ObjCollectTfi_rec
(
p
,
iObj
,
fTerm
);
return
&
p
->
vArray0
;
return
&
p
->
vArray0
;
}
}
Vec_Int_t
*
Acb_ObjCollectTfiVec
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
)
{
int
i
,
iObj
;
Vec_IntClear
(
&
p
->
vArray0
);
Acb_NtkIncTravId
(
p
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Acb_ObjCollectTfi_rec
(
p
,
iObj
,
0
);
return
&
p
->
vArray0
;
}
void
Acb_ObjCollectTfo_rec
(
Acb_Ntk_t
*
p
,
int
iObj
,
int
fTerm
)
void
Acb_ObjCollectTfo_rec
(
Acb_Ntk_t
*
p
,
int
iObj
,
int
fTerm
)
{
{
...
@@ -95,6 +104,130 @@ Vec_Int_t * Acb_ObjCollectTfo( Acb_Ntk_t * p, int iObj, int fTerm )
...
@@ -95,6 +104,130 @@ Vec_Int_t * Acb_ObjCollectTfo( Acb_Ntk_t * p, int iObj, int fTerm )
Acb_ObjCollectTfo_rec
(
p
,
iObj
,
fTerm
);
Acb_ObjCollectTfo_rec
(
p
,
iObj
,
fTerm
);
return
&
p
->
vArray1
;
return
&
p
->
vArray1
;
}
}
Vec_Int_t
*
Acb_ObjCollectTfoVec
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
)
{
int
i
,
iObj
;
if
(
!
Acb_NtkHasObjFanout
(
p
)
)
Acb_NtkCreateFanout
(
p
);
Vec_IntClear
(
&
p
->
vArray1
);
Acb_NtkIncTravId
(
p
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Acb_ObjCollectTfo_rec
(
p
,
iObj
,
0
);
return
&
p
->
vArray1
;
}
/**Function*************************************************************
Synopsis [Count the number of nodes driving the POs.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Acb_NtkIsPiBuffers
(
Acb_Ntk_t
*
p
,
int
iObj
)
{
if
(
Acb_ObjIsCi
(
p
,
iObj
)
)
return
1
;
if
(
Acb_ObjFaninNum
(
p
,
iObj
)
!=
1
)
return
0
;
return
Acb_NtkIsPiBuffers
(
p
,
Acb_ObjFanin
(
p
,
iObj
,
0
)
);
}
int
Acb_NtkCountPiBuffers
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
)
{
int
i
,
iObj
,
Count
=
0
;
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Count
+=
Acb_NtkIsPiBuffers
(
p
,
iObj
);
return
Count
;
}
int
Acb_NtkCountPoDrivers
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
)
{
int
i
,
iObj
,
Count
=
0
;
Acb_NtkIncTravId
(
p
);
Acb_NtkForEachCo
(
p
,
iObj
,
i
)
Acb_ObjSetTravIdCur
(
p
,
iObj
);
Acb_NtkForEachCo
(
p
,
iObj
,
i
)
Acb_ObjSetTravIdCur
(
p
,
Acb_ObjFanin
(
p
,
iObj
,
0
)
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Count
+=
Acb_ObjIsTravIdCur
(
p
,
iObj
);
return
Count
;
}
/**Function*************************************************************
Synopsis [Compute MFFC size.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Acb_NtkNodeDeref_rec
(
Vec_Int_t
*
vRefs
,
Acb_Ntk_t
*
p
,
int
iObj
,
int
nGates
[
5
]
)
{
int
i
,
Fanin
,
*
pFanins
,
Counter
=
1
;
if
(
Acb_ObjIsCi
(
p
,
iObj
)
)
return
0
;
if
(
nGates
)
{
int
Type
=
Acb_ObjType
(
p
,
iObj
);
if
(
Type
==
ABC_OPER_CONST_F
)
nGates
[
0
]
++
;
if
(
Type
==
ABC_OPER_CONST_T
)
nGates
[
1
]
++
;
if
(
Type
==
ABC_OPER_BIT_BUF
)
nGates
[
2
]
++
;
if
(
Type
==
ABC_OPER_BIT_INV
)
nGates
[
3
]
++
;
else
nGates
[
4
]
+=
Acb_ObjFaninNum
(
p
,
iObj
)
-
1
;
}
Acb_ObjForEachFaninFast
(
p
,
iObj
,
pFanins
,
Fanin
,
i
)
{
assert
(
Vec_IntEntry
(
vRefs
,
Fanin
)
>
0
);
Vec_IntAddToEntry
(
vRefs
,
Fanin
,
-
1
);
if
(
Vec_IntEntry
(
vRefs
,
Fanin
)
==
0
)
Counter
+=
Acb_NtkNodeDeref_rec
(
vRefs
,
p
,
Fanin
,
nGates
);
}
return
Counter
;
}
int
Acb_NtkNodeRef_rec
(
Vec_Int_t
*
vRefs
,
Acb_Ntk_t
*
p
,
int
iObj
)
{
int
i
,
Fanin
,
*
pFanins
,
Counter
=
1
;
if
(
Acb_ObjIsCi
(
p
,
iObj
)
)
return
0
;
Acb_ObjForEachFaninFast
(
p
,
iObj
,
pFanins
,
Fanin
,
i
)
{
if
(
Vec_IntEntry
(
vRefs
,
Fanin
)
==
0
)
Counter
+=
Acb_NtkNodeRef_rec
(
vRefs
,
p
,
Fanin
);
Vec_IntAddToEntry
(
vRefs
,
Fanin
,
1
);
}
return
Counter
;
}
int
Acb_NtkFindMffcSize
(
Acb_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
,
int
nGates
[
5
]
)
{
Vec_Int_t
*
vRefs
=
Vec_IntStart
(
Acb_NtkObjNumMax
(
p
)
);
int
i
,
iObj
,
Fanin
,
*
pFanins
,
Count1
=
0
,
Count2
=
0
;
Acb_NtkForEachObj
(
p
,
iObj
)
Acb_ObjForEachFaninFast
(
p
,
iObj
,
pFanins
,
Fanin
,
i
)
Vec_IntAddToEntry
(
vRefs
,
Fanin
,
1
);
//Vec_IntForEachEntry( vObjs, iObj, i )
// assert( Vec_IntEntry(vRefs, iObj) > 0 );
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Vec_IntAddToEntry
(
vRefs
,
iObj
,
1
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Count1
+=
Acb_NtkNodeDeref_rec
(
vRefs
,
p
,
iObj
,
nGates
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Count2
+=
Acb_NtkNodeRef_rec
(
vRefs
,
p
,
iObj
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
Vec_IntAddToEntry
(
vRefs
,
iObj
,
-
1
);
assert
(
Count1
==
Count2
);
Vec_IntFree
(
vRefs
);
return
Count1
;
}
/**Function*************************************************************
/**Function*************************************************************
...
...
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