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
7f7b7671
Commit
7f7b7671
authored
Jul 28, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to Cba data-structure.
parent
0806dd22
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
231 additions
and
32 deletions
+231
-32
src/base/abci/abc.c
+1
-0
src/base/cba/cba.h
+73
-5
src/base/cba/cbaNtk.c
+155
-25
src/base/io/ioReadPla.c
+2
-2
No files found.
src/base/abci/abc.c
View file @
7f7b7671
...
...
@@ -10260,6 +10260,7 @@ int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
usage:
Abc_Print
(
-
2
,
"usage: cover [-N num] [-sxvh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
decomposition into a network of SOP/ESOP PLAs
\n
"
);
Abc_Print
(
-
2
,
"
\t
(this command is known to have bugs)
\n
"
);
Abc_Print
(
-
2
,
"
\t
-N num : maximum number of inputs [default = %d]
\n
"
,
nFaninMax
);
Abc_Print
(
-
2
,
"
\t
-s : toggle the use of SOPs [default = %s]
\n
"
,
fUseSop
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-x : toggle the use of ESOPs [default = %s]
\n
"
,
fUseEsop
?
"yes"
:
"no"
);
src/base/cba/cba.h
View file @
7f7b7671
...
...
@@ -142,11 +142,14 @@ struct Cba_Ntk_t_
int
Id
;
// network ID
int
NameId
;
// name ID
int
iCopy
;
// copy module
int
Mark
;
// visit mark
unsigned
Mark
:
1
;
// visit mark
unsigned
fComb
:
1
;
// the network is combinational
unsigned
fSeq
:
1
;
// the network is sequential
// interface
Vec_Int_t
vInputs
;
// inputs
Vec_Int_t
vOutputs
;
// outputs
Vec_Int_t
vOrder
;
// order
Vec_Int_t
vSeq
;
// sequential objects
// stucture
Vec_Str_t
vObjType
;
// type
Vec_Int_t
vObjFin0
;
// fanins
...
...
@@ -183,6 +186,7 @@ struct Cba_Man_t_
char
*
pSpec
;
// spec file name
Abc_Nam_t
*
pStrs
;
// string manager
Abc_Nam_t
*
pMods
;
// module name manager
char
*
pTypeNames
[
CBA_BOX_LAST
];
// internal data
int
iRoot
;
// root network
Vec_Ptr_t
vNtks
;
// networks
...
...
@@ -213,9 +217,11 @@ static inline Cba_Ntk_t * Cba_NtkNtk( Cba_Ntk_t * p, int i ) { r
static
inline
int
Cba_NtkId
(
Cba_Ntk_t
*
p
)
{
return
p
->
Id
;
}
static
inline
int
Cba_NtkPi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vInputs
,
i
);
}
static
inline
int
Cba_NtkPo
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vOutputs
,
i
);
}
static
inline
int
Cba_NtkBoxSeq
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vSeq
,
i
);
}
static
inline
char
*
Cba_NtkStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManStr
(
p
->
pDesign
,
i
);
}
static
inline
char
*
Cba_NtkName
(
Cba_Ntk_t
*
p
)
{
return
Cba_NtkStr
(
p
,
p
->
NameId
);
}
static
inline
int
Cba_NtkNameId
(
Cba_Ntk_t
*
p
)
{
return
p
->
NameId
;
}
static
inline
char
*
Cba_NtkName
(
Cba_Ntk_t
*
p
)
{
return
Cba_NtkStr
(
p
,
p
->
NameId
);
}
static
inline
char
*
Cba_NtkTypeName
(
Cba_Ntk_t
*
p
,
int
Type
)
{
return
p
->
pDesign
->
pTypeNames
[
Type
];
}
static
inline
int
Cba_NtkCopy
(
Cba_Ntk_t
*
p
)
{
return
p
->
iCopy
;
}
static
inline
Cba_Ntk_t
*
Cba_NtkCopyNtk
(
Cba_Man_t
*
pNew
,
Cba_Ntk_t
*
p
)
{
return
Cba_ManNtk
(
pNew
,
Cba_NtkCopy
(
p
));
}
static
inline
void
Cba_NtkSetCopy
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
p
->
iCopy
==
0
);
p
->
iCopy
=
i
;
}
...
...
@@ -235,6 +241,7 @@ static inline int Cba_NtkTypeNum( Cba_Ntk_t * p, int Type ) { r
static
inline
int
Cba_NtkBoxNum
(
Cba_Ntk_t
*
p
)
{
return
Cba_NtkObjNum
(
p
)
-
Cba_NtkPioNum
(
p
);
}
static
inline
int
Cba_NtkBoxUserNum
(
Cba_Ntk_t
*
p
)
{
return
Cba_NtkTypeNum
(
p
,
CBA_OBJ_BOX
);
}
static
inline
int
Cba_NtkBoxPrimNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_StrCountLarger
(
&
p
->
vObjType
,
(
char
)
CBA_OBJ_BOX
);
}
static
inline
int
Cba_NtkBoxSeqNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vSeq
);
}
static
inline
void
Cba_NtkCleanObjCopies
(
Cba_Ntk_t
*
p
)
{
Vec_IntFill
(
&
p
->
vObjCopy
,
Vec_StrCap
(
&
p
->
vObjType
),
-
1
);
}
static
inline
void
Cba_NtkCleanObjFuncs
(
Cba_Ntk_t
*
p
)
{
Vec_IntFill
(
&
p
->
vObjFunc
,
Vec_StrCap
(
&
p
->
vObjType
),
0
);
}
...
...
@@ -281,6 +288,7 @@ static inline void Cba_NtkFreeFinObjs( Cba_Ntk_t * p ) { V
static
inline
Cba_ObjType_t
Cba_ObjType
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
(
Cba_ObjType_t
)(
int
)(
unsigned
char
)
Vec_StrEntry
(
&
p
->
vObjType
,
i
);
}
static
inline
void
Cba_ObjCleanType
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
Vec_StrWriteEntry
(
&
p
->
vObjType
,
i
,
(
char
)
CBA_OBJ_NONE
);
}
static
inline
int
Cba_TypeIsBox
(
Cba_ObjType_t
Type
)
{
return
Type
>=
CBA_OBJ_BOX
&&
Type
<
CBA_BOX_LAST
;
}
static
inline
int
Cba_TypeIsSeq
(
Cba_ObjType_t
Type
)
{
return
Type
>=
CBA_BOX_RAM
&&
Type
<=
CBA_BOX_DFFRS
;
}
static
inline
int
Cba_ObjIsPi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PI
;
}
static
inline
int
Cba_ObjIsPo
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PO
;
}
...
...
@@ -319,9 +327,10 @@ static inline void Cba_ObjSetFinFon( Cba_Ntk_t * p, int i, int k, int
static
inline
void
Cba_ObjCleanFinFon
(
Cba_Ntk_t
*
p
,
int
i
,
int
k
)
{
assert
(
i
>
0
);
assert
(
Cba_ObjFinFon
(
p
,
i
,
k
)
>
0
);
Vec_IntWriteEntry
(
&
p
->
vFinFon
,
Cba_ObjFin
(
p
,
i
,
k
),
0
);
}
static
inline
void
Cba_ObjPatchFinFon
(
Cba_Ntk_t
*
p
,
int
i
,
int
k
,
int
x
){
assert
(
i
>
0
);
Cba_ObjCleanFinFon
(
p
,
i
,
k
);
Cba_ObjSetFinFon
(
p
,
i
,
k
,
x
);
}
static
inline
int
Cba_ObjNtkId
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
&&
Cba_NtkHasObjFuncs
(
p
));
return
Cba_ObjIsBoxUser
(
p
,
i
)
?
Cba_ObjFunc
(
p
,
i
)
:
0
;}
static
inline
int
Cba_ObjNtkId
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
(
Cba_ObjIsBoxUser
(
p
,
i
)
&&
Cba_NtkHasObjFuncs
(
p
)
)
?
Cba_ObjFunc
(
p
,
i
)
:
0
;}
static
inline
Cba_Ntk_t
*
Cba_ObjNtk
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
Cba_NtkNtk
(
p
,
Cba_ObjNtkId
(
p
,
i
));
}
static
inline
int
Cba_ObjSetNtkId
(
Cba_Ntk_t
*
p
,
int
i
,
int
x
)
{
assert
(
i
>
0
);
assert
(
Cba_ObjIsBoxUser
(
p
,
i
));
Cba_ObjSetFunc
(
p
,
i
,
x
);
}
static
inline
int
Cba_ObjIsSeq
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
Cba_ObjIsBoxUser
(
p
,
i
)
?
Cba_ObjNtk
(
p
,
i
)
->
fSeq
:
Cba_TypeIsSeq
(
Cba_ObjType
(
p
,
i
));
}
static
inline
int
Cba_FonIsReal
(
int
f
)
{
return
f
>
0
;
}
static
inline
int
Cba_FonIsConst
(
int
f
)
{
return
f
<
0
;
}
...
...
@@ -353,6 +362,8 @@ static inline int Cba_ObjFanin( Cba_Ntk_t * p, int i, int k ) { a
for ( i = 0; (i < Cba_NtkPiNum(p)) && (((iObj) = Cba_NtkPi(p, i)), 1); i++ )
#define Cba_NtkForEachPo( p, iObj, i ) \
for ( i = 0; (i < Cba_NtkPoNum(p)) && (((iObj) = Cba_NtkPo(p, i)), 1); i++ )
#define Cba_NtkForEachBoxSeq( p, iObj, i ) \
for ( i = 0; (i < Cba_NtkBoxSeqNum(p)) && (((iObj) = Cba_NtkBoxSeq(p, i)), 1); i++ )
#define Cba_NtkForEachPiFon( p, iObj, iFon, i ) \
for ( i = 0; (i < Cba_NtkPiNum(p)) && (((iObj) = Cba_NtkPi(p, i)), 1) && (((iFon) = Cba_ObjFon0(p, iObj)), 1); i++ )
...
...
@@ -367,6 +378,8 @@ static inline int Cba_ObjFanin( Cba_Ntk_t * p, int i, int k ) { a
for ( i = 1; i < Vec_StrSize(&p->vObjType) && (((Type) = Cba_ObjType(p, i)), 1); i++ ) if ( !Type ) {} else
#define Cba_NtkForEachBox( p, i ) \
for ( i = 1; i < Vec_StrSize(&p->vObjType); i++ ) if ( !Cba_ObjIsBox(p, i) ) {} else
#define Cba_NtkForEachBoxComb( p, i ) \
for ( i = 1; i < Vec_StrSize(&p->vObjType); i++ ) if ( !Cba_ObjIsBox(p, i) || Cba_ObjIsSeq(p, i) ) {} else
#define Cba_NtkForEachBoxUser( p, i ) \
for ( i = 1; i < Vec_StrSize(&p->vObjType); i++ ) if ( !Cba_ObjIsBoxUser(p, i) ) {} else
#define Cba_NtkForEachBoxPrim( p, i ) \
...
...
@@ -473,6 +486,7 @@ static inline void Cba_NtkFree( Cba_Ntk_t * p )
Vec_IntErase
(
&
p
->
vInputs
);
Vec_IntErase
(
&
p
->
vOutputs
);
Vec_IntErase
(
&
p
->
vOrder
);
Vec_IntErase
(
&
p
->
vSeq
);
// stucture
Vec_StrErase
(
&
p
->
vObjType
);
Vec_IntErase
(
&
p
->
vObjFin0
);
...
...
@@ -555,7 +569,42 @@ static inline void Cba_NtkMissingFonNames( Cba_Ntk_t * p, char * pPref )
if
(
NameId
==
0
)
Cba_FonSetName
(
p
,
iFon
,
Cba_ManNewStrId
(
p
->
pDesign
,
pPref
,
iFon
,
NULL
)
);
}
static
inline
int
Cba_NtkIsSeq
(
Cba_Ntk_t
*
p
)
{
int
iObj
;
if
(
p
->
fSeq
)
return
1
;
if
(
p
->
fComb
)
return
0
;
assert
(
!
p
->
fSeq
&&
!
p
->
fComb
);
Cba_NtkForEachBox
(
p
,
iObj
)
if
(
Cba_ObjIsBoxUser
(
p
,
iObj
)
)
{
if
(
Cba_NtkIsSeq
(
Cba_ObjNtk
(
p
,
iObj
)
)
)
{
p
->
fSeq
=
1
;
return
1
;
}
}
else
if
(
Cba_ObjIsSeq
(
p
,
iObj
)
)
{
p
->
fSeq
=
1
;
return
1
;
}
p
->
fComb
=
1
;
return
0
;
}
static
inline
void
Cba_NtkPrepareSeq
(
Cba_Ntk_t
*
p
)
{
int
iObj
;
assert
(
Cba_NtkBoxSeqNum
(
p
)
==
0
);
if
(
!
Cba_NtkIsSeq
(
p
)
)
return
;
Cba_NtkForEachBox
(
p
,
iObj
)
if
(
Cba_ObjIsSeq
(
p
,
iObj
)
)
Vec_IntPush
(
&
p
->
vSeq
,
iObj
);
// Cba_NtkObjOrder( p, &p->vSeq, NULL );
}
static
inline
void
Cba_NtkCountParams
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
,
int
*
nPis
,
int
*
nPos
,
int
*
nFins
,
int
*
nFons
)
{
int
i
,
iObj
;
...
...
@@ -603,6 +652,7 @@ static inline Cba_Ntk_t * Cba_NtkDupOrder( Cba_Man_t * pMan, Cba_Ntk_t * p, Vec_
return
NULL
;
pNew
=
Cba_NtkDup
(
pMan
,
p
,
vObjs
);
Vec_IntFree
(
vObjs
);
//Cba_NtkPrepareSeq( pNew );
return
pNew
;
}
static
inline
void
Cba_NtkDupAttrs
(
Cba_Ntk_t
*
pNew
,
Cba_Ntk_t
*
p
)
...
...
@@ -627,6 +677,7 @@ static inline int Cba_NtkMemory( Cba_Ntk_t * p )
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vInputs
);
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vOutputs
);
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vOrder
);
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vSeq
);
// stucture
nMem
+=
(
int
)
Vec_StrMemory
(
&
p
->
vObjType
);
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vObjFin0
);
...
...
@@ -658,6 +709,7 @@ static inline void Cba_NtkPrintStats( Cba_Ntk_t * p )
{
printf
(
"pi =%5d "
,
Cba_NtkPiNum
(
p
)
);
printf
(
"po =%5d "
,
Cba_NtkPoNum
(
p
)
);
printf
(
"seq =%5d "
,
Cba_NtkBoxSeqNum
(
p
)
);
printf
(
"box =%5d "
,
Cba_NtkBoxNum
(
p
)
);
printf
(
"prim =%5d "
,
Cba_NtkBoxPrimNum
(
p
)
);
printf
(
"user =%5d "
,
Cba_NtkBoxUserNum
(
p
)
);
...
...
@@ -707,10 +759,15 @@ static inline Cba_Man_t * Cba_ManAlloc( char * pFileName, int nNtks, Abc_Nam_t *
if
(
nNtks
==
1
)
pNew
->
iRoot
=
1
;
return
pNew
;
}
static
inline
void
Cba_ManDupTypeNames
(
Cba_Man_t
*
pNew
,
Cba_Man_t
*
p
)
{
memcpy
(
pNew
->
pTypeNames
,
p
->
pTypeNames
,
sizeof
(
void
*
)
*
CBA_BOX_LAST
);
}
static
inline
Cba_Man_t
*
Cba_ManDup
(
Cba_Man_t
*
p
,
Vec_Int_t
*
(
*
pFuncOrder
)(
Cba_Ntk_t
*
)
)
{
Cba_Ntk_t
*
pNtk
,
*
pNtkNew
;
int
i
;
Cba_Man_t
*
pNew
=
Cba_ManAlloc
(
p
->
pSpec
,
Cba_ManNtkNum
(
p
),
Abc_NamRef
(
p
->
pStrs
),
Abc_NamStart
(
100
,
24
)
);
Cba_ManDupTypeNames
(
pNew
,
p
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
pNtkNew
=
Cba_NtkDupOrder
(
pNew
,
pNtk
,
pFuncOrder
);
...
...
@@ -723,6 +780,12 @@ static inline Cba_Man_t * Cba_ManDup( Cba_Man_t * p, Vec_Int_t*(* pFuncOrder)(Cb
pNew
->
iRoot
=
Cba_ManNtkNum
(
pNew
);
return
pNew
;
}
static
inline
void
Cba_ManPrepareSeq
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkPrepareSeq
(
pNtk
);
}
static
inline
void
Cba_ManFree
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
...
...
@@ -822,14 +885,19 @@ static inline void Cba_ManPrintStats( Cba_Man_t * p, int nModules, int fVerbose
/*=== cbaCba.c ===============================================================*/
/*=== cbaCom.c ===============================================================*/
/*=== cbaNtk.c ===============================================================*/
extern
void
Cba_NtkObjOrder
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vNameIds
);
extern
int
Cba_NtkCiFonNum
(
Cba_Ntk_t
*
p
);
extern
int
Cba_NtkCoFinNum
(
Cba_Ntk_t
*
p
);
extern
int
Cba_NtkCheckComboLoop
(
Cba_Ntk_t
*
p
);
extern
int
Cba_ManIsTop
Order
(
Cba_Man_t
*
p
,
int
(
*
pFuncIsSeq
)(
Cba_Ntk_t
*
,
int
)
);
extern
int
Cba_ManIsTop
oOrder
(
Cba_Man_t
*
p
);
extern
Vec_Int_t
*
Cba_NtkCollectDfs
(
Cba_Ntk_t
*
p
);
extern
Cba_Man_t
*
Cba_ManCollapse
(
Cba_Man_t
*
p
,
int
TypeBuf
);
extern
Cba_Man_t
*
Cba_ManExtractGroup
(
Cba_Man_t
*
p
,
Vec_Int_t
*
vObjs
);
extern
Cba_Man_t
*
Cba_ManDeriveFromGia
(
Gia_Man_t
*
pGia
);
extern
Cba_Man_t
*
Cba_ManInsertGroup
(
Cba_Man_t
*
p
,
Vec_Int_t
*
vObjs
,
Cba_Ntk_t
*
pSyn
);
//extern void Cba_ManPrepareTypeNames( Cba_Man_t * p );
/*=== cbaReadBlif.c ==========================================================*/
extern
Vec_Ptr_t
*
Prs_ManReadBlif
(
char
*
pFileName
);
/*=== cbaReadVer.c ===========================================================*/
...
...
src/base/cba/cbaNtk.c
View file @
7f7b7671
...
...
@@ -32,6 +32,127 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
Synopsis [Order objects by box type and then by name.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
// compares two numbers with the first mismatching char in i-th position
static
inline
int
Cba_CharIsDigit
(
char
c
)
{
return
c
>=
'0'
&&
c
<=
'9'
;
}
int
Cba_StrCmpInt
(
char
*
p1
,
char
*
p2
,
int
i
)
{
// check if one of the mismatching chars is a digit
if
(
Cba_CharIsDigit
(
p1
[
i
])
||
Cba_CharIsDigit
(
p2
[
i
])
)
{
// if previous (equal) char was a digit or if this is first digit on both sides, scroll back
if
(
(
i
>
0
&&
Cba_CharIsDigit
(
p1
[
i
-
1
]))
||
(
Cba_CharIsDigit
(
p1
[
i
])
&&
Cba_CharIsDigit
(
p2
[
i
]))
)
{
int
Num1
,
Num2
;
// find the first digit
for
(
--
i
;
i
>=
0
;
i
--
)
if
(
!
Cba_CharIsDigit
(
p1
[
i
])
)
break
;
i
++
;
// current char is digit
assert
(
Cba_CharIsDigit
(
p1
[
i
])
);
assert
(
Cba_CharIsDigit
(
p2
[
i
])
);
// previous char does not exist or is not a digit
assert
(
i
==
0
||
!
Cba_CharIsDigit
(
p1
[
i
-
1
])
);
assert
(
i
==
0
||
!
Cba_CharIsDigit
(
p2
[
i
-
1
])
);
// compare numbers
Num1
=
atoi
(
p1
+
i
);
Num2
=
atoi
(
p2
+
i
);
if
(
Num1
<
Num2
)
return
-
1
;
if
(
Num1
>
Num2
)
return
1
;
assert
(
0
);
return
0
;
}
}
// compare as usual
if
(
p1
[
i
]
<
p2
[
i
]
)
return
-
1
;
if
(
p1
[
i
]
>
p2
[
i
]
)
return
1
;
assert
(
0
);
return
0
;
}
int
Cba_StrCmp
(
char
**
pp1
,
char
**
pp2
)
{
char
*
p1
=
*
pp1
;
char
*
p2
=
*
pp2
;
int
i
;
for
(
i
=
0
;
p1
[
i
]
&&
p2
[
i
];
i
++
)
if
(
p1
[
i
]
!=
p2
[
i
]
)
return
Cba_StrCmpInt
(
p1
,
p2
,
i
);
assert
(
!
p1
[
i
]
||
!
p2
[
i
]
);
return
Cba_StrCmpInt
(
p1
,
p2
,
i
);
}
void
Cba_NtkObjOrder
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vNameIds
)
{
char
Buffer
[
1000
],
*
pName
;
Vec_Ptr_t
*
vNames
;
int
i
,
iObj
;
if
(
Vec_IntSize
(
vObjs
)
<
2
)
return
;
vNames
=
Vec_PtrAlloc
(
Vec_IntSize
(
vObjs
)
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
{
char
*
pTypeName
=
Cba_NtkTypeName
(
p
,
Cba_ObjType
(
p
,
iObj
)
);
char
*
pInstName
=
vNameIds
?
Cba_NtkStr
(
p
,
Vec_IntEntry
(
vNameIds
,
i
))
:
Cba_ObjNameStr
(
p
,
iObj
);
sprintf
(
Buffer
,
"%s_%s_%d"
,
pTypeName
,
pInstName
,
iObj
);
Vec_PtrPush
(
vNames
,
Abc_UtilStrsav
(
Buffer
)
);
}
// print before
// Vec_PtrForEachEntry( char *, vNames, pName, i )
// printf( "%s \n", pName );
// printf( "\n" );
// do the sorting
Vec_PtrSort
(
vNames
,
(
int
(
*
)(
void
))
Cba_StrCmp
);
// print after
// Vec_PtrForEachEntry( char *, vNames, pName, i )
// printf( "%s \n", pName );
// printf( "\n" );
// reload in a new order
Vec_IntClear
(
vObjs
);
Vec_PtrForEachEntry
(
char
*
,
vNames
,
pName
,
i
)
Vec_IntPush
(
vObjs
,
atoi
(
strrchr
(
pName
,
'_'
)
+
1
)
);
Vec_PtrFreeFree
(
vNames
);
}
/**Function*************************************************************
Synopsis [Returns the number of CI fons.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Cba_NtkCiFonNum
(
Cba_Ntk_t
*
p
)
{
int
i
,
iObj
,
Count
=
Cba_NtkPiNum
(
p
);
Cba_NtkForEachBoxSeq
(
p
,
iObj
,
i
)
Count
+=
Cba_ObjFonNum
(
p
,
iObj
);
return
Count
;
}
int
Cba_NtkCoFinNum
(
Cba_Ntk_t
*
p
)
{
int
i
,
iObj
,
Count
=
Cba_NtkPoNum
(
p
);
Cba_NtkForEachBoxSeq
(
p
,
iObj
,
i
)
Count
+=
Cba_ObjFinNum
(
p
,
iObj
);
return
Count
;
}
/**Function*************************************************************
Synopsis [Returns 1 if the manager is in the topo order.]
Description []
...
...
@@ -41,19 +162,20 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
int
Cba_NtkIsTopoOrder
(
Cba_Ntk_t
*
p
,
int
(
*
pFuncIsSeq
)(
Cba_Ntk_t
*
,
int
)
)
int
Cba_NtkIsTopoOrder
(
Cba_Ntk_t
*
p
)
{
int
i
,
iObj
,
iFin
,
iFanin
,
fTopo
=
1
;
int
i
,
k
,
iObj
,
iFin
,
iFanin
,
fTopo
=
1
;
Vec_Bit_t
*
vVisited
=
Vec_BitStart
(
Cba_NtkObjNum
(
p
)
+
1
);
// mark PIs and seq objects
Cba_NtkForEachObj
(
p
,
iObj
)
if
(
Cba_ObjIsPi
(
p
,
iObj
)
||
pFuncIsSeq
(
p
,
iObj
)
)
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Vec_BitWriteEntry
(
vVisited
,
iObj
,
1
);
Cba_NtkForEachBoxSeq
(
p
,
iObj
,
i
)
Vec_BitWriteEntry
(
vVisited
,
iObj
,
1
);
// visit combinational nodes
Cba_NtkForEachBox
(
p
,
iObj
)
if
(
!
pFunc
IsSeq
(
p
,
iObj
)
)
if
(
!
Cba_Obj
IsSeq
(
p
,
iObj
)
)
{
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
i
)
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
k
)
if
(
!
Vec_BitEntry
(
vVisited
,
iFanin
)
)
fTopo
=
0
;
if
(
!
fTopo
)
...
...
@@ -61,10 +183,19 @@ int Cba_NtkIsTopoOrder( Cba_Ntk_t * p, int(* pFuncIsSeq)(Cba_Ntk_t*, int) )
Vec_BitWriteEntry
(
vVisited
,
iObj
,
1
);
}
// visit POs and seq objects
Cba_NtkForEachObj
(
p
,
iObj
)
if
(
Cba_ObjIsPo
(
p
,
iObj
)
||
pFuncIsSeq
(
p
,
iObj
)
)
if
(
fTopo
)
Cba_NtkForEachPo
(
p
,
iObj
,
i
)
{
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
i
)
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
k
)
if
(
!
Vec_BitEntry
(
vVisited
,
iFanin
)
)
fTopo
=
0
;
if
(
!
fTopo
)
break
;
}
if
(
fTopo
)
Cba_NtkForEachBoxSeq
(
p
,
iObj
,
i
)
{
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
k
)
if
(
!
Vec_BitEntry
(
vVisited
,
iFanin
)
)
fTopo
=
0
;
if
(
!
fTopo
)
...
...
@@ -73,11 +204,11 @@ int Cba_NtkIsTopoOrder( Cba_Ntk_t * p, int(* pFuncIsSeq)(Cba_Ntk_t*, int) )
Vec_BitFree
(
vVisited
);
return
fTopo
;
}
int
Cba_ManIsTop
Order
(
Cba_Man_t
*
p
,
int
(
*
pFuncIsSeq
)(
Cba_Ntk_t
*
,
int
)
)
int
Cba_ManIsTop
oOrder
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
if
(
!
Cba_NtkIsTopoOrder
(
pNtk
,
pFuncIsSeq
)
)
if
(
!
Cba_NtkIsTopoOrder
(
pNtk
)
)
return
0
;
return
1
;
}
...
...
@@ -104,7 +235,7 @@ int Cba_NtkCheckComboLoop_rec( Cba_Ntk_t * p, int iObj )
return
0
;
Cba_ObjSetCopy
(
p
,
iObj
,
0
);
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
k
)
// if ( !Clr_Ntk
ObjIsSeq(p, iFanin) )
if
(
!
Cba_
ObjIsSeq
(
p
,
iFanin
)
)
if
(
!
Cba_NtkCheckComboLoop_rec
(
p
,
iFanin
)
)
return
0
;
//Cba_ObjSetCopy( p, iObj, 1 );
...
...
@@ -116,7 +247,7 @@ int Cba_NtkCheckComboLoop( Cba_Ntk_t * p )
int
iObj
;
Cba_NtkCleanObjCopies
(
p
);
// -1 = not visited; 0 = on the path; 1 = finished
Cba_NtkForEachBox
(
p
,
iObj
)
// if ( !Clr_Ntk
ObjIsSeq(p, iObj) )
if
(
!
Cba_
ObjIsSeq
(
p
,
iObj
)
)
if
(
!
Cba_NtkCheckComboLoop_rec
(
p
,
iObj
)
)
{
printf
(
"Cyclic dependency of user boxes is detected.
\n
"
);
...
...
@@ -150,9 +281,11 @@ Vec_Int_t * Cba_NtkCollectDfs( Cba_Ntk_t * p )
{
int
i
,
k
,
iObj
,
iFin
,
iFanin
;
Vec_Int_t
*
vObjs
=
Vec_IntAlloc
(
Cba_NtkObjNum
(
p
)
);
// collect PIs
// collect PIs
and seq boxes
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Vec_IntPush
(
vObjs
,
iObj
);
Cba_NtkForEachBoxSeq
(
p
,
iObj
,
i
)
Vec_IntPush
(
vObjs
,
iObj
);
// prepare leaves
Cba_NtkCleanObjCopies
(
p
);
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
...
...
@@ -161,18 +294,12 @@ Vec_Int_t * Cba_NtkCollectDfs( Cba_Ntk_t * p )
Cba_NtkForEachPo
(
p
,
iObj
,
i
)
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
k
)
Cba_NtkCollectDfs_rec
(
p
,
iFanin
,
vObjs
);
// additionally collect user modules without outputs
Cba_NtkForEachBoxUser
(
p
,
iObj
)
if
(
Cba_ObjFonNum
(
p
,
iObj
)
==
0
)
Cba_NtkForEachBoxSeq
(
p
,
iObj
,
i
)
Cba_ObjForEachFinFaninReal
(
p
,
iObj
,
iFin
,
iFanin
,
k
)
Cba_NtkCollectDfs_rec
(
p
,
iFanin
,
vObjs
);
// collect POs
Cba_NtkForEachPo
(
p
,
iObj
,
i
)
Vec_IntPush
(
vObjs
,
iObj
);
// collect user boxes without fanouts
Cba_NtkForEachBoxUser
(
p
,
iObj
)
if
(
Cba_ObjFonNum
(
p
,
iObj
)
==
0
)
Vec_IntPush
(
vObjs
,
iObj
);
assert
(
Vec_IntSize
(
vObjs
)
<=
Cba_NtkObjNum
(
p
)
);
if
(
Vec_IntSize
(
vObjs
)
!=
Cba_NtkObjNum
(
p
)
)
printf
(
"Warning: DSF ordering for module
\"
%s
\"
collected %d out of %d objects.
\n
"
,
Cba_NtkName
(
p
),
Vec_IntSize
(
vObjs
),
Cba_NtkObjNum
(
p
)
);
...
...
@@ -299,6 +426,7 @@ Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p, int TypeBuf )
Cba_Ntk_t
*
pRoot
=
Cba_ManRoot
(
p
),
*
pRootNew
;
Vec_Int_t
*
vSigs
=
Vec_IntAlloc
(
1000
);
int
i
,
iObj
,
iObjNew
,
iFon
,
nObjs
=
0
,
nFins
=
0
,
nFons
=
0
;
Cba_ManDupTypeNames
(
pNew
,
p
);
Cba_ManGetClpStats
(
p
,
&
nObjs
,
&
nFins
,
&
nFons
);
pRootNew
=
Cba_NtkAlloc
(
pNew
,
Cba_NtkNameId
(
pRoot
),
Cba_NtkPiNum
(
pRoot
),
Cba_NtkPoNum
(
pRoot
),
nObjs
,
nFins
,
nFons
);
Cba_NtkAdd
(
pNew
,
pRootNew
);
...
...
@@ -342,6 +470,7 @@ Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p, int TypeBuf )
assert
(
Cba_NtkFonNum
(
pRootNew
)
==
Cba_NtkFonNumAlloc
(
pRootNew
)
);
// create internal node names
Cba_NtkMissingFonNames
(
pRootNew
,
"m"
);
//Cba_NtkPrepareSeq( pRootNew );
return
pNew
;
}
...
...
@@ -469,6 +598,7 @@ Cba_Man_t * Cba_ManExtractGroup( Cba_Man_t * p, Vec_Int_t * vObjs )
Vec_Int_t
*
vFonIns
=
Cba_NtkCollectInFons
(
pRoot
,
vObjs
);
Vec_Int_t
*
vFonOuts
=
Cba_NtkCollectOutFons
(
pRoot
,
vObjs
);
int
nObjs
,
nFins
,
nFons
;
Cba_ManDupTypeNames
(
pNew
,
p
);
// collect stats
Cba_NtkCollectGroupStats
(
pRoot
,
vObjs
,
&
nFins
,
&
nFons
);
nObjs
=
Vec_IntSize
(
vObjs
)
+
Vec_IntSize
(
vFonIns
)
+
Vec_IntSize
(
vFonOuts
);
...
...
@@ -484,6 +614,7 @@ Cba_Man_t * Cba_ManExtractGroup( Cba_Man_t * p, Vec_Int_t * vObjs )
// add group nodes
Cba_ManExtractGroupInt
(
pRootNew
,
pRoot
,
vObjs
,
vFonIns
,
vFonOuts
);
Cba_NtkMissingFonNames
(
pRootNew
,
"b"
);
//Cba_NtkPrepareSeq( pRootNew );
// cleanup
Vec_IntFree
(
vFonIns
);
Vec_IntFree
(
vFonOuts
);
...
...
@@ -550,6 +681,7 @@ Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia )
Vec_Int_t
*
vLit2Fon
=
Vec_IntStartFull
(
2
*
Gia_ManObjNum
(
pGia
)
);
int
i
,
iObj
,
iObjNew
,
NameId
,
iLit0
,
iFon0
;
Gia_Obj_t
*
pObj
;
//Cba_ManPrepareTypeNames( p );
Cba_NtkAdd
(
p
,
pNtk
);
Cba_NtkCleanObjNames
(
pNtk
);
Gia_ManForEachCiId
(
pGia
,
iObj
,
i
)
...
...
@@ -661,11 +793,9 @@ void Cba_NtkInsertGroup( Cba_Ntk_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn )
}
Cba_Man_t
*
Cba_ManInsertGroup
(
Cba_Man_t
*
p
,
Vec_Int_t
*
vObjs
,
Cba_Ntk_t
*
pSyn
)
{
extern
Vec_Int_t
*
Clr_NtkCollectDfs
(
Cba_Ntk_t
*
p
);
Cba_NtkInsertGroup
(
Cba_ManRoot
(
p
),
vObjs
,
pSyn
);
// if ( Cba_NtkCheckComboLoop( Cba_ManRoot(p) ) )
// printf( "There is no combo loop!\n" );
return
Cba_ManDup
(
p
,
Clr_NtkCollectDfs
);
Cba_NtkCheckComboLoop
(
Cba_ManRoot
(
p
)
);
return
Cba_ManDup
(
p
,
Cba_NtkCollectDfs
);
}
////////////////////////////////////////////////////////////////////////
...
...
src/base/io/ioReadPla.c
View file @
7f7b7671
...
...
@@ -500,14 +500,14 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros, int fBoth )
pCubeOut
=
(
char
*
)
vTokens
->
pArray
[
1
];
if
(
strlen
(
pCubeIn
)
!=
(
unsigned
)
nInputs
)
{
printf
(
"%s (line %d): Input cube length (%
zu
) differs from the number of inputs (%d).
\n
"
,
printf
(
"%s (line %d): Input cube length (%
d
) differs from the number of inputs (%d).
\n
"
,
Extra_FileReaderGetFileName
(
p
),
iLine
,
strlen
(
pCubeIn
),
nInputs
);
Abc_NtkDelete
(
pNtk
);
return
NULL
;
}
if
(
strlen
(
pCubeOut
)
!=
(
unsigned
)
nOutputs
)
{
printf
(
"%s (line %d): Output cube length (%
zu
) differs from the number of outputs (%d).
\n
"
,
printf
(
"%s (line %d): Output cube length (%
d
) differs from the number of outputs (%d).
\n
"
,
Extra_FileReaderGetFileName
(
p
),
iLine
,
strlen
(
pCubeOut
),
nOutputs
);
Abc_NtkDelete
(
pNtk
);
Extra_ProgressBarStop
(
pProgress
);
...
...
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