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
f6a7f695
Commit
f6a7f695
authored
Jul 31, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to Cba data-structure.
parent
bab71101
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
808 additions
and
258 deletions
+808
-258
src/base/bac/bacCom.c
+3
-3
src/base/cba/cba.c
+2
-2
src/base/cba/cba.h
+79
-15
src/base/cba/cbaBlast.c
+32
-4
src/base/cba/cbaCba.c
+11
-5
src/base/cba/cbaCom.c
+42
-108
src/base/cba/cbaNtk.c
+4
-4
src/base/cba/cbaPrs.h
+13
-6
src/base/cba/cbaReadBlif.c
+198
-4
src/base/cba/cbaReadVer.c
+26
-0
src/base/cba/cbaWriteBlif.c
+31
-51
src/base/cba/cbaWriteVer.c
+366
-56
src/base/main/mainInt.h
+1
-0
No files found.
src/base/bac/bacCom.c
View file @
f6a7f695
...
...
@@ -38,9 +38,9 @@ static int Bac_CommandClp ( Abc_Frame_t * pAbc, int argc, char ** argv );
static
int
Bac_CommandCec
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Bac_CommandTest
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
inline
Bac_Man_t
*
Bac_AbcGetMan
(
Abc_Frame_t
*
pAbc
)
{
return
(
Bac_Man_t
*
)
pAbc
->
pAbc
Cba
;
}
static
inline
void
Bac_AbcFreeMan
(
Abc_Frame_t
*
pAbc
)
{
if
(
pAbc
->
pAbc
Cba
)
Bac_ManFree
(
Bac_AbcGetMan
(
pAbc
));
}
static
inline
void
Bac_AbcUpdateMan
(
Abc_Frame_t
*
pAbc
,
Bac_Man_t
*
p
)
{
Bac_AbcFreeMan
(
pAbc
);
pAbc
->
pAbc
Cba
=
p
;
}
static
inline
Bac_Man_t
*
Bac_AbcGetMan
(
Abc_Frame_t
*
pAbc
)
{
return
(
Bac_Man_t
*
)
pAbc
->
pAbc
Bac
;
}
static
inline
void
Bac_AbcFreeMan
(
Abc_Frame_t
*
pAbc
)
{
if
(
pAbc
->
pAbc
Bac
)
Bac_ManFree
(
Bac_AbcGetMan
(
pAbc
));
}
static
inline
void
Bac_AbcUpdateMan
(
Abc_Frame_t
*
pAbc
,
Bac_Man_t
*
p
)
{
Bac_AbcFreeMan
(
pAbc
);
pAbc
->
pAbc
Bac
=
p
;
}
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
...
...
src/base/cba/cba.c
View file @
f6a7f695
...
...
@@ -4,9 +4,9 @@
SystemName [ABC: Logic synthesis and verification system.]
PackageName [
Verilog parser
.]
PackageName [
Hierarchical word-level netlist
.]
Synopsis [
Parses several flavors of word-level Verilog.
]
Synopsis []
Author [Alan Mishchenko]
...
...
src/base/cba/cba.h
View file @
f6a7f695
...
...
@@ -47,7 +47,8 @@ typedef enum {
CBA_OBJ_BOX
,
// 3: box
CBA_BOX_SLICE
,
CBA_BOX_CONCAT
,
CBA_BOX_CATIN
,
CBA_BOX_CATOUT
,
CBA_BOX_CF
,
CBA_BOX_CT
,
...
...
@@ -112,8 +113,9 @@ typedef enum {
CBA_BOX_ROTL
,
CBA_BOX_ROTR
,
CBA_BOX_
GAT
E
,
CBA_BOX_
NOD
E
,
CBA_BOX_LUT
,
CBA_BOX_GATE
,
CBA_BOX_ASSIGN
,
CBA_BOX_TRI
,
...
...
@@ -188,11 +190,16 @@ struct Cba_Man_t_
Abc_Nam_t
*
pStrs
;
// string manager
Abc_Nam_t
*
pCons
;
// constant manager
Abc_Nam_t
*
pMods
;
// module name manager
Vec_Int_t
vNameMap
;
// mapping names
Vec_Int_t
vNameMap2
;
// mapping names
Vec_Int_t
vUsed
;
// used map entries
Vec_Int_t
vUsed2
;
// used map entries
char
*
pTypeNames
[
CBA_BOX_LAST
];
// internal data
int
iRoot
;
// root network
Vec_Ptr_t
vNtks
;
// networks
// user data
int
nOpens
;
Vec_Str_t
vOut
;
Vec_Str_t
vOut2
;
void
*
pMioLib
;
...
...
@@ -230,6 +237,7 @@ static inline char * Cba_NtkStr( Cba_Ntk_t * p, int i ) { r
static
inline
int
Cba_NtkStrId
(
Cba_Ntk_t
*
p
,
char
*
pName
)
{
return
Cba_ManStrId
(
p
->
pDesign
,
pName
);
}
static
inline
int
Cba_NtkNewStrId
(
Cba_Ntk_t
*
p
,
char
*
pName
)
{
return
Cba_ManNewStrId
(
p
->
pDesign
,
pName
);
}
static
inline
char
*
Cba_NtkConst
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManConst
(
p
->
pDesign
,
i
);
}
static
inline
char
*
Cba_NtkSop
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManConst
(
p
->
pDesign
,
i
);
}
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
];
}
...
...
@@ -301,7 +309,7 @@ static inline Cba_ObjType_t Cba_ObjType( Cba_Ntk_t * p, int i ) { a
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_TypeIsUnary
(
Cba_ObjType_t
Type
)
{
return
Type
==
CBA_BOX_BUF
||
Type
==
CBA_BOX_INV
||
Type
==
CBA_BOX_LNOT
||
Type
==
CBA_BOX_MIN
||
(
Type
>=
CBA_BOX_RAND
&&
Type
<=
CBA_BOX_RXNOR
);
}
static
inline
int
Cba_TypeIsUnary
(
Cba_ObjType_t
Type
)
{
return
Type
==
CBA_BOX_BUF
||
Type
==
CBA_BOX_INV
||
Type
==
CBA_BOX_LNOT
||
Type
==
CBA_BOX_MIN
||
Type
==
CBA_BOX_ABS
||
(
Type
>=
CBA_BOX_RAND
&&
Type
<=
CBA_BOX_RXNOR
);
}
static
inline
int
Cba_TypeIsMux
(
Cba_ObjType_t
Type
)
{
return
Type
==
CBA_BOX_MUX
||
Type
==
CBA_BOX_NMUX
||
Type
==
CBA_BOX_SEL
||
Type
==
CBA_BOX_PSEL
;
}
static
inline
int
Cba_ObjIsPi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PI
;
}
...
...
@@ -312,7 +320,8 @@ static inline int Cba_ObjIsBoxUser( Cba_Ntk_t * p, int i ) { r
static
inline
int
Cba_ObjIsBoxPrim
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
>
CBA_OBJ_BOX
&&
Cba_ObjType
(
p
,
i
)
<
CBA_BOX_LAST
;
}
static
inline
int
Cba_ObjIsGate
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_BOX_GATE
;
}
static
inline
int
Cba_ObjIsSlice
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_BOX_SLICE
;
}
static
inline
int
Cba_ObjIsConcat
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_BOX_CONCAT
;
}
static
inline
int
Cba_ObjIsCatIn
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_BOX_CATIN
;
}
static
inline
int
Cba_ObjIsCatOut
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_BOX_CATOUT
;
}
static
inline
int
Cba_ObjIsUnary
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_TypeIsUnary
(
Cba_ObjType
(
p
,
i
));
}
static
inline
int
Cba_ObjFin0
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
Vec_IntEntry
(
&
p
->
vObjFin0
,
i
);
}
...
...
@@ -354,11 +363,12 @@ static inline int Cba_FonIsReal( int f ) { r
static
inline
int
Cba_FonIsConst
(
int
f
)
{
return
f
<
0
;
}
static
inline
int
Cba_FonConst
(
int
f
)
{
assert
(
Cba_FonIsConst
(
f
));
return
-
f
-
1
;
}
static
inline
int
Cba_FonFromConst
(
int
c
)
{
assert
(
c
>=
0
);
return
-
c
-
1
;
}
static
inline
int
Cba_FonConstRange
(
Cba_Ntk_t
*
p
,
int
f
)
{
assert
(
Cba_FonIsConst
(
f
));
return
atoi
(
Cba_NtkConst
(
p
,
Cba_FonConst
(
f
)));
}
static
inline
int
Cba_FonObj
(
Cba_Ntk_t
*
p
,
int
f
)
{
return
Cba_FonIsReal
(
f
)
?
Vec_IntEntry
(
&
p
->
vFonObj
,
f
)
:
0
;
}
static
inline
int
Cba_FonLeft
(
Cba_Ntk_t
*
p
,
int
f
)
{
return
Cba_NtkHasFonLefts
(
p
)
?
Vec_IntEntry
(
&
p
->
vFonLeft
,
f
)
:
0
;
}
static
inline
int
Cba_FonRight
(
Cba_Ntk_t
*
p
,
int
f
)
{
return
Cba_NtkHasFonRights
(
p
)
?
Vec_IntEntry
(
&
p
->
vFonRight
,
f
)
:
0
;
}
static
inline
int
Cba_FonRange
(
Cba_Ntk_t
*
p
,
int
f
)
{
int
l
=
Cba_FonLeft
(
p
,
f
),
r
=
Cba_FonRight
(
p
,
f
);
return
1
+
(
l
>
r
?
l
-
r
:
r
-
l
);
}
static
inline
int
Cba_FonRange
(
Cba_Ntk_t
*
p
,
int
f
)
{
int
l
,
r
;
if
(
Cba_FonIsConst
(
f
))
return
Cba_FonConstRange
(
p
,
f
);
l
=
Cba_FonLeft
(
p
,
f
),
r
=
Cba_FonRight
(
p
,
f
);
return
1
+
(
l
>
r
?
l
-
r
:
r
-
l
);
}
static
inline
void
Cba_FonSetLeft
(
Cba_Ntk_t
*
p
,
int
f
,
int
x
)
{
assert
(
Cba_NtkHasFonLefts
(
p
));
Vec_IntSetEntry
(
&
p
->
vFonLeft
,
f
,
x
);
}
static
inline
void
Cba_FonSetRight
(
Cba_Ntk_t
*
p
,
int
f
,
int
x
)
{
assert
(
Cba_NtkHasFonRights
(
p
));
Vec_IntSetEntry
(
&
p
->
vFonRight
,
f
,
x
);
}
static
inline
int
Cba_FonCopy
(
Cba_Ntk_t
*
p
,
int
f
)
{
return
Cba_FonIsReal
(
f
)
?
Vec_IntEntry
(
&
p
->
vFonCopy
,
f
)
:
f
;
}
...
...
@@ -791,7 +801,8 @@ static inline Cba_Man_t * Cba_ManAlloc( char * pFileName, int nNtks, Abc_Nam_t *
Abc_NamStrFindOrAdd
(
pNew
->
pCons
,
"1
\'
bz"
,
NULL
);
}
Vec_PtrGrow
(
&
pNew
->
vNtks
,
nNtks
+
1
);
Vec_PtrPush
(
&
pNew
->
vNtks
,
NULL
);
if
(
nNtks
==
1
)
pNew
->
iRoot
=
1
;
// set default root module
pNew
->
iRoot
=
1
;
return
pNew
;
}
static
inline
void
Cba_ManDupTypeNames
(
Cba_Man_t
*
pNew
,
Cba_Man_t
*
p
)
...
...
@@ -830,12 +841,58 @@ static inline void Cba_ManFree( Cba_Man_t * p )
Abc_NamDeref
(
p
->
pStrs
);
Abc_NamDeref
(
p
->
pCons
);
Abc_NamDeref
(
p
->
pMods
);
Vec_IntErase
(
&
p
->
vNameMap
);
Vec_IntErase
(
&
p
->
vUsed
);
Vec_IntErase
(
&
p
->
vNameMap2
);
Vec_IntErase
(
&
p
->
vUsed2
);
Vec_StrErase
(
&
p
->
vOut
);
Vec_StrErase
(
&
p
->
vOut2
);
ABC_FREE
(
p
->
pName
);
ABC_FREE
(
p
->
pSpec
);
ABC_FREE
(
p
);
}
static
inline
int
Cba_ManGetMap
(
Cba_Man_t
*
p
,
int
i
)
{
return
Vec_IntGetEntry
(
&
p
->
vNameMap
,
i
);
}
static
inline
void
Cba_ManSetMap
(
Cba_Man_t
*
p
,
int
i
,
int
x
)
{
assert
(
Vec_IntGetEntry
(
&
p
->
vNameMap
,
i
)
==
0
);
Vec_IntSetEntry
(
&
p
->
vNameMap
,
i
,
x
);
Vec_IntPush
(
&
p
->
vUsed
,
i
);
}
static
inline
void
Cba_ManCleanMap
(
Cba_Man_t
*
p
)
{
int
i
,
Entry
;
Vec_IntForEachEntry
(
&
p
->
vUsed
,
Entry
,
i
)
Vec_IntWriteEntry
(
&
p
->
vNameMap
,
Entry
,
0
);
Vec_IntClear
(
&
p
->
vUsed
);
}
static
inline
int
Cba_NtkGetMap
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManGetMap
(
p
->
pDesign
,
i
);
}
static
inline
void
Cba_NtkSetMap
(
Cba_Ntk_t
*
p
,
int
i
,
int
x
)
{
Cba_ManSetMap
(
p
->
pDesign
,
i
,
x
);
}
static
inline
void
Cba_NtkCleanMap
(
Cba_Ntk_t
*
p
)
{
Cba_ManCleanMap
(
p
->
pDesign
);
}
static
inline
int
Cba_ManGetMap2
(
Cba_Man_t
*
p
,
int
i
)
{
return
Vec_IntGetEntry
(
&
p
->
vNameMap2
,
i
);
}
static
inline
void
Cba_ManSetMap2
(
Cba_Man_t
*
p
,
int
i
,
int
x
)
{
assert
(
Vec_IntGetEntry
(
&
p
->
vNameMap2
,
i
)
==
0
);
Vec_IntSetEntry
(
&
p
->
vNameMap2
,
i
,
x
);
Vec_IntPush
(
&
p
->
vUsed2
,
i
);
}
static
inline
void
Cba_ManCleanMap2
(
Cba_Man_t
*
p
)
{
int
i
,
Entry
;
Vec_IntForEachEntry
(
&
p
->
vUsed2
,
Entry
,
i
)
Vec_IntWriteEntry
(
&
p
->
vNameMap2
,
Entry
,
0
);
Vec_IntClear
(
&
p
->
vUsed2
);
}
static
inline
int
Cba_NtkGetMap2
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManGetMap2
(
p
->
pDesign
,
i
);
}
static
inline
void
Cba_NtkSetMap2
(
Cba_Ntk_t
*
p
,
int
i
,
int
x
)
{
Cba_ManSetMap2
(
p
->
pDesign
,
i
,
x
);
}
static
inline
void
Cba_NtkCleanMap2
(
Cba_Ntk_t
*
p
)
{
Cba_ManCleanMap2
(
p
->
pDesign
);
}
static
inline
int
Cba_ManNewConstId
(
Cba_Man_t
*
p
,
Vec_Str_t
*
vBits
)
{
Vec_Str_t
*
vOut
=
&
p
->
vOut
;
...
...
@@ -859,6 +916,10 @@ static inline int Cba_ManMemory( Cba_Man_t * p )
nMem
+=
Abc_NamMemUsed
(
p
->
pStrs
);
nMem
+=
Abc_NamMemUsed
(
p
->
pCons
);
nMem
+=
Abc_NamMemUsed
(
p
->
pMods
);
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vNameMap
);
nMem
+=
(
int
)
Vec_IntMemory
(
&
p
->
vUsed
);
nMem
+=
(
int
)
Vec_StrMemory
(
&
p
->
vOut
);
nMem
+=
(
int
)
Vec_StrMemory
(
&
p
->
vOut2
);
nMem
+=
(
int
)
Vec_PtrMemory
(
&
p
->
vNtks
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
nMem
+=
Cba_NtkMemory
(
pNtk
);
...
...
@@ -915,7 +976,7 @@ static inline void Cba_ManPrintStats( Cba_Man_t * p, int nModules, int fVerbose
printf
(
"%-12s : "
,
Cba_ManName
(
p
)
);
printf
(
"pi =%5d "
,
Cba_NtkPiNum
(
pRoot
)
);
printf
(
"po =%5d "
,
Cba_NtkPoNum
(
pRoot
)
);
printf
(
"mod =%
6
d "
,
Cba_ManNtkNum
(
p
)
);
printf
(
"mod =%
5
d "
,
Cba_ManNtkNum
(
p
)
);
printf
(
"box =%5d "
,
nPrims
+
nUsers
);
printf
(
"prim =%5d "
,
nPrims
);
printf
(
"user =%5d "
,
nUsers
);
...
...
@@ -931,11 +992,16 @@ static inline void Cba_ManPrintStats( Cba_Man_t * p, int nModules, int fVerbose
}
/*=== cbaBlast.c =============================================================*/
extern
Gia_Man_t
*
Cba_ManBlast
(
Cba_Man_t
*
p
,
int
fBarBufs
,
int
fVerbose
);
extern
Cba_Man_t
*
Cba_ManInsertGia
(
Cba_Man_t
*
p
,
Gia_Man_t
*
pGia
);
extern
Cba_Man_t
*
Cba_ManInsertAbc
(
Cba_Man_t
*
p
,
void
*
pAbc
);
/*=== cbaCba.c ===============================================================*/
extern
Cba_Man_t
*
Cba_ManReadCba
(
char
*
pFileName
);
extern
void
Cba_ManWriteCba
(
char
*
pFileName
,
Cba_Man_t
*
p
);
/*=== cbaCom.c ===============================================================*/
/*=== cbaNtk.c ===============================================================*/
//extern void Cba_ManPrepareTypeNames( Cba_Man_t * p );
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
);
...
...
@@ -946,22 +1012,20 @@ 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
);
extern
Cba_Man_t
*
Cba
_ManReadBlif
(
char
*
pFileName
);
/*=== cbaReadVer.c ===========================================================*/
extern
Vec_Ptr_t
*
Prs
_ManReadVerilog
(
char
*
pFileName
);
extern
Cba_Man_t
*
Cba
_ManReadVerilog
(
char
*
pFileName
);
/*=== cbaWriteBlif.c =========================================================*/
//
extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * p );
//
extern void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p );
extern
void
Prs_ManWriteBlif
(
char
*
pFileName
,
Vec_Ptr_t
*
p
);
extern
void
Cba_ManWriteBlif
(
char
*
pFileName
,
Cba_Man_t
*
p
);
/*=== cbaWriteVer.c ==========================================================*/
extern
void
Prs_ManWriteVerilog
(
char
*
pFileName
,
Vec_Ptr_t
*
p
);
extern
void
Cba_ManWriteVerilog
(
char
*
pFileName
,
Cba_Man_t
*
p
,
int
fInlineConcat
);
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
...
...
src/base/cba/cbaBlast.c
View file @
f6a7f695
/**CFile****************************************************************
FileName [cba.c]
FileName [cba
Blast
.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [
Verilog parser
.]
PackageName [
Hierarchical word-level netlist
.]
Synopsis [
Parses several flavors of word-level Verilog
.]
Synopsis [
Collapsing word-level design
.]
Author [Alan Mishchenko]
...
...
@@ -14,11 +14,15 @@
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
Revision [$Id: cba
Blast
.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
#include "cba.h"
#include "base/abc/abc.h"
#include "map/mio/mio.h"
#include "bool/dec/dec.h"
#include "base/main/mainInt.h"
ABC_NAMESPACE_IMPL_START
...
...
@@ -41,7 +45,31 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Cba_ManBlast
(
Cba_Man_t
*
p
,
int
fBarBufs
,
int
fVerbose
)
{
return
NULL
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t
*
Cba_ManInsertGia
(
Cba_Man_t
*
p
,
Gia_Man_t
*
pGia
)
{
return
NULL
;
}
Cba_Man_t
*
Cba_ManInsertAbc
(
Cba_Man_t
*
p
,
void
*
pAbc
)
{
Abc_Ntk_t
*
pNtk
=
(
Abc_Ntk_t
*
)
pAbc
;
return
(
Cba_Man_t
*
)
pNtk
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
...
...
src/base/cba/cbaCba.c
View file @
f6a7f695
/**CFile****************************************************************
FileName [cba.c]
FileName [cba
Cba
.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [
Verilog parser
.]
PackageName [
Hierarchical word-level netlist
.]
Synopsis [
Parses several flavors of word-level Verilog
.]
Synopsis [
Reading binary representation
.]
Author [Alan Mishchenko]
...
...
@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
Revision [$Id: cba
Cba
.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
...
...
@@ -41,7 +41,13 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
Cba_Man_t
*
Cba_ManReadCba
(
char
*
pFileName
)
{
return
NULL
;
}
void
Cba_ManWriteCba
(
char
*
pFileName
,
Cba_Man_t
*
p
)
{
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
...
...
src/base/cba/cbaCom.c
View file @
f6a7f695
...
...
@@ -28,7 +28,6 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*
static
int
Cba_CommandRead
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Cba_CommandWrite
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Cba_CommandPs
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
...
@@ -37,7 +36,6 @@ static int Cba_CommandGet ( Abc_Frame_t * pAbc, int argc, char ** argv );
static
int
Cba_CommandClp
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Cba_CommandCec
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Cba_CommandTest
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
*/
static
inline
Cba_Man_t
*
Cba_AbcGetMan
(
Abc_Frame_t
*
pAbc
)
{
return
(
Cba_Man_t
*
)
pAbc
->
pAbcCba
;
}
static
inline
void
Cba_AbcFreeMan
(
Abc_Frame_t
*
pAbc
)
{
if
(
pAbc
->
pAbcCba
)
Cba_ManFree
(
Cba_AbcGetMan
(
pAbc
));
}
...
...
@@ -60,7 +58,6 @@ static inline void Cba_AbcUpdateMan( Abc_Frame_t * pAbc, Cba_Man_t * p )
******************************************************************************/
void
Cba_Init
(
Abc_Frame_t
*
pAbc
)
{
/*
Cmd_CommandAdd
(
pAbc
,
"New word level"
,
"@read"
,
Cba_CommandRead
,
0
);
Cmd_CommandAdd
(
pAbc
,
"New word level"
,
"@write"
,
Cba_CommandWrite
,
0
);
Cmd_CommandAdd
(
pAbc
,
"New word level"
,
"@ps"
,
Cba_CommandPs
,
0
);
...
...
@@ -69,7 +66,6 @@ void Cba_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"New word level"
,
"@clp"
,
Cba_CommandClp
,
0
);
Cmd_CommandAdd
(
pAbc
,
"New word level"
,
"@cec"
,
Cba_CommandCec
,
0
);
Cmd_CommandAdd
(
pAbc
,
"New word level"
,
"@test"
,
Cba_CommandTest
,
0
);
*/
}
/**Function********************************************************************
...
...
@@ -89,8 +85,6 @@ void Cba_End( Abc_Frame_t * pAbc )
}
#if 0
/**Function********************************************************************
Synopsis []
...
...
@@ -145,8 +139,7 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
}
fclose
(
pFile
);
#if 0
/*
// perform reading
if ( fUseAbc || fUsePtr )
{
...
...
@@ -162,48 +155,26 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
}
Abc_NtkDelete( pAbcNtk );
}
else if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) )
{
vDes = Prs_ManReadBlif( pFileName );
if ( vDes && Vec_PtrSize(vDes) )
p = Prs_ManBuildCba( pFileName, vDes );
if ( vDes )
Prs_ManVecFree( vDes );
}
else
*/
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"blif"
)
)
p
=
Cba_ManReadBlif
(
pFileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
{
vDes = Prs_ManReadVerilog( pFileName );
if ( vDes && Vec_PtrSize(vDes) )
p = Prs_ManBuildCba( pFileName, vDes );
if ( vDes )
Prs_ManVecFree( vDes );
}
else if ( !strcmp( Extra_FileNameExtension(pFileName), "smt" ) )
{
vDes = NULL;//Prs_ManReadSmt( pFileName );
if ( vDes && Vec_PtrSize(vDes) )
p = Prs_ManBuildCba( pFileName, vDes );
if ( vDes )
Prs_ManVecFree( vDes );
}
p
=
Cba_ManReadVerilog
(
pFileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"cba"
)
)
{
p
=
Cba_ManReadCba
(
pFileName
);
}
else
{
printf
(
"Unrecognized input file extension.
\n
"
);
return
0
;
}
Cba_AbcUpdateMan
(
pAbc
,
p
);
#endif
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @read [-apvh] <file_name>
\n
"
);
Abc_Print( -2, "\t reads hierarchical design
in BLIF or Verilog
\n" );
Abc_Print( -2, "\t-a : toggle using old ABC parser [default = %s]\n", fUseAbc? "yes": "no" );
Abc_Print( -2, "\t-p : toggle using Ptr construction [default = %s]\n", fUsePtr? "yes": "no" );
Abc_Print
(
-
2
,
"
\t
reads hierarchical design
\n
"
);
//
Abc_Print( -2, "\t-a : toggle using old ABC parser [default = %s]\n", fUseAbc? "yes": "no" );
//
Abc_Print( -2, "\t-p : toggle using Ptr construction [default = %s]\n", fUsePtr? "yes": "no" );
Abc_Print
(
-
2
,
"
\t
-v : toggle printing verbose information [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
...
...
@@ -224,19 +195,15 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cba_Man_t
*
p
=
Cba_AbcGetMan
(
pAbc
);
char
*
pFileName
=
NULL
;
int fUseAssign = 1;
int fUsePtr = 0;
int
fInclineCats
=
1
;
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while ( ( c = Extra_UtilGetopt( argc, argv, "
ap
vh" ) ) != EOF )
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"
c
vh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case 'a':
fUseAssign ^= 1;
break;
case 'p':
fUsePtr ^= 1;
case
'c'
:
fInclineCats
^=
1
;
break
;
case
'v'
:
fVerbose
^=
1
;
...
...
@@ -253,7 +220,6 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
}
#if 0
if
(
argc
==
globalUtilOptind
+
1
)
pFileName
=
argv
[
globalUtilOptind
];
else
if
(
argc
==
globalUtilOptind
&&
p
)
...
...
@@ -267,21 +233,7 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"blif"
)
)
Cba_ManWriteBlif
(
pFileName
,
p
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
{
if ( fUsePtr )
{
Vec_Ptr_t * vPtr = Cba_PtrDeriveFromCba( p );
if ( vPtr == NULL )
printf( "Converting to Ptr has failed.\n" );
else
{
Cba_PtrDumpVerilog( pFileName, vPtr );
Cba_PtrFree( vPtr );
}
}
else
Cba_ManWriteVerilog( pFileName, p, fUseAssign );
}
Cba_ManWriteVerilog
(
pFileName
,
p
,
fInclineCats
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"cba"
)
)
Cba_ManWriteCba
(
pFileName
,
p
);
else
...
...
@@ -289,14 +241,11 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
printf
(
"Unrecognized output file extension.
\n
"
);
return
0
;
}
#endif
return
0
;
usage:
Abc_Print( -2, "usage: @write [-
ap
vh]\n" );
Abc_Print
(
-
2
,
"usage: @write [-
c
vh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
writes the design into a file in BLIF or Verilog
\n
"
);
Abc_Print( -2, "\t-a : toggle using assign-statement for primitives [default = %s]\n", fUseAssign? "yes": "no" );
Abc_Print( -2, "\t-p : toggle using Ptr construction (mapped Verilog only) [default = %s]\n", fUsePtr? "yes": "no" );
Abc_Print
(
-
2
,
"
\t
-c : toggle inlining input concatenations [default = %s]
\n
"
,
fInclineCats
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-v : toggle printing verbose information [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
...
...
@@ -348,11 +297,7 @@ int Cba_CommandPs( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
1
,
"Cba_CommandPs(): There is no current design.
\n
"
);
return
0
;
}
#if 0
Cba_ManPrintStats
(
p
,
nModules
,
fVerbose
);
#endif
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @ps [-M num] [-vh]
\n
"
);
...
...
@@ -401,17 +346,13 @@ int Cba_CommandPut( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
1
,
"Cba_CommandPut(): There is no current design.
\n
"
);
return
0
;
}
#if 0
pGia = Cba_ManExtract( p, fBarBufs, fVerbose );
pGia
=
Cba_ManBlast
(
p
,
fBarBufs
,
fVerbose
);
if
(
pGia
==
NULL
)
{
Abc_Print
(
1
,
"Cba_CommandPut(): Conversion to AIG has failed.
\n
"
);
return
0
;
}
Abc_FrameUpdateGia
(
pAbc
,
pGia
);
#endif
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @put [-bvh]
\n
"
);
...
...
@@ -460,7 +401,6 @@ int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
}
#if 0
if
(
fMapped
)
{
if
(
pAbc
->
pNtkCur
==
NULL
)
...
...
@@ -468,7 +408,7 @@ int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
1
,
"Cba_CommandGet(): There is no current mapped design.
\n
"
);
return
0
;
}
pNew =
(Cba_Man_t *)
Cba_ManInsertAbc( p, pAbc->pNtkCur );
pNew
=
Cba_ManInsertAbc
(
p
,
pAbc
->
pNtkCur
);
}
else
{
...
...
@@ -480,8 +420,6 @@ int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv )
pNew
=
Cba_ManInsertGia
(
p
,
pAbc
->
pGia
);
}
Cba_AbcUpdateMan
(
pAbc
,
pNew
);
#endif
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @get [-mvh]
\n
"
);
...
...
@@ -526,12 +464,8 @@ int Cba_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
1
,
"Cba_CommandGet(): There is no current design.
\n
"
);
return
0
;
}
#if 0
pNew
=
Cba_ManCollapse
(
p
,
CBA_BOX_BUF
);
Cba_AbcUpdateMan
(
pAbc
,
pNew
);
#endif
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @clp [-vh]
\n
"
);
...
...
@@ -554,11 +488,10 @@ usage:
******************************************************************************/
int
Cba_CommandCec
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
Cba_Man_t * p = Cba_AbcGetMan(pAbc);
Cba_Man_t
*
p
=
Cba_AbcGetMan
(
pAbc
)
,
*
pTemp
;
Gia_Man_t
*
pFirst
,
*
pSecond
,
*
pMiter
;
Cec_ParCec_t
ParsCec
,
*
pPars
=
&
ParsCec
;
Vec_Ptr_t * vDes;
char * FileName, * pStr, ** pArgvNew;
char
*
pFileName
,
*
pStr
,
**
pArgvNew
;
int
c
,
nArgcNew
,
fDumpMiter
=
0
;
FILE
*
pFile
;
Cec_ManCecSetDefaultParams
(
pPars
);
...
...
@@ -582,7 +515,6 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
}
#if 0
pArgvNew
=
argv
+
globalUtilOptind
;
nArgcNew
=
argc
-
globalUtilOptind
;
if
(
nArgcNew
!=
1
)
...
...
@@ -592,41 +524,42 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
-
1
,
"File name is not given on the command line.
\n
"
);
return
1
;
}
FileName = p->pSpec;
p
FileName
=
p
->
pSpec
;
}
else
FileName = pArgvNew[0];
p
FileName
=
pArgvNew
[
0
];
// fix the wrong symbol
for ( pStr = FileName; *pStr; pStr++ )
for
(
pStr
=
p
FileName
;
*
pStr
;
pStr
++
)
if
(
*
pStr
==
'>'
)
*
pStr
=
'\\'
;
if ( (pFile = fopen( FileName, "r" )) == NULL )
if
(
(
pFile
=
fopen
(
p
FileName
,
"r"
))
==
NULL
)
{
Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (
FileName = Extra_FileGetSimilarName(
FileName, ".v", ".blif", NULL, NULL, NULL )) )
Abc_Print( 1, "Did you mean \"%s\"?", FileName );
Abc_Print
(
-
1
,
"Cannot open input file
\"
%s
\"
. "
,
p
FileName
);
if
(
(
pFileName
=
Extra_FileGetSimilarName
(
p
FileName
,
".v"
,
".blif"
,
NULL
,
NULL
,
NULL
))
)
Abc_Print
(
1
,
"Did you mean
\"
%s
\"
?"
,
p
FileName
);
Abc_Print
(
1
,
"
\n
"
);
return
1
;
}
fclose
(
pFile
);
// extract AIG from the current design
pFirst = Cba_Man
Extrac
t( p, 0, 0 );
pFirst
=
Cba_Man
Blas
t
(
p
,
0
,
0
);
if
(
pFirst
==
NULL
)
{
Abc_Print
(
-
1
,
"Extracting AIG from the current design has failed.
\n
"
);
return
0
;
}
// extract AIG from the second design
if ( !strcmp( Extra_FileNameExtension(FileName), "blif" ) )
vDes = Prs_ManReadBlif( FileName );
else if ( !strcmp( Extra_FileNameExtension(FileName), "v" ) )
vDes = Prs_ManReadVerilog( FileName );
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"blif"
)
)
pTemp
=
Cba_ManReadBlif
(
pFileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
pTemp
=
Cba_ManReadVerilog
(
pFileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"cba"
)
)
pTemp
=
Cba_ManReadCba
(
pFileName
);
else
assert
(
0
);
p = Prs_ManBuildCba( FileName, vDes );
Prs_ManVecFree( vDes );
pSecond = Cba_ManExtract( p, 0, 0 );
Cba_ManFree( p );
pSecond
=
Cba_ManBlast
(
pTemp
,
0
,
0
);
Cba_ManFree
(
pTemp
);
if
(
pSecond
==
NULL
)
{
Gia_ManStop
(
pFirst
);
...
...
@@ -648,8 +581,6 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
}
Gia_ManStop
(
pFirst
);
Gia_ManStop
(
pSecond
);
#endif
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @cec [-vh]
\n
"
);
...
...
@@ -672,6 +603,8 @@ usage:
******************************************************************************/
int
Cba_CommandTest
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Prs_ManReadBlifTest
();
Cba_Man_t
*
p
=
Cba_AbcGetMan
(
pAbc
);
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
...
...
@@ -688,11 +621,14 @@ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
goto
usage
;
}
}
/*
if ( p == NULL )
{
Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" );
return 0;
}
*/
Prs_ManReadBlifTest
();
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @test [-vh]
\n
"
);
...
...
@@ -702,8 +638,6 @@ usage:
return
1
;
}
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/base/cba/cbaNtk.c
View file @
f6a7f695
/**CFile****************************************************************
FileName [cba.c]
FileName [cba
Ntk
.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [
Verilog parser
.]
PackageName [
Hierarchical word-level netlist
.]
Synopsis [
Parses several flavors of word-level Verilog
.]
Synopsis [
Network manipulation
.]
Author [Alan Mishchenko]
...
...
@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
Revision [$Id: cba
Ntk
.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
...
...
src/base/cba/cbaPrs.h
View file @
f6a7f695
...
...
@@ -60,6 +60,7 @@ struct Prs_Ntk_t_
unsigned
fHasCXs
:
1
;
unsigned
fHasCZs
:
1
;
Abc_Nam_t
*
pStrs
;
Abc_Nam_t
*
pSops
;
// interface
Vec_Int_t
vOrder
;
// order of signals
// signal names
...
...
@@ -89,6 +90,7 @@ struct Prs_Man_t_
char
*
pLimit
;
// end of file
char
*
pCur
;
// current position
Abc_Nam_t
*
pStrs
;
// string manager
Abc_Nam_t
*
pSops
;
// cover manager
Prs_Ntk_t
*
pNtk
;
// current network
Vec_Ptr_t
*
vNtks
;
// input networks
// temporary data
...
...
@@ -107,6 +109,7 @@ struct Prs_Man_t_
static
inline
Prs_Ntk_t
*
Prs_ManNtk
(
Vec_Ptr_t
*
vPrs
,
int
i
)
{
return
i
>=
0
&&
i
<
Vec_PtrSize
(
vPrs
)
?
(
Prs_Ntk_t
*
)
Vec_PtrEntry
(
vPrs
,
i
)
:
NULL
;
}
static
inline
Prs_Ntk_t
*
Prs_ManRoot
(
Vec_Ptr_t
*
vPrs
)
{
return
Prs_ManNtk
(
vPrs
,
0
);
}
static
inline
Abc_Nam_t
*
Prs_ManNameMan
(
Vec_Ptr_t
*
vPrs
)
{
return
Prs_ManRoot
(
vPrs
)
->
pStrs
;
}
static
inline
Abc_Nam_t
*
Prs_ManFuncMan
(
Vec_Ptr_t
*
vPrs
)
{
return
Prs_ManRoot
(
vPrs
)
->
pSops
;
}
static
inline
int
Prs_NtkId
(
Prs_Ntk_t
*
p
)
{
return
p
->
iModuleName
;
}
static
inline
int
Prs_NtkPioNum
(
Prs_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vInouts
);
}
...
...
@@ -115,6 +118,7 @@ static inline int Prs_NtkPoNum( Prs_Ntk_t * p ) { return
static
inline
int
Prs_NtkBoxNum
(
Prs_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vObjs
);
}
static
inline
int
Prs_NtkObjNum
(
Prs_Ntk_t
*
p
)
{
return
Prs_NtkPioNum
(
p
)
+
Prs_NtkPiNum
(
p
)
+
Prs_NtkPoNum
(
p
)
+
Prs_NtkBoxNum
(
p
);
}
static
inline
char
*
Prs_NtkStr
(
Prs_Ntk_t
*
p
,
int
h
)
{
return
Abc_NamStr
(
p
->
pStrs
,
h
);
}
static
inline
char
*
Prs_NtkSop
(
Prs_Ntk_t
*
p
,
int
h
)
{
return
Abc_NamStr
(
p
->
pSops
,
h
);
}
static
inline
char
*
Prs_NtkName
(
Prs_Ntk_t
*
p
)
{
return
Prs_NtkStr
(
p
,
Prs_NtkId
(
p
));
}
static
inline
int
Prs_NtkSigName
(
Prs_Ntk_t
*
p
,
int
i
)
{
if
(
!
p
->
fSlices
)
return
i
;
assert
(
Abc_Lit2Att2
(
i
)
==
CBA_PRS_NAME
);
return
Abc_Lit2Var2
(
i
);
}
...
...
@@ -182,6 +186,7 @@ static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices )
p
->
pNtk
->
iModuleName
=
iName
;
p
->
pNtk
->
fSlices
=
fSlices
;
p
->
pNtk
->
pStrs
=
Abc_NamRef
(
p
->
pStrs
);
p
->
pNtk
->
pSops
=
Abc_NamRef
(
p
->
pSops
);
Vec_PtrPush
(
p
->
vNtks
,
p
->
pNtk
);
}
static
inline
void
Prs_ManFinalizeNtk
(
Prs_Man_t
*
p
)
...
...
@@ -264,14 +269,17 @@ static inline Prs_Man_t * Prs_ManAlloc( char * pFileName )
p
->
pLimit
=
pLimit
;
p
->
pCur
=
pBuffer
;
p
->
pStrs
=
Abc_NamStart
(
1000
,
24
);
p
->
pSops
=
Abc_NamStart
(
100
,
24
);
p
->
vNtks
=
Vec_PtrAlloc
(
100
);
Abc_NamStrFindOrAdd
(
p
->
pSops
,
" 0
\n
"
,
NULL
);
Abc_NamStrFindOrAdd
(
p
->
pSops
,
" 1
\n
"
,
NULL
);
return
p
;
}
static
inline
void
Prs_NtkFree
(
Prs_Ntk_t
*
p
)
{
if
(
p
->
pStrs
)
Abc_NamDeref
(
p
->
pStr
s
);
if
(
p
->
pStrs
)
Abc_NamDeref
(
p
->
pStrs
);
if
(
p
->
pSops
)
Abc_NamDeref
(
p
->
pSop
s
);
Vec_IntErase
(
&
p
->
vOrder
);
Vec_IntErase
(
&
p
->
vInouts
);
Vec_IntErase
(
&
p
->
vInputs
);
...
...
@@ -298,10 +306,9 @@ static inline void Prs_ManVecFree( Vec_Ptr_t * vPrs )
static
inline
void
Prs_ManFree
(
Prs_Man_t
*
p
)
{
if
(
p
->
pStrs
)
Abc_NamDeref
(
p
->
pStrs
);
if
(
p
->
vNtks
)
Prs_ManVecFree
(
p
->
vNtks
);
if
(
p
->
pStrs
)
Abc_NamDeref
(
p
->
pStrs
);
if
(
p
->
pSops
)
Abc_NamDeref
(
p
->
pSops
);
if
(
p
->
vNtks
)
Prs_ManVecFree
(
p
->
vNtks
);
// temporary
Vec_StrErase
(
&
p
->
vCover
);
Vec_IntErase
(
&
p
->
vTemp
);
...
...
src/base/cba/cbaReadBlif.c
View file @
f6a7f695
...
...
@@ -234,8 +234,8 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
}
assert
(
Vec_StrSize
(
&
p
->
vCover
)
>
0
);
Vec_StrPush
(
&
p
->
vCover
,
'\0'
);
//iToken = Abc_NamStrFindOrAdd( p->pStrs, Vec_StrArray(&p->vCover), NULL
);
iToken
=
Ptr_SopToType
(
Vec_StrArray
(
&
p
->
vCover
)
);
// iToken = Ptr_SopToType( Vec_StrArray(&p->vCover)
);
iToken
=
Abc_NamStrFindOrAdd
(
p
->
pSops
,
Vec_StrArray
(
&
p
->
vCover
),
NULL
);
Vec_StrClear
(
&
p
->
vCover
);
// set the cover to the module of this box
assert
(
Prs_BoxNtk
(
p
->
pNtk
,
Prs_NtkBoxNum
(
p
->
pNtk
)
-
1
)
==
1
);
// default const 0
...
...
@@ -433,17 +433,211 @@ void Prs_ManReadBlifTest()
abctime
clk
=
Abc_Clock
();
extern
void
Prs_ManWriteBlif
(
char
*
pFileName
,
Vec_Ptr_t
*
vPrs
);
// Vec_Ptr_t * vPrs = Prs_ManReadBlif( "aga/ray/ray_hie_oper.blif" );
Vec_Ptr_t
*
vPrs
=
Prs_ManReadBlif
(
"c/hie/dump/1/netlist_1_out8.blif"
);
// Vec_Ptr_t * vPrs = Prs_ManReadBlif( "c/hie/dump/1/netlist_1_out8.blif" );
Vec_Ptr_t
*
vPrs
=
Prs_ManReadBlif
(
"add2.blif"
);
if
(
!
vPrs
)
return
;
printf
(
"Finished reading %d networks. "
,
Vec_PtrSize
(
vPrs
)
);
printf
(
"NameIDs = %d. "
,
Abc_NamObjNumMax
(
Prs_ManNameMan
(
vPrs
))
);
printf
(
"Memory = %.2f MB. "
,
1
.
0
*
Prs_ManMemory
(
vPrs
)
/
(
1
<<
20
)
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
// Abc_NamPrint( p->pStrs );
Prs_ManWriteBlif
(
"
c/hie/dump/1/netlist_1_out8
_out.blif"
,
vPrs
);
Prs_ManWriteBlif
(
"
add2
_out.blif"
,
vPrs
);
Prs_ManVecFree
(
vPrs
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Prs_CreateBlifFindFon
(
Cba_Ntk_t
*
p
,
int
NameId
)
{
int
iFon
=
Cba_NtkGetMap
(
p
,
NameId
);
if
(
iFon
)
return
iFon
;
printf
(
"Network
\"
%s
\"
: Signal
\"
%s
\"
is not driven.
\n
"
,
Cba_NtkName
(
p
),
Cba_NtkStr
(
p
,
NameId
)
);
return
0
;
}
void
Prs_CreateBlifPio
(
Cba_Ntk_t
*
p
,
Prs_Ntk_t
*
pNtk
)
{
int
i
,
NameId
,
iObj
,
iFon
;
Cba_NtkCleanObjFuncs
(
p
);
Cba_NtkCleanObjNames
(
p
);
Cba_NtkCleanFonNames
(
p
);
// create inputs
Prs_NtkForEachPi
(
pNtk
,
NameId
,
i
)
{
iObj
=
Cba_ObjAlloc
(
p
,
CBA_OBJ_PI
,
0
,
1
);
Cba_ObjSetName
(
p
,
iObj
,
NameId
);
iFon
=
Cba_ObjFon0
(
p
,
iObj
);
Cba_FonSetName
(
p
,
iFon
,
NameId
);
Cba_NtkSetMap
(
p
,
NameId
,
iFon
);
Vec_IntPush
(
&
p
->
vOrder
,
iObj
);
}
// create outputs
Prs_NtkForEachPo
(
pNtk
,
NameId
,
i
)
{
iObj
=
Cba_ObjAlloc
(
p
,
CBA_OBJ_PO
,
1
,
0
);
Cba_ObjSetName
(
p
,
iObj
,
NameId
);
Vec_IntPush
(
&
p
->
vOrder
,
iObj
);
}
}
int
Prs_CreateBlifNtk
(
Cba_Ntk_t
*
p
,
Prs_Ntk_t
*
pNtk
)
{
Vec_Int_t
*
vBox
;
int
i
,
k
,
iObj
,
iTerm
,
iFon
,
FormId
,
ActId
;
// map inputs
Cba_NtkCleanMap
(
p
);
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Cba_NtkSetMap
(
p
,
Cba_ObjName
(
p
,
iObj
),
Cba_ObjFon0
(
p
,
iObj
)
);
// create objects
Prs_NtkForEachBox
(
pNtk
,
vBox
,
i
)
{
int
FuncId
=
Prs_BoxNtk
(
pNtk
,
i
);
assert
(
Prs_BoxIONum
(
pNtk
,
i
)
>
0
);
assert
(
Vec_IntSize
(
vBox
)
%
2
==
0
);
if
(
FuncId
==
-
1
)
// latch
{
iObj
=
Cba_ObjAlloc
(
p
,
CBA_BOX_DFFRS
,
4
,
1
);
Cba_NtkSetMap
(
p
,
Vec_IntEntry
(
vBox
,
3
),
Cba_ObjFon0
(
p
,
iObj
)
);
// latch output
Cba_ObjSetFunc
(
p
,
iObj
,
Prs_BoxName
(
pNtk
,
i
)
+
1
);
// init + 1
}
else
if
(
Prs_BoxIsNode
(
pNtk
,
i
)
)
// node
{
iObj
=
Cba_ObjAlloc
(
p
,
CBA_BOX_NODE
,
Prs_BoxIONum
(
pNtk
,
i
)
-
1
,
1
);
Cba_FonSetName
(
p
,
Cba_ObjFon0
(
p
,
iObj
),
Vec_IntEntryLast
(
vBox
)
);
// node output
Cba_NtkSetMap
(
p
,
Vec_IntEntryLast
(
vBox
),
Cba_ObjFon0
(
p
,
iObj
)
);
Cba_ObjSetFunc
(
p
,
iObj
,
FuncId
);
}
else
// box
{
Cba_Ntk_t
*
pBox
=
Cba_ManNtkFind
(
p
->
pDesign
,
Prs_NtkStr
(
pNtk
,
FuncId
)
);
iObj
=
Cba_ObjAlloc
(
p
,
CBA_OBJ_BOX
,
Cba_NtkPiNum
(
pBox
),
Cba_NtkPoNum
(
pBox
)
);
Cba_ObjSetFunc
(
p
,
iObj
,
Cba_NtkId
(
pBox
)
);
// mark PO objects
Cba_NtkCleanMap2
(
p
);
Cba_NtkForEachPo
(
pBox
,
iTerm
,
k
)
Cba_NtkSetMap2
(
p
,
Cba_ObjName
(
pBox
,
iTerm
),
k
+
1
);
// map box fons
Vec_IntForEachEntryDouble
(
vBox
,
FormId
,
ActId
,
k
)
if
(
Cba_NtkGetMap2
(
p
,
FormId
)
)
{
iFon
=
Cba_ObjFon
(
p
,
iObj
,
Cba_NtkGetMap2
(
p
,
FormId
)
-
1
);
Cba_FonSetName
(
p
,
iFon
,
ActId
);
Cba_NtkSetMap
(
p
,
ActId
,
iFon
);
}
}
}
// connect objects
Prs_NtkForEachBox
(
pNtk
,
vBox
,
i
)
{
iObj
=
Cba_NtkPiNum
(
p
)
+
Cba_NtkPoNum
(
p
)
+
i
+
1
;
if
(
Prs_BoxNtk
(
pNtk
,
i
)
==
-
1
)
// latch
{
assert
(
Cba_ObjType
(
p
,
iObj
)
==
CBA_BOX_DFFRS
);
iFon
=
Prs_CreateBlifFindFon
(
p
,
Vec_IntEntry
(
vBox
,
1
)
);
// latch input
if
(
iFon
)
Cba_ObjSetFinFon
(
p
,
iObj
,
0
,
iFon
);
}
else
if
(
Prs_BoxIsNode
(
pNtk
,
i
)
)
// node
{
assert
(
Cba_ObjType
(
p
,
iObj
)
==
CBA_BOX_NODE
);
Vec_IntForEachEntryDouble
(
vBox
,
FormId
,
ActId
,
k
)
{
if
(
k
==
2
*
Cba_ObjFinNum
(
p
,
iObj
)
)
// stop at node output
break
;
iFon
=
Prs_CreateBlifFindFon
(
p
,
ActId
);
if
(
iFon
)
Cba_ObjSetFinFon
(
p
,
iObj
,
k
/
2
,
iFon
);
}
}
else
// box
{
// mark PI objects
Cba_Ntk_t
*
pBox
=
Cba_ObjNtk
(
p
,
iObj
);
assert
(
Cba_NtkPiNum
(
pBox
)
==
Cba_ObjFinNum
(
p
,
iObj
)
);
assert
(
Cba_NtkPoNum
(
pBox
)
==
Cba_ObjFonNum
(
p
,
iObj
)
);
Cba_NtkCleanMap2
(
p
);
Cba_NtkForEachPi
(
pBox
,
iTerm
,
k
)
Cba_NtkSetMap2
(
p
,
Cba_ObjName
(
pBox
,
iTerm
),
k
+
1
);
// connect box fins
Vec_IntForEachEntryDouble
(
vBox
,
FormId
,
ActId
,
k
)
if
(
Cba_NtkGetMap2
(
p
,
FormId
)
)
{
iFon
=
Prs_CreateBlifFindFon
(
p
,
ActId
);
if
(
iFon
)
Cba_ObjSetFinFon
(
p
,
iObj
,
Cba_NtkGetMap2
(
p
,
FormId
)
-
1
,
iFon
);
}
}
}
// connect outputs
Cba_NtkForEachPo
(
p
,
iObj
,
i
)
{
iFon
=
Prs_CreateBlifFindFon
(
p
,
Cba_ObjName
(
p
,
iObj
)
);
if
(
iFon
)
Cba_ObjSetFinFon
(
p
,
iObj
,
0
,
iFon
);
}
return
0
;
}
Cba_Man_t
*
Prs_ManBuildCbaBlif
(
char
*
pFileName
,
Vec_Ptr_t
*
vDes
)
{
Prs_Ntk_t
*
pPrsNtk
;
int
i
,
fError
=
0
;
Prs_Ntk_t
*
pPrsRoot
=
Prs_ManRoot
(
vDes
);
// start the manager
Abc_Nam_t
*
pStrs
=
Abc_NamRef
(
pPrsRoot
->
pStrs
);
Abc_Nam_t
*
pCons
=
Abc_NamRef
(
pPrsRoot
->
pSops
);
Abc_Nam_t
*
pMods
=
Abc_NamStart
(
100
,
24
);
Cba_Man_t
*
p
=
Cba_ManAlloc
(
pFileName
,
Vec_PtrSize
(
vDes
),
pStrs
,
pCons
,
pMods
);
// initialize networks
Vec_PtrForEachEntry
(
Prs_Ntk_t
*
,
vDes
,
pPrsNtk
,
i
)
{
Cba_Ntk_t
*
pNtk
=
Cba_NtkAlloc
(
p
,
Prs_NtkId
(
pPrsNtk
),
Prs_NtkPiNum
(
pPrsNtk
),
Prs_NtkPoNum
(
pPrsNtk
),
Prs_NtkObjNum
(
pPrsNtk
),
100
,
100
);
Prs_CreateBlifPio
(
pNtk
,
pPrsNtk
);
Cba_NtkAdd
(
p
,
pNtk
);
}
// create networks
Vec_PtrForEachEntry
(
Prs_Ntk_t
*
,
vDes
,
pPrsNtk
,
i
)
{
printf
(
"Elaboration module
\"
%s
\"
...
\n
"
,
Prs_NtkName
(
pPrsNtk
),
vDes
);
fError
=
Prs_CreateBlifNtk
(
Cba_ManNtk
(
p
,
i
+
1
),
pPrsNtk
);
if
(
fError
)
break
;
}
if
(
fError
)
printf
(
"Quitting because of errors.
\n
"
);
else
Cba_ManPrepareSeq
(
p
);
return
p
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t
*
Cba_ManReadBlif
(
char
*
pFileName
)
{
Cba_Man_t
*
p
=
NULL
;
Vec_Ptr_t
*
vDes
=
Prs_ManReadBlif
(
pFileName
);
if
(
vDes
&&
Vec_PtrSize
(
vDes
)
)
p
=
Prs_ManBuildCbaBlif
(
pFileName
,
vDes
);
if
(
vDes
)
Prs_ManVecFree
(
vDes
);
return
p
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/base/cba/cbaReadVer.c
View file @
f6a7f695
...
...
@@ -865,6 +865,32 @@ void Prs_ManReadVerilogTest( char * pFileName )
Prs_ManVecFree
(
vPrs
);
}
Cba_Man_t
*
Prs_ManBuildCbaVerilog
(
char
*
pFileName
,
Vec_Ptr_t
*
vDes
)
{
return
NULL
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t
*
Cba_ManReadVerilog
(
char
*
pFileName
)
{
Cba_Man_t
*
p
=
NULL
;
Vec_Ptr_t
*
vDes
=
Prs_ManReadVerilog
(
pFileName
);
if
(
vDes
&&
Vec_PtrSize
(
vDes
)
)
p
=
Prs_ManBuildCbaVerilog
(
pFileName
,
vDes
);
if
(
vDes
)
Prs_ManVecFree
(
vDes
);
return
p
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
...
...
src/base/cba/cbaWriteBlif.c
View file @
f6a7f695
...
...
@@ -72,7 +72,7 @@ static void Prs_ManWriteBlifLines( FILE * pFile, Prs_Ntk_t * p )
fprintf
(
pFile
,
".names"
);
Vec_IntForEachEntryDouble
(
vBox
,
FormId
,
ActId
,
k
)
fprintf
(
pFile
,
" %s"
,
Prs_NtkStr
(
p
,
ActId
)
);
fprintf
(
pFile
,
"
\n
%s"
,
Prs_NtkS
tr
(
p
,
NtkId
)
);
fprintf
(
pFile
,
"
\n
%s"
,
Prs_NtkS
op
(
p
,
NtkId
)
);
}
else
// box
{
...
...
@@ -116,8 +116,6 @@ void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs )
}
#if 0
/**Function*************************************************************
Synopsis [Write elaborated design.]
...
...
@@ -129,76 +127,59 @@ void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs )
SeeAlso []
***********************************************************************/
void Cba_ManWriteBlifGate( FILE * pFile, Cba_Ntk_t * p, Mio_Gate_t * pGate, Vec_Int_t * vFanins, int iObj )
{
int iFanin, i;
Vec_IntForEachEntry( vFanins, iFanin, i )
fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, i), Cba_ObjNameStr(p, iFanin) );
fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_ObjNameStr(p, iObj) );
fprintf( pFile, "\n" );
}
void Cba_ManWriteBlifArray( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins, int iObj )
{
int iFanin, i;
Vec_IntForEachEntry( vFanins, iFanin, i )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iFanin) );
if ( iObj >= 0 )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iObj) );
fprintf( pFile, "\n" );
}
void Cba_ManWriteBlifArray2( FILE * pFile, Cba_Ntk_t * p, int iObj )
{
int iTerm, i;
Cba_Ntk_t * pModel = Cba_BoxNtk( p, iObj );
Cba_NtkForEachPi( pModel, iTerm, i )
fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBi(p, iObj, i)) );
Cba_NtkForEachPo( pModel, iTerm, i )
fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBo(p, iObj, i)) );
fprintf( pFile, "\n" );
}
void
Cba_ManWriteBlifLines
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
int
i, k, iTerm
;
Cba_NtkForEachBox( p, i )
int
k
,
iObj
,
iFin
,
iFon
;
Cba_NtkForEachBox
(
p
,
i
Obj
)
{
if ( Cba_ObjIsBoxUser(p, i) )
if
(
Cba_ObjIsBoxUser
(
p
,
i
Obj
)
)
{
Cba_Ntk_t
*
pNtk
=
Cba_ObjNtk
(
p
,
iObj
);
fprintf
(
pFile
,
".subckt"
);
fprintf( pFile, " %s", Cba_NtkName(Cba_BoxNtk(p, i)) );
Cba_ManWriteBlifArray2( pFile, p, i );
fprintf
(
pFile
,
" %s"
,
Cba_NtkName
(
pNtk
)
);
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pNtk
,
Cba_NtkPi
(
pNtk
,
k
)),
Cba_FonNameStr
(
p
,
iFon
)
);
Cba_ObjForEachFon
(
p
,
iObj
,
iFon
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pNtk
,
Cba_NtkPo
(
pNtk
,
k
)),
Cba_FonNameStr
(
p
,
iFon
)
);
fprintf
(
pFile
,
"
\n
"
);
}
else if ( Cba_ObjIsGate(p, i) )
else
if
(
Cba_ObjIsGate
(
p
,
i
Obj
)
)
{
char * pGateName = Abc_NamStr(p->pDesign->pMods, Cba_
BoxNtkId(p, i
));
char
*
pGateName
=
Abc_NamStr
(
p
->
pDesign
->
pMods
,
Cba_
ObjNtkId
(
p
,
iObj
));
Mio_Library_t
*
pLib
=
(
Mio_Library_t
*
)
Abc_FrameReadLibGen
();
Mio_Gate_t
*
pGate
=
Mio_LibraryReadGateByName
(
pLib
,
pGateName
,
NULL
);
fprintf
(
pFile
,
".gate %s"
,
pGateName
);
Cba_
BoxForEachBi( p, i, iTerm
, k )
fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, k), Cba_
ObjNameStr(p, iTerm
) );
Cba_
BoxForEachBo( p, i, iTerm
, k )
fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_
ObjNameStr(p, iTerm
) );
Cba_
ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Mio_GateReadPinName
(
pGate
,
k
),
Cba_
FonNameStr
(
p
,
iFon
)
);
Cba_
ObjForEachFon
(
p
,
iObj
,
iFon
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Mio_GateReadOutName
(
pGate
),
Cba_
FonNameStr
(
p
,
iFon
)
);
fprintf
(
pFile
,
"
\n
"
);
}
else
{
fprintf
(
pFile
,
".names"
);
Cba_BoxForEachBi( p, i, iTerm, k )
fprintf( pFile, " %s", Cba_ObjNameStr(p, Cba_ObjFanin(p, iTerm)) );
Cba_BoxForEachBo( p, i, iTerm, k )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iTerm) );
fprintf( pFile, "\n%s", Ptr_TypeToSop(Cba_ObjType(p, i)) );
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
k
)
fprintf
(
pFile
,
" %s"
,
Cba_FonNameStr
(
p
,
iFon
)
);
fprintf
(
pFile
,
" %s"
,
Cba_FonNameStr
(
p
,
Cba_ObjFon0
(
p
,
iObj
))
);
fprintf
(
pFile
,
"
\n
%s"
,
Cba_NtkSop
(
p
,
Cba_ObjFunc
(
p
,
iObj
))
);
}
}
}
void
Cba_ManWriteBlifArray
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vObjs
)
{
int
iObj
,
i
;
Vec_IntForEachEntry
(
vObjs
,
iObj
,
i
)
fprintf
(
pFile
,
" %s"
,
Cba_ObjNameStr
(
p
,
iObj
)
);
fprintf
(
pFile
,
"
\n
"
);
}
void
Cba_ManWriteBlifNtk
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
assert( Vec_IntSize(&p->vFanin) == Cba_NtkObjNum(p) );
// write header
fprintf
(
pFile
,
".model %s
\n
"
,
Cba_NtkName
(
p
)
);
fprintf
(
pFile
,
".inputs"
);
Cba_ManWriteBlifArray( pFile, p, &p->vInputs
, -1
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
&
p
->
vInputs
);
fprintf
(
pFile
,
".outputs"
);
Cba_ManWriteBlifArray( pFile, p, &p->vOutputs
, -1
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
&
p
->
vOutputs
);
// write objects
Cba_ManWriteBlifLines
(
pFile
,
p
);
fprintf
(
pFile
,
".end
\n\n
"
);
...
...
@@ -221,13 +202,12 @@ void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p )
return
;
}
fprintf
(
pFile
,
"# Design
\"
%s
\"
written via CBA package in ABC on %s
\n\n
"
,
Cba_ManName
(
p
),
Extra_TimeStamp
()
);
Cba_ManAssignInternWordNames( p );
//
Cba_ManAssignInternWordNames( p );
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManWriteBlifNtk
(
pFile
,
pNtk
);
fclose
(
pFile
);
}
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
...
...
src/base/cba/cbaWriteVer.c
View file @
f6a7f695
...
...
@@ -206,7 +206,7 @@ void Cba_ManCreatePrimMap( char ** pMap )
pMap
[
CBA_BOX_SHARP
]
=
"&"
;
pMap
[
CBA_BOX_SHARPL
]
=
"&"
;
pMap
[
CBA_BOX_MUX
]
=
"?"
;
pMap
[
CBA_BOX_MAJ
]
=
"maj"
;
pMap
[
CBA_BOX_MAJ
]
=
NULL
;
pMap
[
CBA_BOX_RAND
]
=
"&"
;
pMap
[
CBA_BOX_RNAND
]
=
"~&"
;
pMap
[
CBA_BOX_ROR
]
=
"|"
;
...
...
@@ -215,27 +215,27 @@ void Cba_ManCreatePrimMap( char ** pMap )
pMap
[
CBA_BOX_RXNOR
]
=
"~^"
;
pMap
[
CBA_BOX_LNOT
]
=
"!"
;
pMap
[
CBA_BOX_LAND
]
=
"&&"
;
pMap
[
CBA_BOX_LNAND
]
=
"!&&"
;
pMap
[
CBA_BOX_LNAND
]
=
NULL
;
pMap
[
CBA_BOX_LOR
]
=
"||"
;
pMap
[
CBA_BOX_LNOR
]
=
"!||"
;
pMap
[
CBA_BOX_LNOR
]
=
NULL
;
pMap
[
CBA_BOX_LXOR
]
=
"^^"
;
pMap
[
CBA_BOX_LXNOR
]
=
"!^^"
;
pMap
[
CBA_BOX_NMUX
]
=
"??"
;
pMap
[
CBA_BOX_SEL
]
=
"?|"
;
pMap
[
CBA_BOX_PSEL
]
=
"?%"
;
pMap
[
CBA_BOX_ENC
]
=
"enc"
;
pMap
[
CBA_BOX_PENC
]
=
"penc"
;
pMap
[
CBA_BOX_DEC
]
=
"dec"
;
pMap
[
CBA_BOX_EDEC
]
=
"edec"
;
pMap
[
CBA_BOX_LXNOR
]
=
NULL
;
pMap
[
CBA_BOX_NMUX
]
=
NULL
;
pMap
[
CBA_BOX_SEL
]
=
NULL
;
pMap
[
CBA_BOX_PSEL
]
=
NULL
;
pMap
[
CBA_BOX_ENC
]
=
NULL
;
pMap
[
CBA_BOX_PENC
]
=
NULL
;
pMap
[
CBA_BOX_DEC
]
=
NULL
;
pMap
[
CBA_BOX_EDEC
]
=
NULL
;
pMap
[
CBA_BOX_ADD
]
=
"+"
;
pMap
[
CBA_BOX_SUB
]
=
"-"
;
pMap
[
CBA_BOX_MUL
]
=
"*"
;
pMap
[
CBA_BOX_DIV
]
=
"/"
;
pMap
[
CBA_BOX_MOD
]
=
"mod"
;
pMap
[
CBA_BOX_MOD
]
=
NULL
;
pMap
[
CBA_BOX_REM
]
=
"%%"
;
pMap
[
CBA_BOX_POW
]
=
"**"
;
pMap
[
CBA_BOX_MIN
]
=
"-"
;
pMap
[
CBA_BOX_ABS
]
=
"abs"
;
pMap
[
CBA_BOX_ABS
]
=
NULL
;
pMap
[
CBA_BOX_LTHAN
]
=
"<"
;
pMap
[
CBA_BOX_LETHAN
]
=
"<="
;
pMap
[
CBA_BOX_METHAN
]
=
">="
;
...
...
@@ -244,14 +244,56 @@ void Cba_ManCreatePrimMap( char ** pMap )
pMap
[
CBA_BOX_NEQU
]
=
"!="
;
pMap
[
CBA_BOX_SHIL
]
=
"<<"
;
pMap
[
CBA_BOX_SHIR
]
=
">>"
;
pMap
[
CBA_BOX_ROTL
]
=
"rotL"
;
pMap
[
CBA_BOX_ROTR
]
=
"rotR"
;
pMap
[
CBA_BOX_ROTL
]
=
NULL
;
pMap
[
CBA_BOX_ROTR
]
=
NULL
;
}
// considers word-level signal and returns bit-level signal
int
Cba_ObjFindOne
(
Cba_Ntk_t
*
p
,
int
iFon
)
{
int
Range
=
Cba_FonRange
(
p
,
iFon
);
if
(
Range
==
1
)
{
if
(
Cba_FonIsConst
(
iFon
)
)
return
Cba_FonConst
(
iFon
)
==
1
?
0
:
-
1
;
return
iFon
;
}
assert
(
Range
>
1
);
if
(
Cba_FonIsConst
(
iFon
)
)
{
int
i
;
char
Digit
=
0
;
char
*
s
=
Cba_NtkConst
(
p
,
Cba_FonConst
(
iFon
)
);
while
(
*
s
!=
'b'
)
s
++
;
assert
(
*
s
==
'b'
);
for
(
i
=
1
;
i
<=
Range
;
i
++
)
{
if
(
Digit
==
0
)
Digit
=
s
[
i
];
else
if
(
Digit
!=
s
[
i
]
)
return
-
1
;
}
return
s
[
1
]
==
'0'
?
0
:
-
1
;
}
else
{
int
iObj
=
Cba_FonObj
(
p
,
iFon
);
int
i
,
iFin
,
iFon
,
OneFon
=
ABC_INFINITY
;
if
(
Cba_ObjType
(
p
,
iObj
)
!=
CBA_BOX_CATIN
)
return
-
1
;
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
i
)
if
(
OneFon
==
ABC_INFINITY
)
OneFon
=
iFon
;
else
if
(
OneFon
!=
iFon
)
return
-
1
;
assert
(
Cba_FonIsReal
(
OneFon
)
);
Range
=
Cba_FonRange
(
p
,
OneFon
);
return
Range
==
1
?
OneFon
:
-
1
;
}
}
void
Cba_ManWriteFonRange
(
Cba_Ntk_t
*
p
,
int
iFon
)
{
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
if
(
Cba_FonIsConst
(
iFon
)
||
Cba_FonRange
(
p
,
iFon
)
==
1
)
if
(
Cba_FonIsConst
(
iFon
)
||
(
Cba_FonRange
(
p
,
iFon
)
==
1
&&
Cba_FonRight
(
p
,
iFon
)
==
0
)
)
return
;
Vec_StrPush
(
vStr
,
'['
);
Vec_StrPrintNum
(
vStr
,
Cba_FonLeft
(
p
,
iFon
)
);
...
...
@@ -260,30 +302,59 @@ void Cba_ManWriteFonRange( Cba_Ntk_t * p, int iFon )
Vec_StrPush
(
vStr
,
']'
);
Vec_StrPush
(
vStr
,
' '
);
}
void
Cba_ManWriteFonName
(
Cba_Ntk_t
*
p
,
int
iFon
,
int
fInlineConcat
)
void
Cba_ManWriteFonName
(
Cba_Ntk_t
*
p
,
int
iFon
,
int
fInlineConcat
,
int
fInput
)
{
extern
void
Cba_ManWriteC
oncat
(
Cba_Ntk_t
*
p
,
int
iObj
);
extern
void
Cba_ManWriteC
atIn
(
Cba_Ntk_t
*
p
,
int
iObj
);
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
if
(
!
iFon
||
(
!
Cba_FonIsConst
(
iFon
)
&&
!
Cba_FonName
(
p
,
iFon
))
)
{
Vec_StrPrintStr
(
vStr
,
"Open_"
);
Vec_StrPrintNum
(
vStr
,
Cba_NtkMan
(
p
)
->
nOpens
++
);
return
;
}
if
(
fInlineConcat
&&
!
Cba_FonIsConst
(
iFon
)
&&
Cba_ObjIsCatIn
(
p
,
Cba_FonObj
(
p
,
iFon
))
)
Cba_ManWriteCatIn
(
p
,
Cba_FonObj
(
p
,
iFon
)
);
else
{
int
Range
=
fInput
?
Cba_FonRange
(
p
,
iFon
)
:
0
;
if
(
fInput
&&
Range
>
1
)
Vec_StrPush
(
vStr
,
'{'
);
if
(
Cba_FonIsConst
(
iFon
)
)
Vec_StrPrintStr
(
vStr
,
Cba_NtkConst
(
p
,
Cba_FonConst
(
iFon
))
);
else
if
(
fInlineConcat
&&
Cba_ObjIsConcat
(
p
,
Cba_FonObj
(
p
,
iFon
))
)
Cba_ManWriteConcat
(
p
,
Cba_FonObj
(
p
,
iFon
)
);
else
Vec_StrPrintStr
(
vStr
,
Cba_FonNameStr
(
p
,
iFon
)
);
if
(
fInput
&&
Range
>
1
)
Vec_StrPush
(
vStr
,
'}'
);
}
}
void
Cba_ManWriteC
oncat
(
Cba_Ntk_t
*
p
,
int
iObj
)
void
Cba_ManWriteC
atIn
(
Cba_Ntk_t
*
p
,
int
iObj
)
{
int
i
,
iFin
,
iFon
;
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
assert
(
Cba_ObjIsC
oncat
(
p
,
iObj
)
);
assert
(
Cba_ObjIsC
atIn
(
p
,
iObj
)
);
Vec_StrPush
(
vStr
,
'{'
);
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
i
)
{
Vec_StrPrintStr
(
vStr
,
i
?
", "
:
""
);
Cba_ManWriteFonName
(
p
,
iFon
,
1
);
Cba_ManWriteFonName
(
p
,
iFon
,
1
,
0
);
}
Vec_StrPush
(
vStr
,
'}'
);
}
void
Cba_ManWriteCatOut
(
Cba_Ntk_t
*
p
,
int
iObj
)
{
int
i
,
iFon
;
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
assert
(
Cba_ObjIsCatOut
(
p
,
iObj
)
);
if
(
Cba_ObjFonNum
(
p
,
iObj
)
>
1
)
Vec_StrPush
(
vStr
,
'{'
);
Cba_ObjForEachFon
(
p
,
iObj
,
iFon
,
i
)
{
Vec_StrPrintStr
(
vStr
,
i
?
", "
:
""
);
Cba_ManWriteFonName
(
p
,
iFon
,
0
,
0
);
}
if
(
Cba_ObjFonNum
(
p
,
iObj
)
>
1
)
Vec_StrPush
(
vStr
,
'}'
);
}
int
Cba_ManWriteLineFile
(
Cba_Ntk_t
*
p
,
int
iObj
,
int
FileAttr
,
int
LineAttr
)
{
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
...
...
@@ -303,14 +374,14 @@ int Cba_ManWriteLineFile( Cba_Ntk_t * p, int iObj, int FileAttr, int LineAttr )
void
Cba_ManWriteVerilogNtk
(
Cba_Ntk_t
*
p
,
int
fInlineConcat
)
{
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
int
i
,
iObj
,
iFin
,
iFon
,
StartPos
,
Status
;
int
i
,
k
,
iObj
,
iFin
,
iFon
,
StartPos
,
Status
;
int
FileAttr
=
Cba_NtkStrId
(
p
,
"file"
);
int
LineAttr
=
Cba_NtkStrId
(
p
,
"line"
);
int
fUseNewLine
=
(
int
)(
Cba_NtkPioNum
(
p
)
>
5
);
// mark PO fons
Vec_Bit_t
*
vPoFons
=
Vec_BitStart
(
Cba_NtkFonNum
(
p
)
+
1
);
Cba_NtkForEachPoDriverFon
(
p
,
iObj
,
iFon
,
i
)
if
(
Cba_FonIsReal
(
iFon
)
)
if
(
Cba_FonIsReal
(
iFon
)
&&
Cba_FonName
(
p
,
iFon
)
==
Cba_ObjName
(
p
,
iObj
)
)
Vec_BitWriteEntry
(
vPoFons
,
iFon
,
1
);
// write header
Vec_StrPrintStr
(
vStr
,
"module "
);
...
...
@@ -333,11 +404,14 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
// write inputs/outputs
Cba_NtkForEachPioOrder
(
p
,
iObj
,
i
)
{
int
Offset
=
Vec_StrSize
(
vStr
);
Vec_StrPrintStr
(
vStr
,
" "
);
Vec_StrPrintStr
(
vStr
,
Cba_ObjIsPi
(
p
,
iObj
)
?
"input "
:
"output "
);
Cba_ManWriteFonRange
(
p
,
Cba_ObjIsPi
(
p
,
iObj
)
?
Cba_ObjFon0
(
p
,
iObj
)
:
Cba_ObjFinFon
(
p
,
iObj
,
0
)
);
Vec_StrPrintStr
(
vStr
,
Cba_ObjNameStr
(
p
,
iObj
)
);
Vec_StrPush
(
vStr
,
';'
);
for
(
k
=
Vec_StrSize
(
vStr
);
k
<
Offset
+
40
;
k
++
)
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteLineFile
(
p
,
iObj
,
FileAttr
,
LineAttr
);
Vec_StrPush
(
vStr
,
'\n'
);
}
...
...
@@ -345,9 +419,10 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
// write objects
Cba_NtkForEachBox
(
p
,
iObj
)
{
int
Type
=
Cba_ObjType
(
p
,
iObj
);
if
(
Cba_ObjIsSlice
(
p
,
iObj
)
)
continue
;
if
(
fInlineConcat
&&
Cba_ObjIsC
oncat
(
p
,
iObj
)
)
if
(
fInlineConcat
&&
Cba_ObjIsC
atIn
(
p
,
iObj
)
)
continue
;
if
(
Cba_ObjIsBoxUser
(
p
,
iObj
)
)
{
...
...
@@ -355,9 +430,11 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
// write output wire declarations
Cba_ObjForEachFon
(
p
,
iObj
,
iFon
,
i
)
{
if
(
Vec_BitEntry
(
vPoFons
,
iFon
)
)
continue
;
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
iFon
);
Cba_ManWriteFonName
(
p
,
iFon
,
0
);
Cba_ManWriteFonName
(
p
,
iFon
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
// write box
...
...
@@ -375,7 +452,7 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
Vec_StrPush
(
vStr
,
'.'
);
Vec_StrPrintStr
(
vStr
,
Cba_ObjNameStr
(
pNtk
,
Cba_NtkPi
(
pNtk
,
i
))
);
Vec_StrPush
(
vStr
,
'('
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
,
1
);
Vec_StrPush
(
vStr
,
')'
);
}
// write output binding
...
...
@@ -385,63 +462,295 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
Vec_StrPush
(
vStr
,
'.'
);
Vec_StrPrintStr
(
vStr
,
Cba_ObjNameStr
(
pNtk
,
Cba_NtkPo
(
pNtk
,
i
))
);
Vec_StrPush
(
vStr
,
'('
);
Cba_ManWriteFonName
(
p
,
iFon
,
0
);
Cba_ManWriteFonName
(
p
,
iFon
,
0
,
1
);
Vec_StrPush
(
vStr
,
')'
);
}
Vec_StrPrintStr
(
vStr
,
");"
);
}
else
else
if
(
Type
==
CBA_BOX_CATOUT
)
{
int
Type
=
Cba_ObjType
(
p
,
iObj
);
if
(
Vec_BitEntry
(
vPoFons
,
Cba_ObjFon0
(
p
,
iObj
))
)
Vec_StrPrintStr
(
vStr
,
" assign "
);
else
// write declarations
Cba_ObjForEachFon
(
p
,
iObj
,
iFon
,
i
)
{
if
(
!
Cba_FonName
(
p
,
iFon
)
)
continue
;
if
(
Vec_BitEntry
(
vPoFons
,
iFon
)
)
continue
;
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
Cba_ObjFon0
(
p
,
iObj
)
);
Cba_ManWriteFonRange
(
p
,
iFon
);
Cba_ManWriteFonName
(
p
,
iFon
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
Cba_ManWriteFonName
(
p
,
Cba_ObjFon0
(
p
,
iObj
),
0
);
// write output concatenation
Vec_StrPrintStr
(
vStr
,
" assign "
);
Cba_ManWriteCatOut
(
p
,
iObj
);
Vec_StrPrintStr
(
vStr
,
" = "
);
if
(
Cba_ObjIsConcat
(
p
,
iObj
)
)
Cba_ManWriteConcat
(
p
,
iObj
);
else
if
(
Type
==
CBA_BOX_MUX
||
Type
==
CBA_BOX_NMUX
)
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
0
,
0
);
Vec_StrPush
(
vStr
,
';'
);
}
else
if
(
Type
==
CBA_BOX_NMUX
||
Type
==
CBA_BOX_SEL
)
{
int
fUseSel
=
Type
==
CBA_BOX_SEL
;
int
nBits
=
fUseSel
?
Cba_ObjFinNum
(
p
,
iObj
)
-
1
:
Abc_Base2Log
(
Cba_ObjFinNum
(
p
,
iObj
)
-
1
);
int
iFonIn
=
Cba_ObjFinFon
(
p
,
iObj
,
0
);
int
iFonOut
=
Cba_ObjFon0
(
p
,
iObj
);
// function [15:0] res;
Vec_StrPrintStr
(
vStr
,
" function "
);
Cba_ManWriteFonRange
(
p
,
iFonOut
);
Vec_StrPrintStr
(
vStr
,
"_func_"
);
Cba_ManWriteFonName
(
p
,
iFonOut
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
// input [1:0] s;
Vec_StrPrintStr
(
vStr
,
" input "
);
Cba_ManWriteFonRange
(
p
,
iFonIn
);
Vec_StrPrintStr
(
vStr
,
"s;
\n
"
);
// input [15:0] d0, d1, d2, d3;
Vec_StrPrintStr
(
vStr
,
" input "
);
Cba_ManWriteFonRange
(
p
,
iFonOut
);
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
i
)
{
char
*
pSymb
=
Type
==
CBA_BOX_MUX
?
" ? "
:
" ?? "
;
if
(
i
==
0
)
continue
;
Vec_StrPrintStr
(
vStr
,
i
>
1
?
", "
:
""
);
Vec_StrPrintStr
(
vStr
,
"d"
);
Vec_StrPrintNum
(
vStr
,
i
-
1
);
}
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
// casez (s)
Vec_StrPrintStr
(
vStr
,
" casez(s)"
);
if
(
fUseSel
)
Vec_StrPrintStr
(
vStr
,
" // synopsys full_case parallel_case"
);
Vec_StrPrintStr
(
vStr
,
"
\n
"
);
// 2'b00: res = b[15:0];
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
i
)
{
Vec_StrPrintStr
(
vStr
,
i
?
(
i
==
1
?
pSymb
:
" : "
)
:
""
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
);
if
(
i
==
0
)
continue
;
Vec_StrPrintStr
(
vStr
,
" "
);
Vec_StrPrintNum
(
vStr
,
nBits
);
Vec_StrPrintStr
(
vStr
,
"
\'
b"
);
if
(
fUseSel
)
{
Vec_StrFillExtra
(
vStr
,
Vec_StrSize
(
vStr
)
+
nBits
,
'?'
);
Vec_StrWriteEntry
(
vStr
,
Vec_StrSize
(
vStr
)
-
i
,
'1'
);
}
else
{
for
(
k
=
nBits
-
1
;
k
>=
0
;
k
--
)
Vec_StrPrintNum
(
vStr
,
((
i
-
1
)
>>
k
)
&
1
);
}
else
if
(
Type
==
CBA_BOX_SEL
||
Type
==
CBA_BOX_PSEL
)
Vec_StrPrintStr
(
vStr
,
": _func_"
);
Cba_ManWriteFonName
(
p
,
iFonOut
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
" = "
);
Vec_StrPrintStr
(
vStr
,
"d"
);
Vec_StrPrintNum
(
vStr
,
i
-
1
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
Vec_StrPrintStr
(
vStr
,
" endcase
\n
"
);
Vec_StrPrintStr
(
vStr
,
" endfunction
\n
"
);
// assign z = res(a, b, s);
if
(
Vec_BitEntry
(
vPoFons
,
iFonOut
)
)
Vec_StrPrintStr
(
vStr
,
" assign "
);
else
{
char
*
pSymb
=
Type
==
CBA_BOX_SEL
?
" ?| "
:
" ?% "
;
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
iFonOut
);
}
Cba_ManWriteFonName
(
p
,
iFonOut
,
fInlineConcat
,
0
);
Vec_StrPrintStr
(
vStr
,
" = _func_"
);
Cba_ManWriteFonName
(
p
,
iFonOut
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
" ( "
);
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
i
)
{
Vec_StrPrintStr
(
vStr
,
i
?
(
i
==
1
?
pSymb
:
" : "
)
:
""
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
);
Vec_StrPrintStr
(
vStr
,
i
?
", "
:
""
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
,
0
);
}
Vec_StrPrintStr
(
vStr
,
" );"
);
}
else
if
(
Cba_TypeIsUnary
(
Type
)
)
else
if
(
Type
==
CBA_BOX_DFFRS
||
Type
==
CBA_BOX_LATCHRS
)
{
Vec_StrPrintStr
(
vStr
,
Cba_NtkTypeName
(
p
,
Type
)
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
fInlineConcat
);
int
fUseFlop
=
Type
==
CBA_BOX_DFFRS
;
int
iFonQ
=
Cba_ObjFon0
(
p
,
iObj
);
int
iFonD
=
Cba_ObjFinFon
(
p
,
iObj
,
0
);
int
iFonC
=
Cba_ObjFinFon
(
p
,
iObj
,
3
);
int
iFonSet
=
Cba_ObjFindOne
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
1
)
);
int
iFonRst
=
Cba_ObjFindOne
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
2
)
);
int
Range
=
Cba_FonRange
(
p
,
iFonQ
);
if
(
iFonSet
<
0
||
iFonRst
<
0
)
{
printf
(
"Cba_ManWriteVerilog(): In module
\"
%s
\"
, cannot write object
\"
%s
\"
.
\n
"
,
Cba_NtkName
(
p
),
Cba_ObjNameStr
(
p
,
iObj
)
);
continue
;
}
assert
(
iFonSet
>=
0
&&
iFonRst
>=
0
);
// reg [3:0] Q;
Vec_StrPrintStr
(
vStr
,
" reg "
);
Cba_ManWriteFonRange
(
p
,
iFonQ
);
Cba_ManWriteFonName
(
p
,
iFonQ
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
// always @(posedge C or posedge PRE)
Vec_StrPrintStr
(
vStr
,
" always @("
);
if
(
fUseFlop
)
Vec_StrPrintStr
(
vStr
,
"posedge "
);
Cba_ManWriteFonName
(
p
,
iFonC
,
0
,
0
);
if
(
!
fUseFlop
)
{
Vec_StrPrintStr
(
vStr
,
" or "
);
Cba_ManWriteFonName
(
p
,
iFonD
,
0
,
0
);
}
if
(
iFonSet
>
0
)
{
Vec_StrPrintStr
(
vStr
,
" or "
);
if
(
fUseFlop
)
Vec_StrPrintStr
(
vStr
,
"posedge "
);
Cba_ManWriteFonName
(
p
,
iFonSet
,
0
,
0
);
}
if
(
iFonRst
>
0
)
{
Vec_StrPrintStr
(
vStr
,
" or "
);
if
(
fUseFlop
)
Vec_StrPrintStr
(
vStr
,
"posedge "
);
Cba_ManWriteFonName
(
p
,
iFonRst
,
0
,
0
);
}
Vec_StrPrintStr
(
vStr
,
")
\n
"
);
// if (Set) Q <= 4'b1111;
if
(
iFonSet
)
{
Vec_StrPrintStr
(
vStr
,
" if ("
);
Cba_ManWriteFonName
(
p
,
iFonSet
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
") "
);
Cba_ManWriteFonName
(
p
,
iFonQ
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
fUseFlop
?
" <= "
:
" = "
);
Vec_StrPrintNum
(
vStr
,
Range
);
Vec_StrPrintStr
(
vStr
,
"
\'
b"
);
Vec_StrFillExtra
(
vStr
,
Vec_StrSize
(
vStr
)
+
Range
,
'1'
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
if
(
iFonRst
)
{
Vec_StrPrintStr
(
vStr
,
iFonSet
?
" else if ("
:
" if ("
);
Cba_ManWriteFonName
(
p
,
iFonRst
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
") "
);
Cba_ManWriteFonName
(
p
,
iFonQ
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
fUseFlop
?
" <= "
:
" = "
);
Vec_StrPrintNum
(
vStr
,
Range
);
Vec_StrPrintStr
(
vStr
,
"
\'
b"
);
Vec_StrFillExtra
(
vStr
,
Vec_StrSize
(
vStr
)
+
Range
,
'0'
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
Vec_StrPrintStr
(
vStr
,
(
iFonSet
||
iFonRst
)
?
" else "
:
" "
);
if
(
!
fUseFlop
)
{
Vec_StrPrintStr
(
vStr
,
" if ("
);
Cba_ManWriteFonName
(
p
,
iFonC
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
") "
);
}
Cba_ManWriteFonName
(
p
,
iFonQ
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
fUseFlop
?
" <= "
:
" = "
);
Cba_ManWriteFonName
(
p
,
iFonD
,
fInlineConcat
,
0
);
Vec_StrPrintStr
(
vStr
,
";"
);
}
else
if
(
Type
==
CBA_BOX_ADD
)
{
int
iFon0
=
Cba_ObjFon0
(
p
,
iObj
);
int
iFon1
=
Cba_ObjFon
(
p
,
iObj
,
1
);
// write outputs
if
(
Cba_FonName
(
p
,
iFon1
)
)
{
if
(
!
Vec_BitEntry
(
vPoFons
,
iFon0
)
)
{
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
iFon0
);
Cba_ManWriteFonName
(
p
,
iFon0
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
if
(
!
Vec_BitEntry
(
vPoFons
,
iFon1
)
)
{
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
iFon1
);
Cba_ManWriteFonName
(
p
,
iFon1
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
";
\n
"
);
}
Vec_StrPrintStr
(
vStr
,
" assign {"
);
Cba_ManWriteFonName
(
p
,
iFon1
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
", "
);
Cba_ManWriteFonName
(
p
,
iFon0
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
"} = "
);
}
else
{
if
(
Vec_BitEntry
(
vPoFons
,
iFon0
)
)
Vec_StrPrintStr
(
vStr
,
" assign "
);
else
{
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
iFon0
);
}
Cba_ManWriteFonName
(
p
,
iFon0
,
0
,
0
);
Vec_StrPrintStr
(
vStr
,
" = "
);
}
else
// binary operation
// write carry-in
if
(
Cba_ObjFinFon
(
p
,
iObj
,
0
)
!=
Cba_FonFromConst
(
1
)
)
{
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
fInlineConcat
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
fInlineConcat
,
0
);
Vec_StrPush
(
vStr
,
' '
);
Vec_StrPrintStr
(
vStr
,
Cba_NtkTypeName
(
p
,
Type
)
);
Vec_StrPrintStr
(
vStr
,
"+"
);
}
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
1
),
fInlineConcat
,
0
);
Vec_StrPush
(
vStr
,
' '
);
Vec_StrPrintStr
(
vStr
,
"+"
);
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
2
),
fInlineConcat
,
0
);
Vec_StrPush
(
vStr
,
';'
);
}
else
{
if
(
Vec_BitEntry
(
vPoFons
,
Cba_ObjFon0
(
p
,
iObj
))
)
Vec_StrPrintStr
(
vStr
,
" assign "
);
else
{
Vec_StrPrintStr
(
vStr
,
" wire "
);
Cba_ManWriteFonRange
(
p
,
Cba_ObjFon0
(
p
,
iObj
)
);
}
Cba_ManWriteFonName
(
p
,
Cba_ObjFon0
(
p
,
iObj
),
0
,
0
);
Vec_StrPrintStr
(
vStr
,
" = "
);
if
(
Cba_ObjIsCatIn
(
p
,
iObj
)
)
Cba_ManWriteCatIn
(
p
,
iObj
);
else
if
(
Type
==
CBA_BOX_MUX
)
{
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
fInlineConcat
,
0
);
Vec_StrPrintStr
(
vStr
,
" ? "
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
1
),
fInlineConcat
,
0
);
Vec_StrPrintStr
(
vStr
,
" : "
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
2
),
fInlineConcat
,
0
);
}
else
if
(
Type
==
CBA_BOX_LTHAN
)
{
int
fLessThan
=
(
Cba_ObjFinFon
(
p
,
iObj
,
0
)
==
Cba_FonFromConst
(
1
));
// const0
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
1
),
fInlineConcat
,
0
);
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
1
),
fInlineConcat
);
if
(
Type
==
CBA_BOX_ADD
)
Vec_StrPrintStr
(
vStr
,
fLessThan
?
"<"
:
"<="
);
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
2
),
fInlineConcat
,
0
);
}
else
if
(
Cba_TypeIsUnary
(
Type
)
)
{
Vec_StrPrintStr
(
vStr
,
Cba_NtkTypeName
(
p
,
Type
)
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
fInlineConcat
,
0
);
}
else
if
(
Cba_NtkTypeName
(
p
,
Type
)
)
// binary operation
{
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
0
),
fInlineConcat
,
0
);
Vec_StrPush
(
vStr
,
' '
);
Vec_StrPrintStr
(
vStr
,
Cba_NtkTypeName
(
p
,
Type
)
);
Vec_StrPush
(
vStr
,
' '
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
2
),
fInlineConcat
);
Cba_ManWriteFonName
(
p
,
Cba_ObjFinFon
(
p
,
iObj
,
1
),
fInlineConcat
,
0
);
}
else
// unknown
{
Vec_StrPrintStr
(
vStr
,
"<unknown operator>"
);
printf
(
"Cba_ManWriteVerilog(): In module
\"
%s
\"
, cannot write object
\"
%s
\"
.
\n
"
,
Cba_NtkName
(
p
),
Cba_ObjNameStr
(
p
,
iObj
)
);
}
Vec_StrPush
(
vStr
,
';'
);
}
...
...
@@ -465,7 +774,7 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
Vec_StrPrintStr
(
vStr
,
" assign "
);
Vec_StrPrintStr
(
vStr
,
Cba_ObjNameStr
(
p
,
iObj
)
);
Vec_StrPrintStr
(
vStr
,
" = "
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
);
Cba_ManWriteFonName
(
p
,
iFon
,
fInlineConcat
,
0
);
Vec_StrPush
(
vStr
,
';'
);
Vec_StrPush
(
vStr
,
'\n'
);
}
...
...
@@ -484,6 +793,7 @@ void Cba_ManWriteVerilog( char * pFileName, Cba_Man_t * p, int fInlineConcat )
}
Cba_ManCreatePrimMap
(
p
->
pTypeNames
);
// derive the stream
p
->
nOpens
=
1
;
Vec_StrClear
(
&
p
->
vOut
);
Vec_StrClear
(
&
p
->
vOut2
);
Vec_StrPrintStr
(
&
p
->
vOut
,
"// Design
\"
"
);
...
...
src/base/main/mainInt.h
View file @
f6a7f695
...
...
@@ -127,6 +127,7 @@ struct Abc_Frame_t_
void
*
pAbc85Best
;
void
*
pAbc85Delay
;
void
*
pAbcWlc
;
void
*
pAbcBac
;
void
*
pAbcCba
;
void
*
pAbcPla
;
};
...
...
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