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
17610c03
Commit
17610c03
authored
Jan 17, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Organizing commands for barbuf-aware flow.
parent
42cc5657
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
190 additions
and
135 deletions
+190
-135
src/aig/gia/giaFx.c
+16
-12
src/base/cba/cba.h
+19
-30
src/base/cba/cbaBlast.c
+0
-0
src/base/cba/cbaBuild.c
+11
-11
src/base/cba/cbaCom.c
+2
-2
src/base/cba/cbaNtk.c
+8
-11
src/base/cba/cbaPrs.h
+8
-10
src/base/cba/cbaReadBlif.c
+3
-3
src/base/cba/cbaReadVer.c
+59
-6
src/base/cba/cbaSimple.c
+6
-9
src/base/cba/cbaWriteBlif.c
+30
-4
src/base/cba/cbaWriteVer.c
+28
-37
No files found.
src/aig/gia/giaFx.c
View file @
17610c03
...
...
@@ -96,6 +96,20 @@ int Gia_ManSopToAig( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves )
iSum
=
Abc_LitNot
(
iSum
);
return
iSum
;
}
int
Gia_ManFactorGraph
(
Gia_Man_t
*
p
,
Dec_Graph_t
*
pFForm
,
Vec_Int_t
*
vLeaves
)
{
Dec_Node_t
*
pFFNode
;
int
i
,
Lit
;
// assign fanins
Dec_GraphForEachLeaf
(
pFForm
,
pFFNode
,
i
)
{
assert
(
Vec_IntEntry
(
vLeaves
,
i
)
>=
0
);
pFFNode
->
iFunc
=
Vec_IntEntry
(
vLeaves
,
i
);
}
// perform strashing
Lit
=
Gia_ManGraphToAig
(
p
,
pFForm
);
return
Lit
;
}
int
Gia_ManFactorNode
(
Gia_Man_t
*
p
,
char
*
pSop
,
Vec_Int_t
*
vLeaves
)
{
if
(
Kit_PlaGetVarNum
(
pSop
)
==
0
)
...
...
@@ -103,18 +117,8 @@ int Gia_ManFactorNode( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves )
assert
(
Kit_PlaGetVarNum
(
pSop
)
==
Vec_IntSize
(
vLeaves
)
);
if
(
Kit_PlaGetVarNum
(
pSop
)
>
2
&&
Kit_PlaGetCubeNum
(
pSop
)
>
1
)
{
Dec_Graph_t
*
pFForm
;
Dec_Node_t
*
pFFNode
;
int
i
,
Lit
;
pFForm
=
Dec_Factor
(
pSop
);
// assign fanins
Dec_GraphForEachLeaf
(
pFForm
,
pFFNode
,
i
)
{
assert
(
Vec_IntEntry
(
vLeaves
,
i
)
>=
0
);
pFFNode
->
iFunc
=
Vec_IntEntry
(
vLeaves
,
i
);
}
// perform strashing
Lit
=
Gia_ManGraphToAig
(
p
,
pFForm
);
Dec_Graph_t
*
pFForm
=
Dec_Factor
(
pSop
);
int
Lit
=
Gia_ManFactorGraph
(
p
,
pFForm
,
vLeaves
);
Dec_GraphFree
(
pFForm
);
return
Lit
;
}
...
...
src/base/cba/cba.h
View file @
17610c03
...
...
@@ -21,7 +21,6 @@
#ifndef ABC__base__cba__cba_h
#define ABC__base__cba__cba_h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
...
...
@@ -66,17 +65,15 @@ typedef enum {
CBA_NODE_BUF
,
// 3: buffer
CBA_NODE_INV
,
// 4: inverter
CBA_NODE_AND
,
// 5: AND
CBA_NODE_AND00
,
// 6: AND00
CBA_NODE_AND01
,
// 7: AND01
CBA_NODE_AND10
,
// 8: AND10
CBA_NODE_NAND
,
// 9: NAND
CBA_NODE_OR
,
// 10: OR
CBA_NODE_NOR
,
// 11: NOR
CBA_NODE_XOR
,
// 12: XOR
CBA_NODE_XNOR
,
// 13 XNOR
CBA_NODE_MUX
,
// 14: MUX
CBA_NODE_MAJ
,
// 15: MAJ
CBA_NODE_UNKNOWN
// 16: unknown
CBA_NODE_NAND
,
// 6: NAND
CBA_NODE_OR
,
// 7: OR
CBA_NODE_NOR
,
// 8: NOR
CBA_NODE_XOR
,
// 9: XOR
CBA_NODE_XNOR
,
// 10 XNOR
CBA_NODE_SHARP
,
// 11: SHARP
CBA_NODE_MUX
,
// 12: MUX
CBA_NODE_MAJ
,
// 13: MAJ
CBA_NODE_UNKNOWN
// 14: unknown
}
Cba_NodeType_t
;
...
...
@@ -100,6 +97,8 @@ struct Cba_Man_t_
Vec_Int_t
*
vBuf2RootObj
;
Vec_Int_t
*
vBuf2LeafNtk
;
Vec_Int_t
*
vBuf2LeafObj
;
void
*
pMioLib
;
void
**
ppGraphs
;
};
// network
...
...
@@ -123,7 +122,6 @@ struct Cba_Ntk_t_
Vec_Int_t
vInstIds
;
// instance names (used by parser to store instance name as NameId)
Vec_Int_t
vFanins
;
// fanins (used by parser to store fanin/fanout/range as NameId) (node: handle; CO/BI fanin0)
// attributes
Vec_Int_t
vBoxes
;
// box objects
Vec_Int_t
vNameIds
;
// original names as NameId
Vec_Int_t
vRanges
;
// ranges as NameId
};
...
...
@@ -145,9 +143,8 @@ static inline char * Cba_NtkName( Cba_Ntk_t * p ) { r
static
inline
int
Cba_NtkObjNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vFanins
);
}
static
inline
int
Cba_NtkPiNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vInputs
);
}
static
inline
int
Cba_NtkPoNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vOutputs
);
}
static
inline
int
Cba_NtkBoxNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vBoxes
);
}
static
inline
int
Cba_NtkBoxNumCount
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntCountEntry
(
&
p
->
vTypes
,
CBA_OBJ_BOX
);
}
static
inline
int
Cba_NtkNodeNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntCountEntry
(
&
p
->
vTypes
,
CBA_OBJ_NODE
);
}
static
inline
int
Cba_NtkBoxNum
(
Cba_Ntk_t
*
p
)
{
return
Vec_IntCountEntry
(
&
p
->
vTypes
,
CBA_OBJ_BOX
);
}
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
);
}
...
...
@@ -218,7 +215,6 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { r
/// ITERATORS ///
////////////////////////////////////////////////////////////////////////
#define Cba_ManForEachNtk( p, pNtk, i ) \
for ( i = 1; (i <= Cba_ManNtkNum(p)) && (((pNtk) = Cba_ManNtk(p, i)), 1); i++ )
...
...
@@ -230,8 +226,8 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { r
#define Cba_NtkForEachObjType( p, Type, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1); i++ )
#define Cba_NtkForEachBox( p, i
Obj, i )
\
for ( i = 0; (i < Cba_Ntk
BoxNum(p)) && (((iObj) = Vec_IntEntry(&p->vBoxes, i)), 1); i++ )
#define Cba_NtkForEachBox( p, i
)
\
for ( i = 0; (i < Cba_Ntk
ObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_BOX ) {} else
#define Cba_NtkForEachNode( p, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_NODE ) {} else
...
...
@@ -337,8 +333,6 @@ static inline Cba_Man_t * Cba_ManClone( Cba_Man_t * pOld )
pNtkNew
=
Cba_NtkAlloc
(
p
,
Cba_NtkName
(
pNtk
)
);
Cba_ManFetchArray
(
p
,
&
pNtkNew
->
vInputs
,
Cba_NtkPiNum
(
pNtk
)
);
Cba_ManFetchArray
(
p
,
&
pNtkNew
->
vOutputs
,
Cba_NtkPoNum
(
pNtk
)
);
Cba_ManFetchArray
(
p
,
&
pNtkNew
->
vBoxes
,
Cba_NtkBoxNumCount
(
pNtk
)
);
Vec_IntShrink
(
&
pNtkNew
->
vBoxes
,
0
);
}
assert
(
Cba_ManNtkNum
(
p
)
==
Cba_ManNtkNum
(
pOld
)
);
return
p
;
...
...
@@ -398,9 +392,7 @@ static inline Cba_NodeType_t Ptr_SopToType( char * pSop )
if
(
!
strcmp
(
pSop
,
"1 1
\n
"
)
)
return
CBA_NODE_BUF
;
if
(
!
strcmp
(
pSop
,
"0 1
\n
"
)
)
return
CBA_NODE_INV
;
if
(
!
strcmp
(
pSop
,
"11 1
\n
"
)
)
return
CBA_NODE_AND
;
if
(
!
strcmp
(
pSop
,
"00 1
\n
"
)
)
return
CBA_NODE_AND00
;
if
(
!
strcmp
(
pSop
,
"01 1
\n
"
)
)
return
CBA_NODE_AND01
;
if
(
!
strcmp
(
pSop
,
"10 1
\n
"
)
)
return
CBA_NODE_AND10
;
if
(
!
strcmp
(
pSop
,
"00 1
\n
"
)
)
return
CBA_NODE_NOR
;
if
(
!
strcmp
(
pSop
,
"00 0
\n
"
)
)
return
CBA_NODE_OR
;
if
(
!
strcmp
(
pSop
,
"-1 1
\n
1- 1
\n
"
)
)
return
CBA_NODE_OR
;
if
(
!
strcmp
(
pSop
,
"1- 1
\n
-1 1
\n
"
)
)
return
CBA_NODE_OR
;
...
...
@@ -408,6 +400,7 @@ static inline Cba_NodeType_t Ptr_SopToType( char * pSop )
if
(
!
strcmp
(
pSop
,
"10 1
\n
01 1
\n
"
)
)
return
CBA_NODE_XOR
;
if
(
!
strcmp
(
pSop
,
"11 1
\n
00 1
\n
"
)
)
return
CBA_NODE_XNOR
;
if
(
!
strcmp
(
pSop
,
"00 1
\n
11 1
\n
"
)
)
return
CBA_NODE_XNOR
;
if
(
!
strcmp
(
pSop
,
"10 1
\n
"
)
)
return
CBA_NODE_SHARP
;
assert
(
0
);
return
CBA_NODE_NONE
;
}
...
...
@@ -418,9 +411,6 @@ static inline char * Ptr_TypeToName( Cba_NodeType_t Type )
if
(
Type
==
CBA_NODE_BUF
)
return
"buf"
;
if
(
Type
==
CBA_NODE_INV
)
return
"not"
;
if
(
Type
==
CBA_NODE_AND
)
return
"and"
;
if
(
Type
==
CBA_NODE_AND00
)
return
"and00"
;
if
(
Type
==
CBA_NODE_AND01
)
return
"and01"
;
if
(
Type
==
CBA_NODE_AND10
)
return
"and10"
;
if
(
Type
==
CBA_NODE_NAND
)
return
"nand"
;
if
(
Type
==
CBA_NODE_OR
)
return
"or"
;
if
(
Type
==
CBA_NODE_NOR
)
return
"nor"
;
...
...
@@ -428,6 +418,7 @@ static inline char * Ptr_TypeToName( Cba_NodeType_t Type )
if
(
Type
==
CBA_NODE_XNOR
)
return
"xnor"
;
if
(
Type
==
CBA_NODE_MUX
)
return
"mux"
;
if
(
Type
==
CBA_NODE_MAJ
)
return
"maj"
;
if
(
Type
==
CBA_NODE_SHARP
)
return
"sharp"
;
assert
(
0
);
return
"???"
;
}
...
...
@@ -438,14 +429,12 @@ static inline char * Ptr_TypeToSop( Cba_NodeType_t Type )
if
(
Type
==
CBA_NODE_BUF
)
return
"1 1
\n
"
;
if
(
Type
==
CBA_NODE_INV
)
return
"0 1
\n
"
;
if
(
Type
==
CBA_NODE_AND
)
return
"11 1
\n
"
;
if
(
Type
==
CBA_NODE_AND00
)
return
"00 1
\n
"
;
if
(
Type
==
CBA_NODE_AND01
)
return
"01 1
\n
"
;
if
(
Type
==
CBA_NODE_AND10
)
return
"10 1
\n
"
;
if
(
Type
==
CBA_NODE_NAND
)
return
"11 0
\n
"
;
if
(
Type
==
CBA_NODE_OR
)
return
"00 0
\n
"
;
if
(
Type
==
CBA_NODE_NOR
)
return
"00 1
\n
"
;
if
(
Type
==
CBA_NODE_XOR
)
return
"01 1
\n
10 1
\n
"
;
if
(
Type
==
CBA_NODE_XNOR
)
return
"00 1
\n
11 1
\n
"
;
if
(
Type
==
CBA_NODE_SHARP
)
return
"10 1
\n
"
;
if
(
Type
==
CBA_NODE_MUX
)
return
"11- 1
\n
0-1 1
\n
"
;
if
(
Type
==
CBA_NODE_MAJ
)
return
"11- 1
\n
1-1 1
\n
-11 1
\n
"
;
assert
(
0
);
...
...
@@ -462,7 +451,7 @@ extern Cba_Man_t * Cba_ManBuild( Cba_Man_t * p );
/*=== cbaReadBlif.c =========================================================*/
extern
Cba_Man_t
*
Cba_PrsReadBlif
(
char
*
pFileName
);
/*=== cbaReadVer.c ==========================================================*/
extern
Cba_Man_t
*
Cba_PrsReadVerilog
(
char
*
pFileName
);
extern
Cba_Man_t
*
Cba_PrsReadVerilog
(
char
*
pFileName
,
int
fBinary
);
/*=== cbaWriteBlif.c ========================================================*/
extern
void
Cba_PrsWriteBlif
(
char
*
pFileName
,
Cba_Man_t
*
p
);
extern
void
Cba_ManWriteBlif
(
char
*
pFileName
,
Cba_Man_t
*
p
);
...
...
src/base/cba/cbaBlast.c
View file @
17610c03
This diff is collapsed.
Click to expand it.
src/base/cba/cbaBuild.c
View file @
17610c03
...
...
@@ -73,12 +73,9 @@ void Cba_BoxRemap( Cba_Ntk_t * pNtk, int iBox, Vec_Int_t * vMap )
}
void
Cba_NtkRemapBoxes
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
)
{
int
Type
,
iBox
;
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iBox
)
if
(
Type
==
CBA_OBJ_BOX
)
Cba_BoxRemap
(
pNtk
,
iBox
,
vMap
);
Vec_IntForEachEntry
(
vMap
,
Type
,
iBox
)
assert
(
Type
==
-
1
);
int
iBox
;
Cba_NtkForEachBox
(
pNtk
,
iBox
)
Cba_BoxRemap
(
pNtk
,
iBox
,
vMap
);
}
// create maps of NameId and boxes
void
Cba_NtkFindNonDriven
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
int
nObjCount
,
Vec_Int_t
*
vNonDriven
)
...
...
@@ -164,7 +161,7 @@ int Cba_NtkCreateMap( Cba_Ntk_t * pNtk, Vec_Int_t * vMap, Vec_Int_t * vBoxes, Ve
nObjCount
+=
Vec_IntSize
(
vNonDriven
)
+
Cba_NtkPoNum
(
pNtk
);
return
nObjCount
;
}
Cba_Ntk_t
*
Cba_NtkBuild
(
Cba_Man_t
*
pNew
,
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vNonDriven
,
Vec_Int_t
*
vTemp
,
int
nObjCount
)
Cba_Ntk_t
*
Cba_NtkBuild
(
Cba_Man_t
*
pNew
,
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
v
Boxes
,
Vec_Int_t
*
v
NonDriven
,
Vec_Int_t
*
vTemp
,
int
nObjCount
)
{
Vec_Int_t
*
vFanins
;
Cba_Ntk_t
*
pNtkNew
,
*
pNtkBox
;
...
...
@@ -202,7 +199,7 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
else
if
(
Type
==
CBA_OBJ_BOX
)
{
ObjId
=
Vec_IntEntry
(
&
pNtkNew
->
vBoxes
,
nBoxes
++
);
ObjId
=
Vec_IntEntry
(
vBoxes
,
nBoxes
++
);
pNtkBox
=
Cba_ObjBoxModel
(
pNtk
,
iObj
);
// collect fanins
Vec_IntFill
(
vTemp
,
Cba_NtkPiNum
(
pNtkBox
),
-
1
);
...
...
@@ -243,7 +240,7 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
}
}
assert
(
nBoxes
==
Vec_IntSize
(
&
pNtkNew
->
vBoxes
)
);
assert
(
nBoxes
==
Vec_IntSize
(
vBoxes
)
);
// add constants for nondriven nodes
Vec_IntForEachEntry
(
vNonDriven
,
NameId
,
i
)
{
...
...
@@ -309,6 +306,7 @@ Cba_Man_t * Cba_ManBuild( Cba_Man_t * p )
{
Cba_Man_t
*
pNew
=
Cba_ManClone
(
p
);
Vec_Int_t
*
vMap
=
Vec_IntStartFull
(
Abc_NamObjNumMax
(
p
->
pNames
)
+
1
);
Vec_Int_t
*
vBoxes
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vNonDr
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vTemp
=
Vec_IntAlloc
(
1000
);
Cba_Ntk_t
*
pNtk
;
...
...
@@ -317,11 +315,13 @@ Cba_Man_t * Cba_ManBuild( Cba_Man_t * p )
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
Cba_NtkRemapBoxes
(
pNtk
,
vMap
);
nObjs
=
Cba_NtkCreateMap
(
pNtk
,
vMap
,
&
Cba_ManNtk
(
pNew
,
i
)
->
vBoxes
,
vNonDr
);
Cba_NtkBuild
(
pNew
,
pNtk
,
vMap
,
vNonDr
,
vTemp
,
nObjs
);
nObjs
=
Cba_NtkCreateMap
(
pNtk
,
vMap
,
vBoxes
,
vNonDr
);
Cba_NtkBuild
(
pNew
,
pNtk
,
vMap
,
v
Boxes
,
v
NonDr
,
vTemp
,
nObjs
);
Cba_NtkCleanMap
(
pNtk
,
vMap
);
}
assert
(
Vec_IntCountEntry
(
vMap
,
-
1
)
==
Vec_IntSize
(
vMap
)
);
Vec_IntFree
(
vMap
);
Vec_IntFree
(
vBoxes
);
Vec_IntFree
(
vNonDr
);
Vec_IntFree
(
vTemp
);
return
pNew
;
...
...
src/base/cba/cbaCom.c
View file @
17610c03
...
...
@@ -149,7 +149,7 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"blif"
)
)
p
=
Cba_PrsReadBlif
(
pFileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
p
=
Cba_PrsReadVerilog
(
pFileName
);
p
=
Cba_PrsReadVerilog
(
pFileName
,
1
);
else
assert
(
0
);
p
=
Cba_ManBuild
(
pTemp
=
p
);
Cba_ManFree
(
pTemp
);
...
...
@@ -465,7 +465,7 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
if
(
!
strcmp
(
Extra_FileNameExtension
(
FileName
),
"blif"
)
)
p
=
Cba_PrsReadBlif
(
FileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
FileName
),
"v"
)
)
p
=
Cba_PrsReadVerilog
(
FileName
);
p
=
Cba_PrsReadVerilog
(
FileName
,
1
);
else
assert
(
0
);
p
=
Cba_ManBuild
(
pTemp
=
p
);
Cba_ManFree
(
pTemp
);
...
...
src/base/cba/cbaNtk.c
View file @
17610c03
...
...
@@ -43,11 +43,11 @@ ABC_NAMESPACE_IMPL_START
***********************************************************************/
void
Cba_ManAssignInternNamesNtk
(
Cba_Ntk_t
*
p
)
{
int
i
,
Type
,
NameId
;
int
i
,
NameId
;
int
nDigits
=
Abc_Base10Log
(
Cba_NtkObjNum
(
p
)
);
Cba_NtkForEach
ObjType
(
p
,
Type
,
i
)
Cba_NtkForEach
Node
(
p
,
i
)
{
if
(
Type
==
CBA_OBJ_NODE
&&
Cba_ObjNameId
(
p
,
i
)
==
-
1
)
if
(
Cba_ObjNameId
(
p
,
i
)
==
-
1
)
{
char
Buffer
[
100
];
sprintf
(
Buffer
,
"%s%0*d"
,
"_n_"
,
nDigits
,
i
);
...
...
@@ -109,28 +109,25 @@ void Cba_ObjDupStart( Cba_Ntk_t * pNew, Cba_Ntk_t * p, int iObj )
Vec_IntWriteEntry
(
&
pNew
->
vNameIds
,
pNew
->
nObjs
,
Cba_ObjNameId
(
p
,
iObj
)
);
if
(
Cba_ObjIsBox
(
p
,
iObj
)
)
Cba_NtkSetHost
(
Cba_ObjBoxModel
(
pNew
,
pNew
->
nObjs
),
Cba_NtkId
(
pNew
),
pNew
->
nObjs
);
if
(
Cba_ObjIsBox
(
p
,
iObj
)
)
Vec_IntPush
(
&
pNew
->
vBoxes
,
pNew
->
nObjs
);
Cba_NtkSetCopy
(
p
,
iObj
,
pNew
->
nObjs
++
);
}
void
Cba_NtkDupStart
(
Cba_Ntk_t
*
pNew
,
Cba_Ntk_t
*
p
)
{
int
i
,
k
,
iObj
,
iTerm
;
assert
(
Vec_IntSize
(
&
pNew
->
vBoxes
)
==
0
);
int
i
,
iObj
,
iTerm
;
pNew
->
nObjs
=
0
;
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Cba_ObjDupStart
(
pNew
,
p
,
iObj
);
Cba_NtkForEachPo
(
p
,
iObj
,
i
)
Cba_ObjDupStart
(
pNew
,
p
,
iObj
);
Cba_NtkForEachBox
(
p
,
iObj
,
i
)
Cba_NtkForEachBox
(
p
,
iObj
)
{
Cba_BoxForEachBi
(
p
,
iObj
,
iTerm
,
k
)
Cba_BoxForEachBi
(
p
,
iObj
,
iTerm
,
i
)
Cba_ObjDupStart
(
pNew
,
p
,
iTerm
);
Cba_ObjDupStart
(
pNew
,
p
,
iObj
);
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
k
)
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
i
)
Cba_ObjDupStart
(
pNew
,
p
,
iTerm
);
// connect box outputs to boxes
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
k
)
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
i
)
Vec_IntWriteEntry
(
&
pNew
->
vFanins
,
Cba_NtkCopy
(
p
,
iTerm
),
Cba_NtkCopy
(
p
,
Cba_ObjFanin0
(
p
,
iTerm
))
);
}
assert
(
Cba_NtkBoxNum
(
p
)
==
Cba_NtkBoxNum
(
pNew
)
);
...
...
src/base/cba/cbaPrs.h
View file @
17610c03
...
...
@@ -197,17 +197,15 @@ static inline void Cba_PrsFree( Cba_Prs_t * p )
}
static
inline
void
Cba_PrsRemapBoxModels
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
,
Type
,
iObj
;
Cba_Ntk_t
*
pNtk
;
int
i
,
iBox
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
if
(
Type
==
CBA_OBJ_BOX
)
{
char
*
pName
=
Abc_NamStr
(
p
->
pNames
,
Cba_ObjFuncId
(
pNtk
,
iObj
)
);
int
iModelId
=
Abc_NamStrFind
(
p
->
pModels
,
pName
);
assert
(
iModelId
>
0
);
Vec_IntWriteEntry
(
&
pNtk
->
vFuncs
,
iObj
,
iModelId
);
}
Cba_NtkForEachBox
(
pNtk
,
iBox
)
{
char
*
pName
=
Abc_NamStr
(
p
->
pNames
,
Cba_ObjFuncId
(
pNtk
,
iBox
)
);
int
iModelId
=
Abc_NamStrFind
(
p
->
pModels
,
pName
);
assert
(
iModelId
>
0
);
Vec_IntWriteEntry
(
&
pNtk
->
vFuncs
,
iBox
,
iModelId
);
}
}
////////////////////////////////////////////////////////////////////////
...
...
src/base/cba/cbaReadBlif.c
View file @
17610c03
...
...
@@ -62,11 +62,11 @@ static inline void Cba_PrsAddBlifDirectives( Cba_Prs_t * p )
{
int
i
;
for
(
i
=
1
;
s_BlifTypes
[
i
];
i
++
)
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pNames
,
(
char
*
)
s_BlifTypes
[
i
],
NULL
);
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pNames
,
(
char
*
)
s_BlifTypes
[
i
],
NULL
);
assert
(
Abc_NamObjNumMax
(
p
->
pDesign
->
pNames
)
==
i
);
for
(
i
=
1
;
i
<
CBA_NODE_UNKNOWN
;
i
++
)
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pFuncs
,
Ptr_TypeToSop
(
i
),
NULL
);
assert
(
Abc_NamObjNumMax
(
p
->
pDesign
->
pFuncs
)
==
i
-
1
);
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pFuncs
,
Ptr_TypeToSop
(
i
),
NULL
);
assert
(
Abc_NamObjNumMax
(
p
->
pDesign
->
pFuncs
)
==
i
);
}
...
...
src/base/cba/cbaReadVer.c
View file @
17610c03
...
...
@@ -708,7 +708,57 @@ void Cba_PrsPrintModules( Cba_Prs_t * p )
SeeAlso []
***********************************************************************/
Cba_Man_t
*
Cba_PrsReadVerilog
(
char
*
pFileName
)
void
Cba_PrsSkipRangesNtk
(
Cba_Ntk_t
*
p
)
{
Vec_Int_t
*
vFanins
;
int
FormId
,
NameId
,
RangeId
;
int
i
,
k
,
s
,
Count
=
0
;
Vec_Int_t
*
vSigs
[
4
]
=
{
&
p
->
vInouts
,
&
p
->
vInputs
,
&
p
->
vOutputs
,
&
p
->
vWires
};
for
(
s
=
0
;
s
<
4
;
s
++
)
{
k
=
0
;
Vec_IntForEachEntryDouble
(
vSigs
[
s
],
NameId
,
RangeId
,
i
)
Vec_IntWriteEntry
(
vSigs
[
s
],
k
++
,
NameId
),
Count
+=
RangeId
>
0
;
Vec_IntShrink
(
vSigs
[
s
],
k
);
}
Cba_NtkForEachNode
(
p
,
i
)
{
k
=
0
;
vFanins
=
Cba_ObjFaninVec
(
p
,
i
);
Vec_IntForEachEntryDouble
(
vFanins
,
NameId
,
RangeId
,
s
)
Vec_IntWriteEntry
(
vFanins
,
k
++
,
NameId
),
Count
+=
RangeId
>
0
;
Cba_ObjFaninArray
(
p
,
i
)[
0
]
=
k
;
}
Cba_NtkForEachBox
(
p
,
i
)
{
k
=
0
;
vFanins
=
Cba_ObjFaninVec
(
p
,
i
);
Vec_IntForEachEntryTriple
(
vFanins
,
FormId
,
NameId
,
RangeId
,
s
)
Vec_IntWriteEntry
(
vFanins
,
k
++
,
FormId
),
Vec_IntWriteEntry
(
vFanins
,
k
++
,
NameId
),
Count
+=
RangeId
>
0
;
Cba_ObjFaninArray
(
p
,
i
)[
0
]
=
k
;
}
if
(
Count
)
printf
(
"Network %s has %d non-trivial ranges.
\n
"
,
Cba_NtkName
(
p
),
Count
);
}
void
Cba_PrsSkipRanges
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_PrsSkipRangesNtk
(
pNtk
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t
*
Cba_PrsReadVerilog
(
char
*
pFileName
,
int
fBinary
)
{
Cba_Man_t
*
pDesign
=
NULL
;
Cba_Prs_t
*
p
=
Cba_PrsAlloc
(
pFileName
);
...
...
@@ -716,11 +766,14 @@ Cba_Man_t * Cba_PrsReadVerilog( char * pFileName )
return
NULL
;
Cba_PrsAddVerilogDirectives
(
p
);
Cba_PrsReadDesign
(
p
);
Cba_PrsPrintModules
(
p
);
//
Cba_PrsPrintModules( p );
if
(
Cba_PrsErrorPrint
(
p
)
)
ABC_SWAP
(
Cba_Man_t
*
,
pDesign
,
p
->
pDesign
);
Cba_PrsFree
(
p
);
Cba_PrsRemapBoxModels
(
pDesign
);
// transform to binary ranges
if
(
fBinary
)
Cba_PrsSkipRanges
(
pDesign
);
return
pDesign
;
}
...
...
@@ -728,16 +781,16 @@ void Cba_PrsReadVerilogTest( char * pFileName )
{
abctime
clk
=
Abc_Clock
();
extern
void
Cba_PrsWriteVerilog
(
char
*
pFileName
,
Cba_Man_t
*
p
);
Cba_Man_t
*
p
=
Cba_PrsReadVerilog
(
"c/hie/dump/
1/netlist_1.v"
);
// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/me/me_wide.v" );
// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/ray/ray_wide.v" );
Cba_Man_t
*
p
=
Cba_PrsReadVerilog
(
"c/hie/dump/
24/netlist_0.v"
,
0
);
// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/me/me_wide.v"
, 0
);
// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/ray/ray_wide.v"
, 0
);
if
(
!
p
)
return
;
printf
(
"Finished reading %d networks. "
,
Cba_ManNtkNum
(
p
)
);
printf
(
"NameIDs = %d. "
,
Abc_NamObjNumMax
(
p
->
pNames
)
);
printf
(
"Memory = %.2f MB. "
,
1
.
0
*
Cba_ManMemory
(
p
)
/
(
1
<<
20
)
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
// Abc_NamPrint( p->pDesign->pNames );
Cba_PrsWriteVerilog
(
"c/hie/dump/
1/netlist_1
_out.v"
,
p
);
Cba_PrsWriteVerilog
(
"c/hie/dump/
24/netlist_0
_out.v"
,
p
);
// Cba_PrsWriteVerilog( "aga/me/me_wide_out.v", p );
// Cba_PrsWriteVerilog( "aga/ray/ray_wide_out.v", p );
Cba_ManFree
(
p
);
...
...
src/base/cba/cbaSimple.c
View file @
17610c03
...
...
@@ -481,11 +481,10 @@ Vec_Ptr_t * Ptr_CbaDeriveNode( Cba_Ntk_t * pNtk, int iObj )
}
Vec_Ptr_t
*
Ptr_CbaDeriveNodes
(
Cba_Ntk_t
*
pNtk
)
{
int
Type
,
iObj
;
int
i
;
Vec_Ptr_t
*
vNodes
=
Vec_PtrAlloc
(
Cba_NtkNodeNum
(
pNtk
)
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
if
(
Type
==
CBA_OBJ_NODE
)
Vec_PtrPush
(
vNodes
,
Ptr_CbaDeriveNode
(
pNtk
,
iObj
)
);
Cba_NtkForEachNode
(
pNtk
,
i
)
Vec_PtrPush
(
vNodes
,
Ptr_CbaDeriveNode
(
pNtk
,
i
)
);
assert
(
Ptr_CheckArray
(
vNodes
)
);
return
vNodes
;
}
...
...
@@ -515,11 +514,10 @@ Vec_Ptr_t * Ptr_CbaDeriveBox( Cba_Ntk_t * pNtk, int iObj )
}
Vec_Ptr_t
*
Ptr_CbaDeriveBoxes
(
Cba_Ntk_t
*
pNtk
)
{
int
Type
,
iObj
;
int
i
;
Vec_Ptr_t
*
vBoxes
=
Vec_PtrAlloc
(
Cba_NtkBoxNum
(
pNtk
)
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
if
(
Type
==
CBA_OBJ_BOX
)
Vec_PtrPush
(
vBoxes
,
Ptr_CbaDeriveBox
(
pNtk
,
iObj
)
);
Cba_NtkForEachBox
(
pNtk
,
i
)
Vec_PtrPush
(
vBoxes
,
Ptr_CbaDeriveBox
(
pNtk
,
i
)
);
assert
(
Ptr_CheckArray
(
vBoxes
)
);
return
vBoxes
;
}
...
...
@@ -620,7 +618,6 @@ void Cba_PrsReadModule( Cba_Man_t * p, Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_I
Cba_ManAllocArray
(
p
,
&
pNtk
->
vFuncs
,
Vec_PtrSize
(
vNodes
)
+
Vec_PtrSize
(
vBoxes
)
);
Cba_ManAllocArray
(
p
,
&
pNtk
->
vInstIds
,
Vec_PtrSize
(
vNodes
)
+
Vec_PtrSize
(
vBoxes
)
);
Cba_ManAllocArray
(
p
,
&
pNtk
->
vFanins
,
Vec_PtrSize
(
vNodes
)
+
Vec_PtrSize
(
vBoxes
)
);
Cba_ManAllocArray
(
p
,
&
pNtk
->
vBoxes
,
Vec_PtrSize
(
vBoxes
)
);
Cba_PrsReadList
(
p
,
vInputs
,
&
pNtk
->
vInputs
,
-
1
,
-
1
);
Cba_PrsReadList
(
p
,
vOutputs
,
&
pNtk
->
vOutputs
,
-
1
,
-
1
);
...
...
src/base/cba/cbaWriteBlif.c
View file @
17610c03
...
...
@@ -20,6 +20,8 @@
#include "cba.h"
#include "cbaPrs.h"
#include "map/mio/mio.h"
#include "base/main/main.h"
ABC_NAMESPACE_IMPL_START
...
...
@@ -131,6 +133,14 @@ void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * p )
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
;
...
...
@@ -157,10 +167,20 @@ void Cba_ManWriteBlifLines( FILE * pFile, Cba_Ntk_t * p )
{
if
(
Type
==
CBA_OBJ_NODE
)
// .names/assign/box2 (no formal/actual binding)
{
fprintf
(
pFile
,
".names"
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
),
i
);
//fprintf( pFile, "%s", Cba_NtkFuncStr(p, Cba_ObjFuncId(p, i)) );
fprintf
(
pFile
,
"%s"
,
Ptr_TypeToSop
(
Cba_ObjFuncId
(
p
,
i
)
)
);
if
(
Abc_NamObjNumMax
(
p
->
pDesign
->
pFuncs
)
>
1
)
// mapped
{
char
*
pGateName
=
Abc_NamStr
(
p
->
pDesign
->
pFuncs
,
Cba_ObjFuncId
(
p
,
i
)
);
Mio_Gate_t
*
pGate
=
Mio_LibraryReadGateByName
(
(
Mio_Library_t
*
)
p
->
pDesign
->
pMioLib
,
pGateName
,
NULL
);
fprintf
(
pFile
,
".gate"
);
Cba_ManWriteBlifGate
(
pFile
,
p
,
pGate
,
Cba_ObjFaninVec
(
p
,
i
),
i
);
}
else
{
fprintf
(
pFile
,
".names"
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
),
i
);
//fprintf( pFile, "%s", Cba_NtkFuncStr(p, Cba_ObjFuncId(p, i)) );
fprintf
(
pFile
,
"%s"
,
Ptr_TypeToSop
(
Cba_ObjFuncId
(
p
,
i
)
)
);
}
}
else
if
(
Type
==
CBA_OBJ_BOX
)
// .names/assign/box2 (no formal/actual binding)
{
...
...
@@ -201,6 +221,12 @@ void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p )
FILE
*
pFile
;
Cba_Ntk_t
*
pNtk
;
int
i
;
// check the library
if
(
Abc_NamObjNumMax
(
p
->
pFuncs
)
>
1
&&
p
->
pMioLib
!=
Abc_FrameReadLibGen
()
)
{
printf
(
"Genlib library used in the mapped design is not longer a current library.
\n
"
);
return
;
}
pFile
=
fopen
(
pFileName
,
"wb"
);
if
(
pFile
==
NULL
)
{
...
...
src/base/cba/cbaWriteVer.c
View file @
17610c03
...
...
@@ -116,14 +116,13 @@ void Cba_PrsWriteVerilogNodes( FILE * pFile, Cba_Ntk_t * p )
}
void
Cba_PrsWriteVerilogBoxes
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
int
Type
,
i
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
if
(
Type
==
CBA_OBJ_BOX
)
// .subckt/.gate/box (formal/actual binding)
{
fprintf
(
pFile
,
" %s %s ("
,
Cba_NtkName
(
Cba_ObjBoxModel
(
p
,
i
)),
Cba_ObjInstStr
(
p
,
i
)
);
Cba_PrsWriteVerilogArray3
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
)
);
fprintf
(
pFile
,
");
\n
"
);
}
int
i
;
Cba_NtkForEachBox
(
p
,
i
)
// .subckt/.gate/box (formal/actual binding)
{
fprintf
(
pFile
,
" %s %s ("
,
Cba_NtkName
(
Cba_ObjBoxModel
(
p
,
i
)),
Cba_ObjInstStr
(
p
,
i
)
);
Cba_PrsWriteVerilogArray3
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
)
);
fprintf
(
pFile
,
");
\n
"
);
}
}
void
Cba_PrsWriteVerilogSignals
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
,
int
SigType
)
{
...
...
@@ -259,40 +258,32 @@ void Cba_ManWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, int iObj, Vec_Int_t
}
void
Cba_ManWriteVerilogNodes
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
int
Type
,
Func
,
i
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
if
(
Type
==
CBA_OBJ_NODE
)
// .names/assign/box2 (no formal/actual binding)
int
Func
,
i
;
Cba_NtkForEachNode
(
p
,
i
)
// .names/assign/box2 (no formal/actual binding)
{
Func
=
Cba_ObjFuncId
(
p
,
i
);
if
(
Func
>=
CBA_NODE_BUF
&&
Func
<=
CBA_NODE_XNOR
)
{
Func
=
Cba_ObjFuncId
(
p
,
i
);
if
(
Func
>=
CBA_NODE_BUF
&&
Func
<=
CBA_NODE_XNOR
)
{
fprintf
(
pFile
,
" %s ("
,
Ptr_TypeToName
(
Func
)
);
Cba_ManWriteVerilogArray2
(
pFile
,
p
,
i
,
Cba_ObjFaninVec
(
p
,
i
)
);
fprintf
(
pFile
,
");
\n
"
);
}
// else if ( Func == CBA_NODE_MUX )
// Cba_PrsWriteVerilogMux( pFile, p, Cba_ObjFaninVec(p, i) );
else
{
//char * pName = Cba_NtkStr(p, Func);
assert
(
0
);
}
fprintf
(
pFile
,
" %s ("
,
Ptr_TypeToName
(
Func
)
);
Cba_ManWriteVerilogArray2
(
pFile
,
p
,
i
,
Cba_ObjFaninVec
(
p
,
i
)
);
fprintf
(
pFile
,
");
\n
"
);
}
else
assert
(
0
);
}
}
void
Cba_ManWriteVerilogBoxes
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
int
i
,
k
,
iTerm
,
Type
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
if
(
Type
==
CBA_OBJ_BOX
)
// .subckt/.gate/box (formal/actual binding)
{
Cba_Ntk_t
*
pModel
=
Cba_ObjBoxModel
(
p
,
i
);
fprintf
(
pFile
,
" %s %s ("
,
Cba_NtkName
(
pModel
),
Vec_IntSize
(
&
p
->
vInstIds
)
?
Cba_ObjInstStr
(
p
,
i
)
:
""
);
Cba_NtkForEachPi
(
pModel
,
iTerm
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Cba_ObjBoxBi
(
p
,
i
,
k
))
);
Cba_NtkForEachPo
(
pModel
,
iTerm
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Cba_ObjBoxBo
(
p
,
i
,
k
))
);
fprintf
(
pFile
,
"
\n
"
);
}
int
i
,
k
,
iTerm
;
Cba_NtkForEachBox
(
p
,
i
)
// .subckt/.gate/box (formal/actual binding)
{
Cba_Ntk_t
*
pModel
=
Cba_ObjBoxModel
(
p
,
i
);
fprintf
(
pFile
,
" %s %s ("
,
Cba_NtkName
(
pModel
),
Vec_IntSize
(
&
p
->
vInstIds
)
?
Cba_ObjInstStr
(
p
,
i
)
:
""
);
Cba_NtkForEachPi
(
pModel
,
iTerm
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Cba_ObjBoxBi
(
p
,
i
,
k
))
);
Cba_NtkForEachPo
(
pModel
,
iTerm
,
k
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Cba_ObjBoxBo
(
p
,
i
,
k
))
);
fprintf
(
pFile
,
"
\n
"
);
}
}
void
Cba_ManWriteVerilogSignals
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
,
int
SigType
,
int
fNoRange
)
{
...
...
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