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
ee72b500
Commit
ee72b500
authored
Jan 11, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various transformations of Cba_Ntk_t.
parent
26b8116a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
38 deletions
+120
-38
src/base/cba/cba.h
+0
-0
src/base/cba/cbaBuild.c
+0
-0
src/base/cba/cbaNtk.c
+21
-1
src/base/cba/cbaPrs.h
+9
-28
src/base/cba/cbaReadBlif.c
+4
-4
src/base/cba/cbaReadVer.c
+4
-4
src/base/cba/cbaSimple.c
+0
-0
src/base/cba/cbaWriteBlif.c
+82
-1
No files found.
src/base/cba/cba.h
View file @
ee72b500
This diff is collapsed.
Click to expand it.
src/base/cba/cbaBuild.c
View file @
ee72b500
This diff is collapsed.
Click to expand it.
src/base/cba/cbaNtk.c
View file @
ee72b500
...
...
@@ -41,7 +41,27 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
void
Cba_ManAssignInternNamesNtk
(
Cba_Ntk_t
*
p
)
{
int
i
,
Type
,
NameId
;
int
nDigits
=
Abc_Base10Log
(
Cba_NtkObjNum
(
p
)
);
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
{
if
(
Type
==
CBA_OBJ_NODE
||
Type
==
CBA_OBJ_PIN
)
{
char
Buffer
[
100
];
sprintf
(
Buffer
,
"%s%0*d"
,
"_n_"
,
nDigits
,
i
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pNames
,
Buffer
,
NULL
);
Vec_IntWriteEntry
(
&
p
->
vNameIds
,
i
,
NameId
);
}
}
}
void
Cba_ManAssignInternNames
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManAssignInternNamesNtk
(
pNtk
);
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
...
...
src/base/cba/cbaPrs.h
View file @
ee72b500
...
...
@@ -111,38 +111,19 @@ static inline int Cba_PrsErrorPrint( Cba_Prs_t * p )
return
0
;
}
// copy contents to the vector
static
inline
int
Cba_PrsSetupDataInt
(
Cba_Prs_t
*
p
,
Vec_Int_t
*
vFrom
)
{
int
h
=
Vec_SetFetchH
(
Cba_ManMem
(
p
->
pDesign
),
sizeof
(
int
)
*
(
Vec_IntSize
(
vFrom
)
+
1
)
);
int
*
pArray
=
(
int
*
)
Vec_SetEntry
(
Cba_ManMem
(
p
->
pDesign
),
h
);
pArray
[
0
]
=
Vec_IntSize
(
vFrom
);
memcpy
(
pArray
+
1
,
Vec_IntArray
(
vFrom
),
sizeof
(
int
)
*
Vec_IntSize
(
vFrom
)
);
Vec_IntClear
(
vFrom
);
return
h
;
}
static
inline
void
Cba_PrsSetupVecInt
(
Cba_Prs_t
*
p
,
Vec_Int_t
*
vTo
,
Vec_Int_t
*
vFrom
)
{
if
(
Vec_IntSize
(
vFrom
)
==
0
)
return
;
vTo
->
nSize
=
vTo
->
nCap
=
Vec_IntSize
(
vFrom
);
vTo
->
pArray
=
(
int
*
)
Vec_SetFetch
(
Cba_ManMem
(
p
->
pDesign
),
sizeof
(
int
)
*
Vec_IntSize
(
vFrom
)
);
memcpy
(
Vec_IntArray
(
vTo
),
Vec_IntArray
(
vFrom
),
sizeof
(
int
)
*
Vec_IntSize
(
vFrom
)
);
Vec_IntClear
(
vFrom
);
}
// create network
static
inline
Cba_Ntk_t
*
Cba_PrsAddCurrentModel
(
Cba_Prs_t
*
p
,
int
iNameId
)
{
Cba_Ntk_t
*
pNtk
=
Cba_NtkAlloc
(
p
->
pDesign
,
Abc_NamStr
(
p
->
pDesign
->
pNames
,
iNameId
)
);
assert
(
Vec_IntSize
(
&
p
->
vInputsCur
)
!=
0
||
Vec_IntSize
(
&
p
->
vOutputsCur
)
!=
0
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vInouts
,
&
p
->
vInoutsCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vInputs
,
&
p
->
vInputsCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vOutputs
,
&
p
->
vOutputsCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vWires
,
&
p
->
vWiresCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vTypes
,
&
p
->
vTypesCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vFuncs
,
&
p
->
vFuncsCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vInstIds
,
&
p
->
vInstIdsCur
);
Cba_
PrsSetupVecInt
(
p
,
&
pNtk
->
vFanins
,
&
p
->
vFaninsCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vInouts
,
&
p
->
vInoutsCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vInputs
,
&
p
->
vInputsCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vOutputs
,
&
p
->
vOutputsCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vWires
,
&
p
->
vWiresCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vTypes
,
&
p
->
vTypesCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vFuncs
,
&
p
->
vFuncsCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vInstIds
,
&
p
->
vInstIdsCur
);
Cba_
ManSetupArray
(
p
->
pDesign
,
&
pNtk
->
vFanins
,
&
p
->
vFaninsCur
);
return
pNtk
;
}
...
...
src/base/cba/cbaReadBlif.c
View file @
ee72b500
...
...
@@ -267,7 +267,7 @@ static inline int Cba_PrsReadNode( Cba_Prs_t * p )
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
1
);
// default const 0 function
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
}
static
inline
int
Cba_PrsReadBox
(
Cba_Prs_t
*
p
,
int
fGate
)
...
...
@@ -278,7 +278,7 @@ static inline int Cba_PrsReadBox( Cba_Prs_t * p, int fGate )
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_BOX
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
iToken
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
}
static
inline
int
Cba_PrsReadLatch
(
Cba_Prs_t
*
p
)
...
...
@@ -301,7 +301,7 @@ static inline int Cba_PrsReadLatch( Cba_Prs_t * p )
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_LATCH
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
iToken
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
}
static
inline
int
Cba_PrsReadShort
(
Cba_Prs_t
*
p
)
...
...
@@ -318,7 +318,7 @@ static inline int Cba_PrsReadShort( Cba_Prs_t * p )
// save results
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
2
);
// default buffer function
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
0
;
}
static
inline
int
Cba_PrsReadModel
(
Cba_Prs_t
*
p
)
...
...
src/base/cba/cbaReadVer.c
View file @
ee72b500
...
...
@@ -370,7 +370,7 @@ static inline int Cba_PrsReadConcat( Cba_Prs_t * p, Vec_Int_t * vTemp2 )
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_CONCAT
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
0
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
0
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
vTemp2
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
vTemp2
)
);
return
Vec_IntSize
(
&
p
->
vFaninsCur
);
}
static
inline
int
Cba_PrsReadSignalOrConcat
(
Cba_Prs_t
*
p
,
int
*
pName
,
int
*
pRange
)
...
...
@@ -500,7 +500,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p )
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
fCompl
?
CBA_NODE_INV
:
CBA_NODE_BUF
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
0
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
1
;
}
if
(
Cba_PrsIsChar
(
p
,
'&'
)
)
...
...
@@ -535,7 +535,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p )
Vec_IntPush
(
&
p
->
vTypesCur
,
CBA_PRS_NODE
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
Oper
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
0
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
1
;
}
static
inline
int
Cba_PrsReadInstance
(
Cba_Prs_t
*
p
,
int
Func
)
...
...
@@ -565,7 +565,7 @@ static inline int Cba_PrsReadInstance( Cba_Prs_t * p, int Func )
Vec_IntPush
(
&
p
->
vTypesCur
,
Type
);
Vec_IntPush
(
&
p
->
vFuncsCur
,
Func
);
Vec_IntPush
(
&
p
->
vInstIdsCur
,
InstId
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
PrsSetupDataInt
(
p
,
&
p
->
vTemp
)
);
Vec_IntPush
(
&
p
->
vFaninsCur
,
Cba_
ManHandleArray
(
p
->
pDesign
,
&
p
->
vTemp
)
);
return
1
;
}
...
...
src/base/cba/cbaSimple.c
View file @
ee72b500
This diff is collapsed.
Click to expand it.
src/base/cba/cbaWriteBlif.c
View file @
ee72b500
...
...
@@ -121,7 +121,7 @@ void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * pDes )
/**Function*************************************************************
Synopsis []
Synopsis [
Write elaborated design.
]
Description []
...
...
@@ -130,6 +130,87 @@ void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * pDes )
SeeAlso []
***********************************************************************/
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
;
Vec_Int_t
*
vFanins
=
Cba_ObjFaninVec
(
p
,
iObj
);
Cba_Ntk_t
*
pModel
=
Cba_ObjModel
(
p
,
iObj
);
Cba_NtkForEachPi
(
pModel
,
iTerm
,
i
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
Vec_IntEntry
(
vFanins
,
i
))
);
Cba_NtkForEachPo
(
pModel
,
iTerm
,
i
)
fprintf
(
pFile
,
" %s=%s"
,
Cba_ObjNameStr
(
pModel
,
iTerm
),
Cba_ObjNameStr
(
p
,
iObj
+
1
+
i
)
);
fprintf
(
pFile
,
"
\n
"
);
}
void
Cba_ManWriteBlifLines
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
int
Type
,
i
;
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
{
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_ObjFuncStr
(
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
)
);
Cba_ManWriteBlifArray2
(
pFile
,
p
,
i
);
}
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_ObjNameStr
(
p
,
Vec_IntEntry
(
vFanins
,
1
))
);
fprintf
(
pFile
,
" %s"
,
Cba_ObjNameStr
(
p
,
Vec_IntEntry
(
vFanins
,
0
))
);
fprintf
(
pFile
,
" %c
\n
"
,
'0'
+
Cba_ObjFuncId
(
p
,
i
)
);
}
}
}
void
Cba_ManWriteBlifNtk
(
FILE
*
pFile
,
Cba_Ntk_t
*
p
)
{
assert
(
Vec_IntSize
(
&
p
->
vTypes
)
==
Cba_NtkObjNum
(
p
)
);
assert
(
Vec_IntSize
(
&
p
->
vFuncs
)
==
Cba_NtkObjNum
(
p
)
);
// write header
fprintf
(
pFile
,
".model %s
\n
"
,
Cba_NtkName
(
p
)
);
if
(
Vec_IntSize
(
&
p
->
vInouts
)
)
fprintf
(
pFile
,
".inouts"
);
if
(
Vec_IntSize
(
&
p
->
vInouts
)
)
Cba_ManWriteBlifArray
(
pFile
,
p
,
&
p
->
vInouts
,
-
1
);
fprintf
(
pFile
,
".inputs"
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
&
p
->
vInputs
,
-
1
);
fprintf
(
pFile
,
".outputs"
);
Cba_ManWriteBlifArray
(
pFile
,
p
,
&
p
->
vOutputs
,
-
1
);
// write objects
Cba_ManWriteBlifLines
(
pFile
,
p
);
fprintf
(
pFile
,
".end
\n\n
"
);
}
void
Cba_ManWriteBlif
(
char
*
pFileName
,
Cba_Man_t
*
p
)
{
FILE
*
pFile
;
Cba_Ntk_t
*
pNtk
;
int
i
;
pFile
=
fopen
(
pFileName
,
"wb"
);
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open output file
\"
%s
\"
.
\n
"
,
pFileName
);
return
;
}
fprintf
(
pFile
,
"// Design
\"
%s
\"
written by ABC on %s
\n\n
"
,
Cba_ManName
(
p
),
Extra_TimeStamp
()
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManWriteBlifNtk
(
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