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
8ac8923a
Commit
8ac8923a
authored
Jan 13, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various transformations of Cba_Ntk_t.
parent
2b2f05ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
122 additions
and
80 deletions
+122
-80
src/base/cba/cba.h
+0
-0
src/base/cba/cbaBuild.c
+42
-23
src/base/cba/cbaCom.c
+9
-3
src/base/cba/cbaPrs.h
+2
-0
src/base/cba/cbaReadBlif.c
+4
-4
src/base/cba/cbaReadVer.c
+7
-7
src/base/cba/cbaSimple.c
+31
-19
src/base/cba/cbaWriteBlif.c
+22
-19
src/base/cba/cbaWriteVer.c
+5
-5
No files found.
src/base/cba/cba.h
View file @
8ac8923a
This diff is collapsed.
Click to expand it.
src/base/cba/cbaBuild.c
View file @
8ac8923a
...
...
@@ -56,6 +56,8 @@ void Cba_BoxRemap( Cba_Ntk_t * pNtk, int iBox, Vec_Int_t * vMap )
Cba_Ntk_t
*
pBoxModel
=
Cba_ObjBoxModel
(
pNtk
,
iBox
);
Vec_Int_t
*
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iBox
);
int
i
,
NameId
;
Vec_IntForEachEntry
(
vMap
,
NameId
,
i
)
assert
(
NameId
==
-
1
);
// map formal names into I/O indexes
Cba_NtkForEachPi
(
pBoxModel
,
NameId
,
i
)
{
...
...
@@ -217,9 +219,7 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
int
i
,
iObj
,
ObjId
,
FaninId
,
Type
,
Index
,
NameId
,
nBoxes
=
0
;
// start network
pNtkNew
=
Cba_NtkAlloc
(
pNew
,
Cba_NtkName
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vInputs
,
Cba_NtkPiNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vOutputs
,
Cba_NtkPoNum
(
pNtk
)
);
pNtkNew
=
Cba_ManNtk
(
pNew
,
Cba_NtkId
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vTypes
,
nObjCount
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFuncs
,
nObjCount
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFanins
,
nObjCount
);
...
...
@@ -230,9 +230,12 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
Cba_NtkForEachPi
(
pNtk
,
NameId
,
i
)
{
ObjId
=
Vec_IntEntry
(
vMap
,
NameId
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vInputs
,
i
,
ObjId
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vInputs
,
i
,
ObjId
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
,
CBA_OBJ_PI
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
,
i
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
ObjId
,
NameId
);
}
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
{
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
...
...
@@ -252,7 +255,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
(
vBoxes
,
nBoxes
++
);
ObjId
=
Vec_IntEntry
(
&
pNtkNew
->
vBoxes
,
nBoxes
++
);
pNtkBox
=
Cba_ObjBoxModel
(
pNtk
,
iObj
);
Cba_NtkSetHost
(
pNtkBox
,
Cba_NtkId
(
pNtk
),
ObjId
);
// collect fanins
...
...
@@ -262,33 +265,38 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
i
++
;
NameId
=
Vec_IntEntry
(
vFanins
,
i
);
assert
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
);
if
(
Index
<
Cba_NtkPiNum
(
pNtkBox
)
)
{
Vec_IntWriteEntry
(
vTemp
,
Index
,
Vec_IntEntry
(
vMap
,
NameId
)
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
ObjId
-
Cba_NtkPiNum
(
pNtkBox
)
+
Index
,
NameId
);
}
else
{
assert
(
Vec_IntEntry
(
vMap
,
NameId
)
==
ObjId
+
1
+
Index
-
Cba_NtkPiNum
(
pNtkBox
)
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
Vec_IntEntry
(
vMap
,
NameId
),
NameId
);
}
}
Vec_IntForEachEntry
(
vTemp
,
Index
,
i
)
assert
(
Index
>=
0
);
// create box
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
,
CBA_OBJ_BOX
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
,
Cba_ManNtkId
(
pNew
,
Cba_NtkName
(
pNtkBox
))
);
// create box inputs
for
(
i
=
0
;
i
<
Cba_NtkPiNum
(
pNtkBox
);
i
++
)
Cba_BoxForEachBi
(
pNtkNew
,
ObjId
,
FaninId
,
i
)
{
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
-
Cba_NtkPiNum
(
pNtkBox
)
+
i
,
CBA_OBJ_BI
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
-
Cba_NtkPiNum
(
pNtkBox
)
+
i
,
i
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFanins
,
ObjId
-
Cba_NtkPiNum
(
pNtkBox
)
+
i
,
Cba_ManHandleBuffer
(
pNew
,
Vec_IntEntry
(
vTemp
,
i
))
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
FaninId
,
CBA_OBJ_BI
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
FaninId
,
i
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFanins
,
FaninId
,
Cba_ManHandleBuffer
(
pNew
,
Vec_IntEntry
(
vTemp
,
i
))
);
}
// craete box
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
,
CBA_OBJ_BOX
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
,
Cba_ManNtkId
(
pNew
,
Cba_NtkName
(
pNtkBox
))
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFanins
,
ObjId
,
Cba_ManHandleArray
(
pNew
,
vTemp
)
);
// create box outputs
for
(
i
=
1
;
i
<=
Cba_NtkPoNum
(
pNtkBox
);
i
++
)
Cba_BoxForEachBo
(
pNtkNew
,
ObjId
,
FaninId
,
i
)
{
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
+
i
,
CBA_OBJ_BO
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
+
i
,
i
-
1
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFanins
,
ObjId
+
i
,
Cba_ManHandleBuffer
(
pNew
,
ObjId
)
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
FaninId
,
CBA_OBJ_BO
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
FaninId
,
i
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFanins
,
FaninId
,
Cba_ManHandleBuffer
(
pNew
,
ObjId
)
);
}
}
}
assert
(
nBoxes
==
Vec_IntSize
(
vBoxes
)
);
assert
(
nBoxes
==
Vec_IntSize
(
&
pNtkNew
->
vBoxes
)
);
Cba_NtkForEachPo
(
pNtk
,
NameId
,
i
)
{
ObjId
=
nObjCount
-
Cba_NtkPoNum
(
pNtk
)
+
i
;
...
...
@@ -296,23 +304,34 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
assert
(
FaninId
!=
-
1
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vOutputs
,
i
,
ObjId
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
,
CBA_OBJ_PO
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
,
-
1
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
,
i
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFanins
,
ObjId
,
Cba_ManHandleBuffer
(
pNew
,
FaninId
)
);
// remove NameId from the driver and assign it to the output
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
FaninId
,
-
1
);
//
Vec_IntWriteEntry( &pNtkNew->vNameIds, FaninId, -1 );
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
ObjId
,
NameId
);
}
return
pNtkNew
;
}
Cba_Man_t
*
Cba_ManPreBuild
(
Cba_Man_t
*
p
)
{
Cba_Man_t
*
pNew
=
Cba_ManClone
(
p
);
Cba_Ntk_t
*
pNtk
,
*
pNtkNew
;
int
i
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
pNtkNew
=
Cba_NtkAlloc
(
pNew
,
Cba_NtkName
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vInputs
,
Cba_NtkPiNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vOutputs
,
Cba_NtkPoNum
(
pNtk
)
);
}
assert
(
Cba_ManNtkNum
(
pNew
)
==
Cba_ManNtkNum
(
p
)
);
return
pNew
;
}
Cba_Man_t
*
Cba_ManBuild
(
Cba_Man_t
*
p
)
{
Cba_Man_t
*
pNew
=
Cba_Man
Alloc
(
Cba_ManName
(
p
)
);
Cba_Man_t
*
pNew
=
Cba_Man
PreBuild
(
p
);
Vec_Int_t
*
vMap
=
Vec_IntStartFull
(
Abc_NamObjNumMax
(
p
->
pNames
)
+
1
);
Vec_Int_t
*
vBoxes
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vTemp
=
Vec_IntAlloc
(
1000
);
Cba_Ntk_t
*
pNtk
;
int
i
,
nObjs
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Abc_NamStrFindOrAdd
(
p
->
pModels
,
Cba_NtkName
(
pNtk
),
NULL
);
assert
(
Abc_NamObjNumMax
(
p
->
pModels
)
==
Cba_ManNtkNum
(
p
)
+
1
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
...
...
src/base/cba/cbaCom.c
View file @
8ac8923a
...
...
@@ -174,7 +174,7 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
}
if
(
argc
==
globalUtilOptind
)
pFileName
=
Extra_FileNameGenericAppend
(
pNtk
->
pName
,
"_out.v"
);
pFileName
=
Extra_FileNameGenericAppend
(
Cba_NtkMan
(
pNtk
)
->
pName
,
"_out.v"
);
else
if
(
argc
==
globalUtilOptind
+
1
)
pFileName
=
argv
[
globalUtilOptind
];
else
...
...
@@ -314,7 +314,10 @@ usage:
******************************************************************************/
int
Cba_CommandTest
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Cba_ManReadDesExperiment
(
Abc_Ntk_t
*
pNtk
);
Abc_Ntk_t
*
pAbcNtk
;
Cba_Ntk_t
*
pNtk
=
Cba_AbcGetNtk
(
pAbc
);
char
*
pFileName
=
"c/hie/dump/1/netlist_1.v"
;
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"vh"
)
)
!=
EOF
)
...
...
@@ -330,14 +333,17 @@ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
goto
usage
;
}
}
/*
if ( pNtk == NULL )
{
Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" );
return 0;
}
*/
// transform
// pNtk = Cba_NtkUifNodePairs( pNtk, NULL );
Cba_AbcUpdateNtk
(
pAbc
,
pNtk
);
pAbcNtk
=
Io_ReadNetlist
(
pFileName
,
Io_ReadFileType
(
pFileName
),
0
);
Cba_ManReadDesExperiment
(
pAbcNtk
);
Abc_NtkDelete
(
pAbcNtk
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: @test [-vh]
\n
"
);
...
...
src/base/cba/cbaPrs.h
View file @
8ac8923a
...
...
@@ -32,6 +32,7 @@
ABC_NAMESPACE_HEADER_START
/*
// parser objects (object types after parsing)
typedef enum {
CBA_PRS_NONE = 0, // 0: unused
...
...
@@ -41,6 +42,7 @@ typedef enum {
CBA_PRS_CONCAT, // 4: concatenation
CBA_PRS_UNKNOWN // 5: unknown
} Cba_PrsType_t;
*/
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
...
...
src/base/cba/cbaReadBlif.c
View file @
8ac8923a
...
...
@@ -265,7 +265,7 @@ static inline int Cba_PrsReadNode( Cba_Prs_t * p )
{
if
(
Cba_PrsReadList2
(
p
)
)
return
1
;
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_NODE
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
1
);
// default const 0 function
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
...
...
@@ -276,7 +276,7 @@ static inline int Cba_PrsReadBox( Cba_Prs_t * p, int fGate )
if
(
iToken
==
0
)
return
Cba_PrsErrorSet
(
p
,
"Cannot read model name."
,
1
);
if
(
Cba_PrsReadList3
(
p
)
)
return
1
;
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_BOX
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_BOX
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
iToken
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
...
...
@@ -299,7 +299,7 @@ static inline int Cba_PrsReadLatch( Cba_Prs_t * p )
iToken
=
2
;
Cba_PrsSkipToChar
(
p
,
'\n'
);
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_LATCH
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_LATCH
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
iToken
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
...
...
@@ -316,7 +316,7 @@ static inline int Cba_PrsReadShort( Cba_Prs_t * p )
Cba_PrsSkipSpaces
(
p
);
if
(
!
Cba_PrsIsChar
(
p
,
'\n'
)
)
return
Cba_PrsErrorSet
(
p
,
"Trailing symbols on .short line."
,
1
);
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_NODE
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
2
);
// default buffer function
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
...
...
src/base/cba/cbaReadVer.c
View file @
8ac8923a
...
...
@@ -367,7 +367,7 @@ static inline int Cba_PrsReadConcat( Cba_Prs_t * p, Vec_Int_t * vTemp2 )
assert
(
Vec_IntSize
(
vTemp2
)
>
2
);
assert
(
Vec_IntSize
(
vTemp2
)
%
2
==
0
);
// create new concatentation
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_CONCAT
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_CONCAT
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
0
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
0
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
vTemp2
)
);
...
...
@@ -497,7 +497,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p )
// check unary operator
if
(
Cba_PrsIsChar
(
p
,
';'
)
)
{
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_NODE
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
fCompl
?
CBA_NODE_INV
:
CBA_NODE_BUF
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
0
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
...
...
@@ -532,7 +532,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p )
if
(
!
Cba_PrsIsChar
(
p
,
';'
)
)
return
Cba_PrsErrorSet
(
p
,
"Expected semicolon at the end of the assign-statement."
,
0
);
}
// write binary operator
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
PRS
_NODE
);
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_
OBJ
_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
Oper
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
0
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
...
...
@@ -550,12 +550,12 @@ static inline int Cba_PrsReadInstance( Cba_Prs_t * p, int Func )
p
->
pCur
++
;
if
(
Cba_PrsUtilSkipSpaces
(
p
)
)
return
0
;
if
(
Cba_PrsIsChar
(
p
,
'.'
)
)
// node
Status
=
Cba_PrsReadSignalList2
(
p
,
&
p
->
vTemp
),
Type
=
CBA_
PRS
_BOX
;
Status
=
Cba_PrsReadSignalList2
(
p
,
&
p
->
vTemp
),
Type
=
CBA_
OBJ
_BOX
;
else
Status
=
Cba_PrsReadSignalList1
(
p
,
&
p
->
vTemp
),
Type
=
CBA_
PRS
_NODE
;
Status
=
Cba_PrsReadSignalList1
(
p
,
&
p
->
vTemp
),
Type
=
CBA_
OBJ
_NODE
;
if
(
Status
==
0
)
return
0
;
// translate elementary gate
if
(
Type
==
CBA_
PRS
_NODE
)
if
(
Type
==
CBA_
OBJ
_NODE
)
{
int
iFuncNew
=
Cba_PrsIsKnownModule
(
p
,
Abc_NamStr
(
p
->
pDesign
->
pNames
,
Func
));
if
(
iFuncNew
==
0
)
return
Cba_PrsErrorSet
(
p
,
"Cannot find elementary gate."
,
0
);
...
...
@@ -726,7 +726,7 @@ Cba_Man_t * Cba_PrsReadVerilog( char * pFileName )
void
Cba_PrsReadVerilogTest
(
char
*
pFileName
)
{
abctime
clk
=
Abc_Clock
();
extern
void
Cba_PrsWriteVerilog
(
char
*
pFileName
,
Cba_Man_t
*
p
Des
);
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"
);
...
...
src/base/cba/cbaSimple.c
View file @
8ac8923a
...
...
@@ -89,7 +89,7 @@ char * Ptr_TypeToName( Ptr_ObjType_t Type )
assert
(
0
);
return
"???"
;
}
char
*
Ptr_TypeToSop
(
Ptr_ObjType_
t
Type
)
char
*
Ptr_TypeToSop
(
in
t
Type
)
{
if
(
Type
==
PTR_OBJ_BUF
)
return
"1 1
\n
"
;
if
(
Type
==
PTR_OBJ_INV
)
return
"0 1
\n
"
;
...
...
@@ -277,7 +277,7 @@ void Ptr_ManDumpNodeBlif( FILE * pFile, Vec_Ptr_t * vNode )
Vec_PtrForEachEntryStart
(
char
*
,
vNode
,
pName
,
i
,
2
)
fprintf
(
pFile
,
" %s"
,
pName
);
fprintf
(
pFile
,
" %s
\n
"
,
(
char
*
)
Vec_PtrEntry
(
vNode
,
0
)
);
fprintf
(
pFile
,
"%s"
,
Ptr_TypeToSop
(
(
Ptr_ObjType_t
)
Abc_Ptr2Int
(
Vec_PtrEntry
(
vNode
,
1
))
)
);
fprintf
(
pFile
,
"%s"
,
Ptr_TypeToSop
(
Abc_Ptr2Int
(
Vec_PtrEntry
(
vNode
,
1
))
)
);
}
void
Ptr_ManDumpNodesBlif
(
FILE
*
pFile
,
Vec_Ptr_t
*
vNodes
)
{
...
...
@@ -544,7 +544,7 @@ Vec_Ptr_t * Ptr_CbaDeriveNodes( Cba_Ntk_t * pNtk )
int
Type
,
iObj
;
Vec_Ptr_t
*
vNodes
=
Vec_PtrAlloc
(
Cba_NtkNodeNum
(
pNtk
)
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
if
(
Type
==
CBA_
PRS
_NODE
)
if
(
Type
==
CBA_
OBJ
_NODE
)
Vec_PtrPush
(
vNodes
,
Ptr_CbaDeriveNode
(
pNtk
,
iObj
)
);
assert
(
Ptr_CheckArray
(
vNodes
)
);
return
vNodes
;
...
...
@@ -578,7 +578,7 @@ Vec_Ptr_t * Ptr_CbaDeriveBoxes( Cba_Ntk_t * pNtk )
int
Type
,
iObj
;
Vec_Ptr_t
*
vBoxes
=
Vec_PtrAlloc
(
Cba_NtkBoxNum
(
pNtk
)
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
if
(
Type
==
CBA_
PRS
_BOX
)
if
(
Type
==
CBA_
OBJ
_BOX
)
Vec_PtrPush
(
vBoxes
,
Ptr_CbaDeriveBox
(
pNtk
,
iObj
)
);
assert
(
Ptr_CheckArray
(
vBoxes
)
);
return
vBoxes
;
...
...
@@ -650,7 +650,7 @@ void Cba_PrsReadNodes( Cba_Man_t * p, Vec_Ptr_t * vNodes, Vec_Int_t * vTypesCur,
Vec_Ptr_t
*
vNode
;
int
i
;
Vec_PtrForEachEntry
(
Vec_Ptr_t
*
,
vNodes
,
vNode
,
i
)
{
Vec_IntPush
(
vTypesCur
,
CBA_
PRS
_NODE
);
Vec_IntPush
(
vTypesCur
,
CBA_
OBJ
_NODE
);
Vec_IntPush
(
vFuncsCur
,
(
Ptr_ObjType_t
)
Abc_Ptr2Int
(
Vec_PtrEntry
(
vNode
,
1
))
);
Vec_IntPush
(
vInstIdsCur
,
0
);
Vec_IntPush
(
vFaninsCur
,
Cba_ManHandleArray
(
p
,
Cba_PrsReadList
(
p
,
vNode
,
vList
,
1
,
-
1
))
);
...
...
@@ -661,8 +661,8 @@ void Cba_PrsReadBoxes( Cba_Man_t * p, Vec_Ptr_t * vBoxes, Vec_Int_t * vTypesCur,
Vec_Ptr_t
*
vBox
;
int
i
;
Vec_PtrForEachEntry
(
Vec_Ptr_t
*
,
vBoxes
,
vBox
,
i
)
{
Vec_IntPush
(
vTypesCur
,
CBA_
PRS
_BOX
);
Vec_IntPush
(
vFuncsCur
,
Abc_NamStrFindOrAdd
(
p
->
p
Name
s
,
Vec_PtrEntry
(
vBox
,
0
),
NULL
)
);
Vec_IntPush
(
vTypesCur
,
CBA_
OBJ
_BOX
);
Vec_IntPush
(
vFuncsCur
,
Abc_NamStrFindOrAdd
(
p
->
p
Model
s
,
Vec_PtrEntry
(
vBox
,
0
),
NULL
)
);
Vec_IntPush
(
vInstIdsCur
,
Abc_NamStrFindOrAdd
(
p
->
pNames
,
Vec_PtrEntry
(
vBox
,
1
),
NULL
)
);
Vec_IntPush
(
vFaninsCur
,
Cba_ManHandleArray
(
p
,
Cba_PrsReadList
(
p
,
vBox
,
vList
,
0
,
1
))
);
}
...
...
@@ -698,7 +698,7 @@ void Cba_PrsReadModule( Cba_Man_t * p, Vec_Ptr_t * vNtk )
Vec_IntFree
(
vFaninsCur
);
Vec_IntFree
(
vList
);
}
Cba_Man_t
*
Cba_PrsRead
Des
(
Vec_Ptr_t
*
vDes
)
Cba_Man_t
*
Cba_PrsRead
Ptr
(
Vec_Ptr_t
*
vDes
)
{
Vec_Ptr_t
*
vNtk
;
int
i
;
Cba_Man_t
*
p
=
Cba_ManAlloc
(
(
char
*
)
Vec_PtrEntry
(
vDes
,
0
)
);
...
...
@@ -722,25 +722,37 @@ Cba_Man_t * Cba_PrsReadDes( Vec_Ptr_t * vDes )
void
Cba_ManReadDesExperiment
(
Abc_Ntk_t
*
pNtk
)
{
abctime
clk
=
Abc_Clock
();
char
*
pFileName1
=
Extra_FileNameGenericAppend
(
pNtk
->
pDesign
->
pName
,
"_out1.blif"
);
char
*
pFileName2
=
Extra_FileNameGenericAppend
(
pNtk
->
pDesign
->
pName
,
"_out2.blif"
);
Cba_Man_t
*
p
;
Cba_Man_t
*
p
,
*
pTemp
;
char
*
pFileName
;
// derive Ptr from ABC
Vec_Ptr_t
*
vDes
=
Ptr_AbcDeriveDes
(
pNtk
);
printf
(
"Converting to Ptr: Memory = %6.3f MB "
,
1
.
0
*
Ptr_ManMemDes
(
vDes
)
/
(
1
<<
20
)
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
Ptr_ManDumpBlif
(
pFileName1
,
vDes
);
printf
(
"Finished writing output file
\"
%s
\"
. "
,
pFileName1
);
// dump
pFileName
=
Extra_FileNameGenericAppend
(
pNtk
->
pDesign
->
pName
,
"_out1.blif"
);
Ptr_ManDumpBlif
(
pFileName
,
vDes
);
printf
(
"Finished writing output file
\"
%s
\"
. "
,
pFileName
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
p
=
Cba_PrsReadDes
(
vDes
);
// derive CBA from Ptr
p
=
Cba_PrsReadPtr
(
vDes
);
Ptr_ManFreeDes
(
vDes
);
// Abc_NamPrint( p->pDesign->pNames );
Cba_PrsWriteBlif
(
pFileName2
,
p
);
// dump
pFileName
=
Extra_FileNameGenericAppend
(
pNtk
->
pDesign
->
pName
,
"_out2.blif"
);
Cba_PrsWriteBlif
(
pFileName
,
p
);
printf
(
"Finished writing output file
\"
%s
\"
. "
,
pFileName
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
// Abc_NamPrint( p->pNames );
// build CBA from CBA
p
=
Cba_ManBuild
(
pTemp
=
p
);
Cba_ManFree
(
pTemp
);
// dump
pFileName
=
Extra_FileNameGenericAppend
(
pNtk
->
pDesign
->
pName
,
"_out3.blif"
);
Cba_ManWriteBlif
(
pFileName
,
p
);
Cba_ManFree
(
p
);
printf
(
"Finished writing output file
\"
%s
\"
. "
,
pFileName
2
);
printf
(
"Finished writing output file
\"
%s
\"
. "
,
pFileName
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
}
...
...
src/base/cba/cbaWriteBlif.c
View file @
8ac8923a
...
...
@@ -27,6 +27,8 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
extern
char
*
Ptr_TypeToSop
(
int
Type
);
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
...
...
@@ -61,27 +63,28 @@ void Cba_PrsWriteBlifArray2( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins )
}
void
Cba_PrsWriteBlifLines
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
Vec_Int_t
*
vFanins
;
int
Type
,
Func
,
i
;
Cba_NtkForEachObjTypeFuncFanins
(
p
,
Type
,
Func
,
vFanins
,
i
)
if
(
Type
==
CBA_PRS_NODE
)
// .names/assign/box2 (no formal/actual binding)
int
i
,
Type
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
if
(
Type
==
CBA_OBJ_NODE
)
// .names/assign/box2 (no formal/actual binding)
{
fprintf
(
pFile
,
".names"
);
Cba_PrsWriteBlifArray
(
pFile
,
p
,
vFanins
,
1
);
fprintf
(
pFile
,
"%s"
,
Cba_NtkFuncStr
(
p
,
Func
)
);
Cba_PrsWriteBlifArray
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
),
1
);
//fprintf( pFile, "%s", Cba_NtkFuncStr(p, Cba_ObjFuncId(p, i)) );
fprintf
(
pFile
,
"%s"
,
Ptr_TypeToSop
(
Cba_ObjFuncId
(
p
,
i
)
)
);
}
else
if
(
Type
==
CBA_
PRS
_BOX
)
// .names/assign/box2 (no formal/actual binding)
else
if
(
Type
==
CBA_
OBJ
_BOX
)
// .names/assign/box2 (no formal/actual binding)
{
fprintf
(
pFile
,
".subckt"
);
fprintf
(
pFile
,
" %s"
,
Cba_
NtkStr
(
p
,
Func
)
);
Cba_PrsWriteBlifArray2
(
pFile
,
p
,
vFanins
);
fprintf
(
pFile
,
" %s"
,
Cba_
ObjFuncStr
(
p
,
i
)
);
Cba_PrsWriteBlifArray2
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
)
);
}
else
if
(
Type
==
CBA_
PRS
_LATCH
)
// .names/assign/box2 (no formal/actual binding)
else
if
(
Type
==
CBA_
OBJ
_LATCH
)
// .names/assign/box2 (no formal/actual binding)
{
Vec_Int_t
*
vFanins
=
Cba_ObjFaninVec
(
p
,
i
);
fprintf
(
pFile
,
".latch"
);
fprintf
(
pFile
,
" %s"
,
Cba_NtkStr
(
p
,
Vec_IntEntry
(
vFanins
,
1
))
);
fprintf
(
pFile
,
" %s"
,
Cba_NtkStr
(
p
,
Vec_IntEntry
(
vFanins
,
0
))
);
fprintf
(
pFile
,
" %c
\n
"
,
'0'
+
Func
);
fprintf
(
pFile
,
" %c
\n
"
,
'0'
+
Cba_ObjFuncId
(
p
,
i
)
);
}
}
void
Cba_PrsWriteBlifNtk
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
...
...
@@ -102,7 +105,7 @@ void Cba_PrsWriteBlifNtk( FILE * pFile, Cba_Ntk_t * p )
Cba_PrsWriteBlifLines
(
pFile
,
p
);
fprintf
(
pFile
,
".end
\n\n
"
);
}
void
Cba_PrsWriteBlif
(
char
*
pFileName
,
Cba_Man_t
*
p
Des
)
void
Cba_PrsWriteBlif
(
char
*
pFileName
,
Cba_Man_t
*
p
)
{
FILE
*
pFile
;
Cba_Ntk_t
*
pNtk
;
...
...
@@ -113,8 +116,8 @@ void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * pDes )
printf
(
"Cannot open output file
\"
%s
\"
.
\n
"
,
pFileName
);
return
;
}
fprintf
(
pFile
,
"// Design
\"
%s
\"
written by ABC on %s
\n\n
"
,
Cba_ManName
(
p
Des
),
Extra_TimeStamp
()
);
Cba_ManForEachNtk
(
p
Des
,
pNtk
,
i
)
fprintf
(
pFile
,
"// Design
\"
%s
\"
written by ABC on %s
\n\n
"
,
Cba_ManName
(
p
),
Extra_TimeStamp
()
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_PrsWriteBlifNtk
(
pFile
,
pNtk
);
fclose
(
pFile
);
}
...
...
@@ -142,12 +145,11 @@ void Cba_ManWriteBlifArray( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins, in
void
Cba_ManWriteBlifArray2
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
,
int
iObj
)
{
int
iTerm
,
i
;
Vec_Int_t
*
vFanins
=
Cba_ObjFaninVec
(
p
,
iObj
);
Cba_Ntk_t
*
pModel
=
Cba_ObjBoxModel
(
p
,
iObj
);
Cba_NtkForEachPi
(
pModel
,
iTerm
,
i
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Vec_IntEntry
(
vFanins
,
i
))
);
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Cba_ObjBoxBi
(
p
,
iObj
,
i
))
);
Cba_NtkForEachPo
(
pModel
,
iTerm
,
i
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
iObj
+
1
+
i
)
);
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Cba_ObjBoxBo
(
p
,
iObj
,
i
)
)
);
fprintf
(
pFile
,
"
\n
"
);
}
void
Cba_ManWriteBlifLines
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
...
...
@@ -159,12 +161,13 @@ void Cba_ManWriteBlifLines( FILE * pFile, Cba_Ntk_t * p )
{
fprintf
(
pFile
,
".names"
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
),
i
);
fprintf
(
pFile
,
"%s"
,
Cba_ObjFuncStr
(
p
,
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)
{
fprintf
(
pFile
,
".subckt"
);
fprintf
(
pFile
,
" %s"
,
Cba_
ObjFuncStr
(
p
,
i
)
);
fprintf
(
pFile
,
" %s"
,
Cba_
NtkName
(
Cba_ObjBoxModel
(
p
,
i
)
)
);
Cba_ManWriteBlifArray2
(
pFile
,
p
,
i
);
}
else
if
(
Type
==
CBA_OBJ_LATCH
)
// .names/assign/box2 (no formal/actual binding)
...
...
src/base/cba/cbaWriteVer.c
View file @
8ac8923a
...
...
@@ -134,7 +134,7 @@ void Cba_PrsWriteVerilogNodes( FILE * pFile, Cba_Ntk_t * p )
{
int
Type
,
Func
,
i
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
if
(
Type
==
CBA_
PRS
_NODE
)
// .names/assign/box2 (no formal/actual binding)
if
(
Type
==
CBA_
OBJ
_NODE
)
// .names/assign/box2 (no formal/actual binding)
{
Func
=
Cba_ObjFuncId
(
p
,
i
);
if
(
Func
>=
CBA_NODE_BUF
&&
Func
<=
CBA_NODE_XNOR
)
...
...
@@ -156,7 +156,7 @@ void Cba_PrsWriteVerilogBoxes( FILE * pFile, Cba_Ntk_t * p )
{
int
Type
,
i
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
if
(
Type
==
CBA_
PRS
_BOX
)
// .subckt/.gate/box (formal/actual binding)
if
(
Type
==
CBA_
OBJ
_BOX
)
// .subckt/.gate/box (formal/actual binding)
{
fprintf
(
pFile
,
" %s %s ("
,
Cba_ObjFuncStr
(
p
,
i
),
Cba_ObjInstStr
(
p
,
i
)
);
Cba_PrsWriteVerilogArray3
(
pFile
,
p
,
Cba_ObjFaninVec
(
p
,
i
)
);
...
...
@@ -204,7 +204,7 @@ void Cba_PrsWriteVerilogNtk( FILE * pFile, Cba_Ntk_t * p )
Cba_PrsWriteVerilogBoxes
(
pFile
,
p
);
fprintf
(
pFile
,
"endmodule
\n\n
"
);
}
void
Cba_PrsWriteVerilog
(
char
*
pFileName
,
Cba_Man_t
*
p
Des
)
void
Cba_PrsWriteVerilog
(
char
*
pFileName
,
Cba_Man_t
*
p
)
{
FILE
*
pFile
;
Cba_Ntk_t
*
pNtk
;
...
...
@@ -215,8 +215,8 @@ void Cba_PrsWriteVerilog( char * pFileName, Cba_Man_t * pDes )
printf
(
"Cannot open output file
\"
%s
\"
.
\n
"
,
pFileName
);
return
;
}
fprintf
(
pFile
,
"// Design
\"
%s
\"
written by ABC on %s
\n\n
"
,
Cba_ManName
(
p
Des
),
Extra_TimeStamp
()
);
Cba_ManForEachNtk
(
p
Des
,
pNtk
,
i
)
fprintf
(
pFile
,
"// Design
\"
%s
\"
written by ABC on %s
\n\n
"
,
Cba_ManName
(
p
),
Extra_TimeStamp
()
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_PrsWriteVerilogNtk
(
pFile
,
pNtk
);
fclose
(
pFile
);
}
...
...
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