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
d6157c75
Commit
d6157c75
authored
Feb 15, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Several improvements to CBA data-structure.
parent
5158c711
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
195 additions
and
63 deletions
+195
-63
src/base/cba/cba.h
+0
-0
src/base/cba/cbaCba.c
+20
-8
src/base/cba/cbaNtk.c
+122
-8
src/base/cba/cbaPrsBuild.c
+10
-12
src/base/cba/cbaPtrAbc.c
+5
-5
src/base/cba/cbaReadBlif.c
+10
-6
src/base/cba/cbaReadVer.c
+28
-24
src/base/cba/cbaWriteVer.c
+0
-0
No files found.
src/base/cba/cba.h
View file @
d6157c75
This diff is collapsed.
Click to expand it.
src/base/cba/cbaCba.c
View file @
d6157c75
...
@@ -50,9 +50,9 @@ int CbaManReadCbaLine( Vec_Str_t * vOut, int * pPos, char * pBuffer, char * pLim
...
@@ -50,9 +50,9 @@ int CbaManReadCbaLine( Vec_Str_t * vOut, int * pPos, char * pBuffer, char * pLim
*
pBuffer
=
0
;
*
pBuffer
=
0
;
return
pBuffer
<
pLimit
;
return
pBuffer
<
pLimit
;
}
}
int
CbaManReadCbaNameAndNums
(
char
*
pBuffer
,
int
*
Num1
,
int
*
Num2
,
int
*
Num3
)
int
CbaManReadCbaNameAndNums
(
char
*
pBuffer
,
int
*
Num1
,
int
*
Num2
,
int
*
Num3
,
int
*
Num4
)
{
{
*
Num1
=
*
Num2
=
*
Num3
=
-
1
;
*
Num1
=
*
Num2
=
*
Num3
=
*
Num4
=
-
1
;
// read name
// read name
while
(
*
pBuffer
&&
*
pBuffer
!=
' '
)
while
(
*
pBuffer
&&
*
pBuffer
!=
' '
)
pBuffer
++
;
pBuffer
++
;
...
@@ -76,6 +76,13 @@ int CbaManReadCbaNameAndNums( char * pBuffer, int * Num1, int * Num2, int * Num3
...
@@ -76,6 +76,13 @@ int CbaManReadCbaNameAndNums( char * pBuffer, int * Num1, int * Num2, int * Num3
// read Num3
// read Num3
assert
(
*
pBuffer
==
' '
);
assert
(
*
pBuffer
==
' '
);
*
Num3
=
atoi
(
++
pBuffer
);
*
Num3
=
atoi
(
++
pBuffer
);
while
(
*
pBuffer
&&
*
pBuffer
!=
' '
)
pBuffer
++
;
if
(
!*
pBuffer
)
return
1
;
// read Num4
assert
(
*
pBuffer
==
' '
);
*
Num4
=
atoi
(
++
pBuffer
);
return
1
;
return
1
;
}
}
void
Cba_ManReadCbaVecStr
(
Vec_Str_t
*
vOut
,
int
*
pPos
,
Vec_Str_t
*
p
,
int
nSize
)
void
Cba_ManReadCbaVecStr
(
Vec_Str_t
*
vOut
,
int
*
pPos
,
Vec_Str_t
*
p
,
int
nSize
)
...
@@ -97,6 +104,7 @@ void Cba_ManReadCbaNtk( Vec_Str_t * vOut, int * pPos, Cba_Ntk_t * pNtk )
...
@@ -97,6 +104,7 @@ void Cba_ManReadCbaNtk( Vec_Str_t * vOut, int * pPos, Cba_Ntk_t * pNtk )
int
i
,
Type
;
int
i
,
Type
;
Cba_ManReadCbaVecStr
(
vOut
,
pPos
,
&
pNtk
->
vType
,
Cba_NtkObjNumAlloc
(
pNtk
)
);
Cba_ManReadCbaVecStr
(
vOut
,
pPos
,
&
pNtk
->
vType
,
Cba_NtkObjNumAlloc
(
pNtk
)
);
Cba_ManReadCbaVecInt
(
vOut
,
pPos
,
&
pNtk
->
vFanin
,
4
*
Cba_NtkObjNumAlloc
(
pNtk
)
);
Cba_ManReadCbaVecInt
(
vOut
,
pPos
,
&
pNtk
->
vFanin
,
4
*
Cba_NtkObjNumAlloc
(
pNtk
)
);
Cba_ManReadCbaVecInt
(
vOut
,
pPos
,
&
pNtk
->
vInfo
,
12
*
Cba_NtkInfoNumAlloc
(
pNtk
)
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
i
)
Cba_NtkForEachObjType
(
pNtk
,
Type
,
i
)
{
{
if
(
Type
==
CBA_OBJ_PI
)
if
(
Type
==
CBA_OBJ_PI
)
...
@@ -107,17 +115,18 @@ void Cba_ManReadCbaNtk( Vec_Str_t * vOut, int * pPos, Cba_Ntk_t * pNtk )
...
@@ -107,17 +115,18 @@ void Cba_ManReadCbaNtk( Vec_Str_t * vOut, int * pPos, Cba_Ntk_t * pNtk )
assert
(
Cba_NtkPiNum
(
pNtk
)
==
Cba_NtkPiNumAlloc
(
pNtk
)
);
assert
(
Cba_NtkPiNum
(
pNtk
)
==
Cba_NtkPiNumAlloc
(
pNtk
)
);
assert
(
Cba_NtkPoNum
(
pNtk
)
==
Cba_NtkPoNumAlloc
(
pNtk
)
);
assert
(
Cba_NtkPoNum
(
pNtk
)
==
Cba_NtkPoNumAlloc
(
pNtk
)
);
assert
(
Cba_NtkObjNum
(
pNtk
)
==
Cba_NtkObjNumAlloc
(
pNtk
)
);
assert
(
Cba_NtkObjNum
(
pNtk
)
==
Cba_NtkObjNumAlloc
(
pNtk
)
);
assert
(
Cba_NtkInfoNum
(
pNtk
)
==
Cba_NtkInfoNumAlloc
(
pNtk
)
);
}
}
Cba_Man_t
*
Cba_ManReadCbaInt
(
Vec_Str_t
*
vOut
)
Cba_Man_t
*
Cba_ManReadCbaInt
(
Vec_Str_t
*
vOut
)
{
{
Cba_Man_t
*
p
;
Cba_Man_t
*
p
;
Cba_Ntk_t
*
pNtk
;
Cba_Ntk_t
*
pNtk
;
char
Buffer
[
1000
]
=
"#"
;
char
Buffer
[
1000
]
=
"#"
;
int
i
,
NameId
,
Pos
=
0
,
nNtks
,
nPrims
,
Num1
,
Num2
,
Num3
;
int
i
,
NameId
,
Pos
=
0
,
nNtks
,
nPrims
,
Num1
,
Num2
,
Num3
,
Num4
;
while
(
Buffer
[
0
]
==
'#'
)
while
(
Buffer
[
0
]
==
'#'
)
if
(
!
CbaManReadCbaLine
(
vOut
,
&
Pos
,
Buffer
,
Buffer
+
1000
)
)
if
(
!
CbaManReadCbaLine
(
vOut
,
&
Pos
,
Buffer
,
Buffer
+
1000
)
)
return
NULL
;
return
NULL
;
if
(
!
CbaManReadCbaNameAndNums
(
Buffer
,
&
nNtks
,
&
nPrims
,
&
Num3
)
)
if
(
!
CbaManReadCbaNameAndNums
(
Buffer
,
&
nNtks
,
&
nPrims
,
&
Num3
,
&
Num4
)
)
return
NULL
;
return
NULL
;
// start manager
// start manager
assert
(
nNtks
>
0
&&
nPrims
>
0
);
assert
(
nNtks
>
0
&&
nPrims
>
0
);
...
@@ -130,7 +139,7 @@ Cba_Man_t * Cba_ManReadCbaInt( Vec_Str_t * vOut )
...
@@ -130,7 +139,7 @@ Cba_Man_t * Cba_ManReadCbaInt( Vec_Str_t * vOut )
Cba_ManFree
(
p
);
Cba_ManFree
(
p
);
return
NULL
;
return
NULL
;
}
}
if
(
!
CbaManReadCbaNameAndNums
(
Buffer
,
&
Num1
,
&
Num2
,
&
Num3
)
)
if
(
!
CbaManReadCbaNameAndNums
(
Buffer
,
&
Num1
,
&
Num2
,
&
Num3
,
&
Num4
)
)
{
{
Cba_ManFree
(
p
);
Cba_ManFree
(
p
);
return
NULL
;
return
NULL
;
...
@@ -138,6 +147,7 @@ Cba_Man_t * Cba_ManReadCbaInt( Vec_Str_t * vOut )
...
@@ -138,6 +147,7 @@ Cba_Man_t * Cba_ManReadCbaInt( Vec_Str_t * vOut )
assert
(
Num1
>
0
&&
Num2
>
0
&&
Num3
>
0
);
assert
(
Num1
>
0
&&
Num2
>
0
&&
Num3
>
0
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pStrs
,
Buffer
,
NULL
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pStrs
,
Buffer
,
NULL
);
Cba_NtkAlloc
(
pNtk
,
NameId
,
Num1
,
Num2
,
Num3
);
Cba_NtkAlloc
(
pNtk
,
NameId
,
Num1
,
Num2
,
Num3
);
Vec_IntFill
(
&
pNtk
->
vInfo
,
3
*
Num4
,
-
1
);
}
}
// read networks
// read networks
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
...
@@ -201,8 +211,9 @@ Cba_Man_t * Cba_ManReadCba( char * pFileName )
...
@@ -201,8 +211,9 @@ Cba_Man_t * Cba_ManReadCba( char * pFileName )
***********************************************************************/
***********************************************************************/
void
Cba_ManWriteCbaNtk
(
Vec_Str_t
*
vOut
,
Cba_Ntk_t
*
pNtk
)
void
Cba_ManWriteCbaNtk
(
Vec_Str_t
*
vOut
,
Cba_Ntk_t
*
pNtk
)
{
{
Vec_StrPushBuffer
(
vOut
,
(
char
*
)
Vec_StrArray
(
&
pNtk
->
vType
),
Cba_NtkObjNum
(
pNtk
)
);
Vec_StrPushBuffer
(
vOut
,
(
char
*
)
Vec_StrArray
(
&
pNtk
->
vType
),
Cba_NtkObjNum
(
pNtk
)
);
Vec_StrPushBuffer
(
vOut
,
(
char
*
)
Vec_IntArray
(
&
pNtk
->
vFanin
),
4
*
Cba_NtkObjNum
(
pNtk
)
);
Vec_StrPushBuffer
(
vOut
,
(
char
*
)
Vec_IntArray
(
&
pNtk
->
vFanin
),
4
*
Cba_NtkObjNum
(
pNtk
)
);
Vec_StrPushBuffer
(
vOut
,
(
char
*
)
Vec_IntArray
(
&
pNtk
->
vInfo
),
12
*
Cba_NtkInfoNum
(
pNtk
)
);
}
}
void
Cba_ManWriteCbaInt
(
Vec_Str_t
*
vOut
,
Cba_Man_t
*
p
)
void
Cba_ManWriteCbaInt
(
Vec_Str_t
*
vOut
,
Cba_Man_t
*
p
)
{
{
...
@@ -215,7 +226,8 @@ void Cba_ManWriteCbaInt( Vec_Str_t * vOut, Cba_Man_t * p )
...
@@ -215,7 +226,8 @@ void Cba_ManWriteCbaInt( Vec_Str_t * vOut, Cba_Man_t * p )
Vec_StrPrintStr
(
vOut
,
Buffer
);
Vec_StrPrintStr
(
vOut
,
Buffer
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
{
sprintf
(
Buffer
,
"%s %d %d %d
\n
"
,
Cba_NtkName
(
pNtk
),
Cba_NtkPiNum
(
pNtk
),
Cba_NtkPoNum
(
pNtk
),
Cba_NtkObjNum
(
pNtk
)
);
sprintf
(
Buffer
,
"%s %d %d %d %d
\n
"
,
Cba_NtkName
(
pNtk
),
Cba_NtkPiNum
(
pNtk
),
Cba_NtkPoNum
(
pNtk
),
Cba_NtkObjNum
(
pNtk
),
Cba_NtkInfoNum
(
pNtk
)
);
Vec_StrPrintStr
(
vOut
,
Buffer
);
Vec_StrPrintStr
(
vOut
,
Buffer
);
}
}
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
...
...
src/base/cba/cbaNtk.c
View file @
d6157c75
...
@@ -32,7 +32,116 @@ ABC_NAMESPACE_IMPL_START
...
@@ -32,7 +32,116 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
/**Function*************************************************************
Synopsis []
Synopsis [Assigns word-level names.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Cba_ManAssignInternTwo
(
Cba_Ntk_t
*
p
,
int
iNum
,
Vec_Int_t
*
vMap
)
{
char
Buffer
[
16
];
int
i
=
0
,
NameId
,
nDigits
;
do
{
nDigits
=
Abc_Base10Log
(
Cba_NtkObjNum
(
p
)
);
if
(
i
==
0
)
sprintf
(
Buffer
,
"%s%0*d"
,
"n"
,
nDigits
,
iNum
);
else
sprintf
(
Buffer
,
"%s%0*d_%d"
,
"n"
,
nDigits
,
iNum
,
++
i
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pStrs
,
Buffer
,
NULL
);
}
while
(
Vec_IntEntry
(
vMap
,
NameId
)
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iNum
);
return
NameId
;
}
void
Cba_ManPrepareBitNames
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vMap
,
int
*
pnNames
,
Vec_Int_t
*
vRanges
,
Vec_Int_t
*
vNames
)
{
int
n
=
0
,
i
,
k
,
Range
;
Vec_IntClear
(
vNames
);
Vec_IntForEachEntry
(
vRanges
,
Range
,
i
)
{
assert
(
Range
>
0
);
if
(
Range
==
1
)
Vec_IntPush
(
vNames
,
Abc_Var2Lit2
(
Cba_ManAssignInternTwo
(
p
,
(
*
pnNames
)
++
,
vMap
),
CBA_NAME_BIN
)
);
else
{
Vec_IntPush
(
vNames
,
Abc_Var2Lit2
(
Cba_ManAssignInternTwo
(
p
,
(
*
pnNames
)
++
,
vMap
),
CBA_NAME_WORD
)
);
for
(
k
=
1
;
k
<
Range
;
k
++
)
Vec_IntPush
(
vNames
,
Abc_Var2Lit2
(
k
,
CBA_NAME_INDEX
)
);
}
}
}
void
Cba_ManAssignInternWordNamesNtk
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vRanges
,
Vec_Int_t
*
vNames
)
{
int
k
,
n
=
0
,
iObj
,
iTerm
,
nNames
=
1
;
assert
(
Cba_NtkReadRangesUser
(
p
,
NULL
,
0
)
==
Cba_NtkPiNum
(
p
)
);
assert
(
Cba_NtkReadRangesUser
(
p
,
NULL
,
1
)
==
Cba_NtkPoNum
(
p
)
);
// start names
assert
(
!
Cba_NtkHasNames
(
p
)
);
Cba_NtkStartNames
(
p
);
// derive PI names
Cba_NtkReadRangesUser
(
p
,
vRanges
,
0
);
Cba_ManPrepareBitNames
(
p
,
vMap
,
&
nNames
,
vRanges
,
vNames
);
assert
(
Vec_IntSize
(
vNames
)
==
Cba_NtkPiNum
(
p
)
);
Cba_NtkForEachPi
(
p
,
iObj
,
k
)
{
Cba_ObjSetName
(
p
,
iObj
,
Vec_IntEntry
(
vNames
,
k
)
);
if
(
Cba_ObjNameType
(
p
,
iObj
)
<=
CBA_NAME_WORD
)
// works only if the PIs are before POs
Cba_NtkSetInfoName
(
p
,
n
++
,
Abc_Var2Lit2
(
Cba_ObjNameId
(
p
,
iObj
),
1
)
);
}
assert
(
n
==
Vec_IntSize
(
vRanges
)
);
// derive box output names
Cba_NtkForEachBox
(
p
,
iObj
)
{
if
(
Cba_ObjIsBoxUser
(
p
,
iObj
)
)
Cba_NtkReadRangesUser
(
Cba_BoxNtk
(
p
,
iObj
),
vRanges
,
1
);
else
if
(
Cba_BoxNtkId
(
p
,
iObj
)
)
Cba_NtkReadRangesPrim
(
Cba_BoxNtkName
(
p
,
iObj
),
vRanges
,
1
);
else
assert
(
0
);
Cba_ManPrepareBitNames
(
p
,
vMap
,
&
nNames
,
vRanges
,
vNames
);
assert
(
Vec_IntSize
(
vNames
)
==
Cba_BoxBoNum
(
p
,
iObj
)
);
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
k
)
Cba_ObjSetName
(
p
,
iTerm
,
Vec_IntEntry
(
vNames
,
k
)
);
}
// mark PO names
Cba_NtkReadRangesUser
(
p
,
vRanges
,
1
);
Cba_NtkForEachPo
(
p
,
iObj
,
k
)
if
(
Cba_ObjNameType
(
p
,
Cba_ObjFanin
(
p
,
iObj
))
<=
CBA_NAME_WORD
)
// works only if the PIs are before POs
Cba_NtkSetInfoName
(
p
,
n
++
,
Abc_Var2Lit2
(
Cba_ObjNameId
(
p
,
Cba_ObjFanin
(
p
,
iObj
)),
2
)
);
assert
(
n
==
Cba_NtkInfoNum
(
p
)
);
// unmark all names
Cba_NtkForEachPi
(
p
,
iObj
,
k
)
if
(
Cba_ObjNameType
(
p
,
iObj
)
<=
CBA_NAME_WORD
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjName
(
p
,
iObj
),
0
);
Cba_NtkForEachBox
(
p
,
iObj
)
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
k
)
if
(
Cba_ObjNameType
(
p
,
iTerm
)
<=
CBA_NAME_WORD
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjName
(
p
,
iTerm
),
0
);
printf
(
"Generated %d word-level names.
\n
"
,
nNames
-
1
);
// Vec_IntPrint( &p->vName );
// Vec_IntPrint( &p->vInfo );
}
void
Cba_ManAssignInternWordNames
(
Cba_Man_t
*
p
)
{
Vec_Int_t
*
vMap
=
Vec_IntStart
(
Cba_ManObjNum
(
p
)
);
Vec_Int_t
*
vRanges
=
Vec_IntAlloc
(
1000
);
Vec_Int_t
*
vNames
=
Vec_IntAlloc
(
1000
);
Cba_Ntk_t
*
pNtk
;
int
i
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_ManAssignInternWordNamesNtk
(
pNtk
,
vMap
,
vRanges
,
vNames
);
Vec_IntFree
(
vMap
);
Vec_IntFree
(
vRanges
);
Vec_IntFree
(
vNames
);
}
/**Function*************************************************************
Synopsis [Assigns bit-level names.]
Description []
Description []
...
@@ -45,8 +154,10 @@ int Cba_ManSetInternOne( Cba_Ntk_t * p, int iTerm, Vec_Int_t * vMap )
...
@@ -45,8 +154,10 @@ int Cba_ManSetInternOne( Cba_Ntk_t * p, int iTerm, Vec_Int_t * vMap )
{
{
if
(
!
Cba_ObjName
(
p
,
iTerm
)
)
if
(
!
Cba_ObjName
(
p
,
iTerm
)
)
return
1
;
return
1
;
assert
(
Vec_IntEntry
(
vMap
,
Cba_ObjName
(
p
,
iTerm
))
==
0
);
if
(
Cba_ObjNameType
(
p
,
iTerm
)
>
CBA_NAME_WORD
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjName
(
p
,
iTerm
),
iTerm
+
1
);
return
0
;
assert
(
Vec_IntEntry
(
vMap
,
Cba_ObjNameId
(
p
,
iTerm
))
==
0
);
Vec_IntWriteEntry
(
vMap
,
Cba_ObjNameId
(
p
,
iTerm
),
iTerm
+
1
);
return
0
;
return
0
;
}
}
int
Cba_ManAssignInternOne
(
Cba_Ntk_t
*
p
,
int
iTerm
,
Vec_Int_t
*
vMap
)
int
Cba_ManAssignInternOne
(
Cba_Ntk_t
*
p
,
int
iTerm
,
Vec_Int_t
*
vMap
)
...
@@ -59,19 +170,20 @@ int Cba_ManAssignInternOne( Cba_Ntk_t * p, int iTerm, Vec_Int_t * vMap )
...
@@ -59,19 +170,20 @@ int Cba_ManAssignInternOne( Cba_Ntk_t * p, int iTerm, Vec_Int_t * vMap )
{
{
nDigits
=
Abc_Base10Log
(
Cba_NtkObjNum
(
p
)
);
nDigits
=
Abc_Base10Log
(
Cba_NtkObjNum
(
p
)
);
if
(
i
==
0
)
if
(
i
==
0
)
sprintf
(
Buffer
,
"%s%0*d"
,
"
_n_
"
,
nDigits
,
iTerm
);
sprintf
(
Buffer
,
"%s%0*d"
,
"
n
"
,
nDigits
,
iTerm
);
else
else
sprintf
(
Buffer
,
"%s%0*d_%d"
,
"
_n_
"
,
nDigits
,
iTerm
,
++
i
);
sprintf
(
Buffer
,
"%s%0*d_%d"
,
"
n
"
,
nDigits
,
iTerm
,
++
i
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pStrs
,
Buffer
,
NULL
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pDesign
->
pStrs
,
Buffer
,
NULL
);
}
}
while
(
Vec_IntEntry
(
vMap
,
NameId
)
);
while
(
Vec_IntEntry
(
vMap
,
NameId
)
);
Cba_ObjSetName
(
p
,
iTerm
,
NameId
);
Cba_ObjSetName
(
p
,
iTerm
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
+
1
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
+
1
);
return
1
;
return
1
;
}
}
void
Cba_ManAssignInternNamesNtk
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vMap
)
void
Cba_ManAssignInternNamesNtk
(
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vMap
)
{
{
int
i
,
iObj
,
iTerm
,
nNameless
=
0
;
int
i
,
iObj
,
iTerm
,
nNameless
=
0
;
// Vec_IntPrint( &p->vName );
if
(
!
Cba_NtkHasNames
(
p
)
)
if
(
!
Cba_NtkHasNames
(
p
)
)
Cba_NtkStartNames
(
p
);
Cba_NtkStartNames
(
p
);
// set all names
// set all names
...
@@ -95,10 +207,12 @@ void Cba_ManAssignInternNamesNtk( Cba_Ntk_t * p, Vec_Int_t * vMap )
...
@@ -95,10 +207,12 @@ void Cba_ManAssignInternNamesNtk( Cba_Ntk_t * p, Vec_Int_t * vMap )
}
}
// unmark all names
// unmark all names
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjName
(
p
,
iObj
),
0
);
if
(
Cba_ObjNameType
(
p
,
iObj
)
<=
CBA_NAME_WORD
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjNameId
(
p
,
iObj
),
0
);
Cba_NtkForEachBox
(
p
,
iObj
)
Cba_NtkForEachBox
(
p
,
iObj
)
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
i
)
Cba_BoxForEachBo
(
p
,
iObj
,
iTerm
,
i
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjName
(
p
,
iTerm
),
0
);
if
(
Cba_ObjNameType
(
p
,
iTerm
)
<=
CBA_NAME_WORD
)
Vec_IntWriteEntry
(
vMap
,
Cba_ObjNameId
(
p
,
iTerm
),
0
);
}
}
void
Cba_ManAssignInternNames
(
Cba_Man_t
*
p
)
void
Cba_ManAssignInternNames
(
Cba_Man_t
*
p
)
{
{
...
...
src/base/cba/cbaPrsBuild.c
View file @
d6157c75
...
@@ -186,7 +186,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -186,7 +186,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
printf
(
"Primary inputs %d and %d have the same name.
\n
"
,
Vec_IntEntry
(
vMap
,
NameId
),
i
);
printf
(
"Primary inputs %d and %d have the same name.
\n
"
,
Vec_IntEntry
(
vMap
,
NameId
),
i
);
iObj
=
Cba_ObjAlloc
(
pNew
,
CBA_OBJ_PI
,
-
1
);
iObj
=
Cba_ObjAlloc
(
pNew
,
CBA_OBJ_PI
,
-
1
);
Cba_ObjSetName
(
pNew
,
iObj
,
NameId
);
Cba_ObjSetName
(
pNew
,
iObj
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iObj
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iObj
);
}
}
// create box outputs
// create box outputs
...
@@ -198,20 +198,20 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -198,20 +198,20 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
if
(
pNtkBox
==
NULL
)
if
(
pNtkBox
==
NULL
)
{
{
iObj
=
Cba_BoxAlloc
(
pNew
,
CBA_BOX_GATE
,
Vec_IntSize
(
vSigs
)
/
2
-
1
,
1
,
Prs_BoxNtk
(
pNtk
,
iBox
)
+
1
);
// +1 to map NtkId into gate name
iObj
=
Cba_BoxAlloc
(
pNew
,
CBA_BOX_GATE
,
Vec_IntSize
(
vSigs
)
/
2
-
1
,
1
,
Prs_BoxNtk
(
pNtk
,
iBox
)
+
1
);
// +1 to map NtkId into gate name
Cba_ObjSetName
(
pNew
,
iObj
,
Prs_BoxName
(
pNtk
,
iBox
)
);
Cba_ObjSetName
(
pNew
,
iObj
,
Abc_Var2Lit2
(
Prs_BoxName
(
pNtk
,
iBox
),
CBA_NAME_BIN
)
);
// consider box output
// consider box output
NameId
=
Vec_IntEntryLast
(
vSigs
);
NameId
=
Vec_IntEntryLast
(
vSigs
);
NameId
=
Prs_NtkSigName
(
pNtk
,
NameId
);
NameId
=
Prs_NtkSigName
(
pNtk
,
NameId
);
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
printf
(
"Box output name %d is already driven.
\n
"
,
NameId
);
printf
(
"Box output name %d is already driven.
\n
"
,
NameId
);
iTerm
=
Cba_BoxBo
(
pNew
,
iObj
,
0
);
iTerm
=
Cba_BoxBo
(
pNew
,
iObj
,
0
);
Cba_ObjSetName
(
pNew
,
iTerm
,
NameId
);
Cba_ObjSetName
(
pNew
,
iTerm
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
);
}
}
else
else
{
{
iObj
=
Cba_BoxAlloc
(
pNew
,
CBA_OBJ_BOX
,
Prs_NtkPiNum
(
pNtkBox
),
Prs_NtkPoNum
(
pNtkBox
),
Prs_BoxNtk
(
pNtk
,
iBox
)
);
iObj
=
Cba_BoxAlloc
(
pNew
,
CBA_OBJ_BOX
,
Prs_NtkPiNum
(
pNtkBox
),
Prs_NtkPoNum
(
pNtkBox
),
Prs_BoxNtk
(
pNtk
,
iBox
)
);
Cba_ObjSetName
(
pNew
,
iObj
,
Prs_BoxName
(
pNtk
,
iBox
)
);
Cba_ObjSetName
(
pNew
,
iObj
,
Abc_Var2Lit2
(
Prs_BoxName
(
pNtk
,
iBox
),
CBA_NAME_BIN
)
);
Cba_NtkSetHost
(
Cba_ManNtk
(
pNew
->
pDesign
,
Prs_BoxNtk
(
pNtk
,
iBox
)),
Cba_NtkId
(
pNew
),
iObj
);
Cba_NtkSetHost
(
Cba_ManNtk
(
pNew
->
pDesign
,
Prs_BoxNtk
(
pNtk
,
iBox
)),
Cba_NtkId
(
pNew
),
iObj
);
Vec_IntForEachEntry
(
vSigs
,
Index
,
i
)
Vec_IntForEachEntry
(
vSigs
,
Index
,
i
)
{
{
...
@@ -225,7 +225,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -225,7 +225,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
printf
(
"Box output name %d is already driven.
\n
"
,
NameId
);
printf
(
"Box output name %d is already driven.
\n
"
,
NameId
);
iTerm
=
Cba_BoxBo
(
pNew
,
iObj
,
Index
-
Prs_NtkPiNum
(
pNtkBox
)
);
iTerm
=
Cba_BoxBo
(
pNew
,
iObj
,
Index
-
Prs_NtkPiNum
(
pNtkBox
)
);
Cba_ObjSetName
(
pNew
,
iTerm
,
NameId
);
Cba_ObjSetName
(
pNew
,
iTerm
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
);
}
}
}
}
...
@@ -241,7 +241,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -241,7 +241,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
printf
(
"Node output name %d is already driven.
\n
"
,
NameId
);
printf
(
"Node output name %d is already driven.
\n
"
,
NameId
);
iTerm
=
Cba_BoxBo
(
pNew
,
iObj
,
0
);
iTerm
=
Cba_BoxBo
(
pNew
,
iObj
,
0
);
Cba_ObjSetName
(
pNew
,
iTerm
,
NameId
);
Cba_ObjSetName
(
pNew
,
iTerm
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
);
Vec_IntWriteEntry
(
vMap
,
NameId
,
iTerm
);
// remember box
// remember box
Vec_IntPush
(
vBoxes
,
iObj
);
Vec_IntPush
(
vBoxes
,
iObj
);
...
@@ -269,7 +269,6 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -269,7 +269,6 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
nNonDriven
++
;
nNonDriven
++
;
}
}
Cba_ObjSetFanin
(
pNew
,
iTerm
,
Vec_IntEntry
(
vMap
,
NameId
)
);
Cba_ObjSetFanin
(
pNew
,
iTerm
,
Vec_IntEntry
(
vMap
,
NameId
)
);
//Cba_ObjSetName( pNew, iTerm, NameId );
}
}
}
}
else
else
...
@@ -291,7 +290,6 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -291,7 +290,6 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
nNonDriven
++
;
nNonDriven
++
;
}
}
Cba_ObjSetFanin
(
pNew
,
iTerm
,
Vec_IntEntry
(
vMap
,
NameId
)
);
Cba_ObjSetFanin
(
pNew
,
iTerm
,
Vec_IntEntry
(
vMap
,
NameId
)
);
//Cba_ObjSetName( pNew, iTerm, NameId );
}
}
}
}
}
}
...
@@ -312,7 +310,6 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -312,7 +310,6 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
nNonDriven
++
;
nNonDriven
++
;
}
}
Cba_ObjSetFanin
(
pNew
,
iTerm
,
Vec_IntEntry
(
vMap
,
NameId
)
);
Cba_ObjSetFanin
(
pNew
,
iTerm
,
Vec_IntEntry
(
vMap
,
NameId
)
);
//Cba_ObjSetName( pNew, iTerm, NameId );
}
}
}
}
// add fanins for primary outputs
// add fanins for primary outputs
...
@@ -326,13 +323,13 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
...
@@ -326,13 +323,13 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
nNonDriven
++
;
nNonDriven
++
;
}
}
Prs_NtkForEachPo
(
pNtk
,
NameId
,
i
)
Prs_NtkForEachPo
(
pNtk
,
NameId
,
i
)
{
iObj
=
Cba_ObjAlloc
(
pNew
,
CBA_OBJ_PO
,
Vec_IntEntry
(
vMap
,
NameId
)
);
iObj
=
Cba_ObjAlloc
(
pNew
,
CBA_OBJ_PO
,
Vec_IntEntry
(
vMap
,
NameId
)
);
//Cba_ObjSetName( pNew, iObj, NameId );
}
if
(
nNonDriven
)
if
(
nNonDriven
)
printf
(
"Module %s has %d non-driven nets (for example, %s).
\n
"
,
Prs_NtkName
(
pNtk
),
nNonDriven
,
Prs_NtkStr
(
pNtk
,
iNonDriven
)
);
printf
(
"Module %s has %d non-driven nets (for example, %s).
\n
"
,
Prs_NtkName
(
pNtk
),
nNonDriven
,
Prs_NtkStr
(
pNtk
,
iNonDriven
)
);
Prs_ManCleanMap
(
pNtk
,
vMap
);
Prs_ManCleanMap
(
pNtk
,
vMap
);
// setup info
Vec_IntForEachEntry
(
&
pNtk
->
vOrder
,
NameId
,
i
)
Cba_NtkAddInfo
(
pNew
,
NameId
,
-
1
,
-
1
);
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -364,6 +361,7 @@ Cba_Man_t * Prs_ManBuildCba( char * pFileName, Vec_Ptr_t * vDes )
...
@@ -364,6 +361,7 @@ Cba_Man_t * Prs_ManBuildCba( char * pFileName, Vec_Ptr_t * vDes )
assert
(
Vec_IntCountEntry
(
vMap
,
-
1
)
==
Vec_IntSize
(
vMap
)
);
assert
(
Vec_IntCountEntry
(
vMap
,
-
1
)
==
Vec_IntSize
(
vMap
)
);
Vec_IntFree
(
vMap
);
Vec_IntFree
(
vMap
);
Vec_IntFree
(
vTmp
);
Vec_IntFree
(
vTmp
);
// Vec_StrPrint( &Cba_ManNtk(pNew, 0)->vType, 1 );
return
pNew
;
return
pNew
;
}
}
...
...
src/base/cba/cbaPtrAbc.c
View file @
d6157c75
...
@@ -290,8 +290,9 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
...
@@ -290,8 +290,9 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
!=
-
1
)
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
!=
-
1
)
{
printf
(
"PI with name
\"
%s
\"
is not unique module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
return
0
;
}
{
printf
(
"PI with name
\"
%s
\"
is not unique module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
return
0
;
}
iObj
=
Cba_ObjAlloc
(
pNtk
,
CBA_OBJ_PI
,
-
1
);
iObj
=
Cba_ObjAlloc
(
pNtk
,
CBA_OBJ_PI
,
-
1
);
Cba_ObjSetName
(
pNtk
,
iObj
,
NameId
);
Cba_ObjSetName
(
pNtk
,
iObj
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntSetEntryFull
(
vMap
,
NameId
,
iObj
);
Vec_IntSetEntryFull
(
vMap
,
NameId
,
iObj
);
Cba_NtkAddInfo
(
pNtk
,
Abc_Var2Lit2
(
NameId
,
1
),
-
1
,
-
1
);
}
}
// map driven NameIds into their ObjIds for BOs
// map driven NameIds into their ObjIds for BOs
Vec_IntClear
(
vBox2Id
);
Vec_IntClear
(
vBox2Id
);
...
@@ -307,14 +308,14 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
...
@@ -307,14 +308,14 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
iObj
=
Cba_BoxAlloc
(
pNtk
,
Ptr_NameToType
(
pBoxNtk
),
nInputs
,
nOutputs
,
NtkId
);
iObj
=
Cba_BoxAlloc
(
pNtk
,
Ptr_NameToType
(
pBoxNtk
),
nInputs
,
nOutputs
,
NtkId
);
if
(
NtkId
>=
0
)
if
(
NtkId
>=
0
)
Cba_NtkSetHost
(
Cba_ManNtk
(
pNtk
->
pDesign
,
NtkId
),
Cba_NtkId
(
pNtk
),
iObj
);
Cba_NtkSetHost
(
Cba_ManNtk
(
pNtk
->
pDesign
,
NtkId
),
Cba_NtkId
(
pNtk
),
iObj
);
Cba_ObjSetName
(
pNtk
,
iObj
,
Abc_
NamStrFindOrAdd
(
pNtk
->
pDesign
->
pStrs
,
pBoxName
,
NULL
)
);
Cba_ObjSetName
(
pNtk
,
iObj
,
Abc_
Var2Lit2
(
Abc_NamStrFindOrAdd
(
pNtk
->
pDesign
->
pStrs
,
pBoxName
,
NULL
),
CBA_NAME_BIN
)
);
Cba_BoxForEachBo
(
pNtk
,
iObj
,
iTerm
,
k
)
Cba_BoxForEachBo
(
pNtk
,
iObj
,
iTerm
,
k
)
{
{
pName
=
(
char
*
)
Vec_PtrEntry
(
vBox
,
Vec_PtrSize
(
vBox
)
-
2
*
(
nOutputs
-
k
)
+
1
);
pName
=
(
char
*
)
Vec_PtrEntry
(
vBox
,
Vec_PtrSize
(
vBox
)
-
2
*
(
nOutputs
-
k
)
+
1
);
NameId
=
Abc_NamStrFindOrAdd
(
pNtk
->
pDesign
->
pStrs
,
pName
,
NULL
);
NameId
=
Abc_NamStrFindOrAdd
(
pNtk
->
pDesign
->
pStrs
,
pName
,
NULL
);
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
!=
-
1
)
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
!=
-
1
)
{
printf
(
"Signal
\"
%s
\"
has multiple drivers in module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
return
0
;
}
{
printf
(
"Signal
\"
%s
\"
has multiple drivers in module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
return
0
;
}
Cba_ObjSetName
(
pNtk
,
iTerm
,
NameId
);
Cba_ObjSetName
(
pNtk
,
iTerm
,
Abc_Var2Lit2
(
NameId
,
CBA_NAME_BIN
)
);
Vec_IntSetEntryFull
(
vMap
,
NameId
,
iTerm
);
Vec_IntSetEntryFull
(
vMap
,
NameId
,
iTerm
);
}
}
Vec_IntPush
(
vBox2Id
,
iObj
);
Vec_IntPush
(
vBox2Id
,
iObj
);
...
@@ -331,7 +332,6 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
...
@@ -331,7 +332,6 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
==
-
1
)
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
==
-
1
)
printf
(
"Signal
\"
%s
\"
in not driven in module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
printf
(
"Signal
\"
%s
\"
in not driven in module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
Cba_ObjSetFanin
(
pNtk
,
iTerm
,
Vec_IntGetEntryFull
(
vMap
,
NameId
)
);
Cba_ObjSetFanin
(
pNtk
,
iTerm
,
Vec_IntGetEntryFull
(
vMap
,
NameId
)
);
//Cba_ObjSetName( pNtk, iTerm, NameId );
}
}
}
}
// connect POs
// connect POs
...
@@ -341,7 +341,7 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
...
@@ -341,7 +341,7 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
==
-
1
)
if
(
Vec_IntGetEntryFull
(
vMap
,
NameId
)
==
-
1
)
printf
(
"PO with name
\"
%s
\"
in not driven in module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
printf
(
"PO with name
\"
%s
\"
in not driven in module
\"
%s
\"
.
\n
"
,
pName
,
pModuleName
);
iObj
=
Cba_ObjAlloc
(
pNtk
,
CBA_OBJ_PO
,
Vec_IntGetEntryFull
(
vMap
,
NameId
)
);
iObj
=
Cba_ObjAlloc
(
pNtk
,
CBA_OBJ_PO
,
Vec_IntGetEntryFull
(
vMap
,
NameId
)
);
//Cba_ObjSetName( pNtk, iObj, NameId
);
Cba_NtkAddInfo
(
pNtk
,
Abc_Var2Lit2
(
NameId
,
2
),
-
1
,
-
1
);
}
}
// update map
// update map
Cba_NtkForEachCi
(
pNtk
,
iObj
)
Cba_NtkForEachCi
(
pNtk
,
iObj
)
...
...
src/base/cba/cbaReadBlif.c
View file @
d6157c75
...
@@ -144,12 +144,15 @@ static inline int Prs_ManReadName( Prs_Man_t * p )
...
@@ -144,12 +144,15 @@ static inline int Prs_ManReadName( Prs_Man_t * p )
return
0
;
return
0
;
return
Abc_NamStrFindOrAddLim
(
p
->
pStrs
,
pStart
,
p
->
pCur
,
NULL
);
return
Abc_NamStrFindOrAddLim
(
p
->
pStrs
,
pStart
,
p
->
pCur
,
NULL
);
}
}
static
inline
int
Prs_ManReadList
(
Prs_Man_t
*
p
)
static
inline
int
Prs_ManReadList
(
Prs_Man_t
*
p
,
Vec_Int_t
*
vOrder
,
int
Type
)
{
{
int
iToken
;
int
iToken
;
Vec_IntClear
(
&
p
->
vTemp
);
Vec_IntClear
(
&
p
->
vTemp
);
while
(
(
iToken
=
Prs_ManReadName
(
p
))
)
while
(
(
iToken
=
Prs_ManReadName
(
p
))
)
{
Vec_IntPush
(
&
p
->
vTemp
,
iToken
);
Vec_IntPush
(
&
p
->
vTemp
,
iToken
);
Vec_IntPush
(
vOrder
,
Abc_Var2Lit2
(
iToken
,
Type
)
);
}
if
(
Vec_IntSize
(
&
p
->
vTemp
)
==
0
)
return
Prs_ManErrorSet
(
p
,
"Signal list is empty."
,
1
);
if
(
Vec_IntSize
(
&
p
->
vTemp
)
==
0
)
return
Prs_ManErrorSet
(
p
,
"Signal list is empty."
,
1
);
return
0
;
return
0
;
}
}
...
@@ -201,7 +204,7 @@ static inline int Prs_ManReadCube( Prs_Man_t * p )
...
@@ -201,7 +204,7 @@ static inline int Prs_ManReadCube( Prs_Man_t * p )
Prs_ManSkipSpaces
(
p
);
Prs_ManSkipSpaces
(
p
);
if
(
Prs_ManIsChar
(
p
,
'\n'
)
)
if
(
Prs_ManIsChar
(
p
,
'\n'
)
)
{
{
if
(
Vec_StrSize
(
&
p
->
vCover
)
!=
1
)
return
Prs_ManErrorSet
(
p
,
"Cannot read cube."
,
1
);
if
(
Vec_StrSize
(
&
p
->
vCover
)
!=
1
)
return
Prs_ManErrorSet
(
p
,
"Cannot read cube."
,
1
);
// fix single literal cube by adding space
// fix single literal cube by adding space
Vec_StrPush
(
&
p
->
vCover
,
Vec_StrEntry
(
&
p
->
vCover
,
0
)
);
Vec_StrPush
(
&
p
->
vCover
,
Vec_StrEntry
(
&
p
->
vCover
,
0
)
);
Vec_StrWriteEntry
(
&
p
->
vCover
,
0
,
' '
);
Vec_StrWriteEntry
(
&
p
->
vCover
,
0
,
' '
);
...
@@ -221,7 +224,8 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
...
@@ -221,7 +224,8 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
int
iToken
;
int
iToken
;
assert
(
Vec_StrSize
(
&
p
->
vCover
)
>
0
);
assert
(
Vec_StrSize
(
&
p
->
vCover
)
>
0
);
Vec_StrPush
(
&
p
->
vCover
,
'\0'
);
Vec_StrPush
(
&
p
->
vCover
,
'\0'
);
iToken
=
Abc_NamStrFindOrAdd
(
p
->
pStrs
,
Vec_StrArray
(
&
p
->
vCover
),
NULL
);
//iToken = Abc_NamStrFindOrAdd( p->pStrs, Vec_StrArray(&p->vCover), NULL );
iToken
=
Ptr_SopToType
(
Vec_StrArray
(
&
p
->
vCover
)
);
Vec_StrClear
(
&
p
->
vCover
);
Vec_StrClear
(
&
p
->
vCover
);
// set the cover to the module of this box
// set the cover to the module of this box
assert
(
Prs_BoxNtk
(
p
->
pNtk
,
Prs_NtkBoxNum
(
p
->
pNtk
)
-
1
)
==
1
);
// default const 0
assert
(
Prs_BoxNtk
(
p
->
pNtk
,
Prs_NtkBoxNum
(
p
->
pNtk
)
-
1
)
==
1
);
// default const 0
...
@@ -241,19 +245,19 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
...
@@ -241,19 +245,19 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
***********************************************************************/
***********************************************************************/
static
inline
int
Prs_ManReadInouts
(
Prs_Man_t
*
p
)
static
inline
int
Prs_ManReadInouts
(
Prs_Man_t
*
p
)
{
{
if
(
Prs_ManReadList
(
p
)
)
return
1
;
if
(
Prs_ManReadList
(
p
,
&
p
->
pNtk
->
vOrder
,
3
)
)
return
1
;
Vec_IntAppend
(
&
p
->
pNtk
->
vInouts
,
&
p
->
vTemp
);
Vec_IntAppend
(
&
p
->
pNtk
->
vInouts
,
&
p
->
vTemp
);
return
0
;
return
0
;
}
}
static
inline
int
Prs_ManReadInputs
(
Prs_Man_t
*
p
)
static
inline
int
Prs_ManReadInputs
(
Prs_Man_t
*
p
)
{
{
if
(
Prs_ManReadList
(
p
)
)
return
1
;
if
(
Prs_ManReadList
(
p
,
&
p
->
pNtk
->
vOrder
,
1
)
)
return
1
;
Vec_IntAppend
(
&
p
->
pNtk
->
vInputs
,
&
p
->
vTemp
);
Vec_IntAppend
(
&
p
->
pNtk
->
vInputs
,
&
p
->
vTemp
);
return
0
;
return
0
;
}
}
static
inline
int
Prs_ManReadOutputs
(
Prs_Man_t
*
p
)
static
inline
int
Prs_ManReadOutputs
(
Prs_Man_t
*
p
)
{
{
if
(
Prs_ManReadList
(
p
)
)
return
1
;
if
(
Prs_ManReadList
(
p
,
&
p
->
pNtk
->
vOrder
,
2
)
)
return
1
;
Vec_IntAppend
(
&
p
->
pNtk
->
vOutputs
,
&
p
->
vTemp
);
Vec_IntAppend
(
&
p
->
pNtk
->
vOutputs
,
&
p
->
vTemp
);
return
0
;
return
0
;
}
}
...
...
src/base/cba/cbaReadVer.c
View file @
d6157c75
...
@@ -30,11 +30,11 @@ ABC_NAMESPACE_IMPL_START
...
@@ -30,11 +30,11 @@ ABC_NAMESPACE_IMPL_START
// Verilog keywords
// Verilog keywords
typedef
enum
{
typedef
enum
{
PRS_VER_NONE
=
0
,
// 0: unused
PRS_VER_NONE
=
0
,
// 0: unused
PRS_VER_
MODULE
,
// 1: module
PRS_VER_
INPUT
,
// 1: input
PRS_VER_
INOUT
,
// 2: ino
ut
PRS_VER_
OUTPUT
,
// 2: outp
ut
PRS_VER_IN
PUT
,
// 3: inp
ut
PRS_VER_IN
OUT
,
// 3: ino
ut
PRS_VER_
OUTPUT
,
// 4: output
PRS_VER_
WIRE
,
// 4: wire
PRS_VER_
WIRE
,
// 5: wir
e
PRS_VER_
MODULE
,
// 5: modul
e
PRS_VER_ASSIGN
,
// 6: assign
PRS_VER_ASSIGN
,
// 6: assign
PRS_VER_REG
,
// 7: reg
PRS_VER_REG
,
// 7: reg
PRS_VER_ALWAYS
,
// 8: always
PRS_VER_ALWAYS
,
// 8: always
...
@@ -47,11 +47,11 @@ typedef enum {
...
@@ -47,11 +47,11 @@ typedef enum {
const
char
*
s_VerTypes
[
PRS_VER_UNKNOWN
+
1
]
=
{
const
char
*
s_VerTypes
[
PRS_VER_UNKNOWN
+
1
]
=
{
NULL
,
// 0: unused
NULL
,
// 0: unused
"
module"
,
// 1: module
"
input"
,
// 1: input
"
inout"
,
// 2: ino
ut
"
output"
,
// 2: outp
ut
"in
put"
,
// 3: inp
ut
"in
out"
,
// 3: ino
ut
"
output"
,
// 4: output
"
wire"
,
// 4: wire
"
wire"
,
// 5: wir
e
"
module"
,
// 5: modul
e
"assign"
,
// 6: assign
"assign"
,
// 6: assign
"reg"
,
// 7: reg
"reg"
,
// 7: reg
"always"
,
// 8: always
"always"
,
// 8: always
...
@@ -476,17 +476,19 @@ static inline int Prs_ManReadSignalList2( Prs_Man_t * p, Vec_Int_t * vTemp )
...
@@ -476,17 +476,19 @@ static inline int Prs_ManReadSignalList2( Prs_Man_t * p, Vec_Int_t * vTemp )
***********************************************************************/
***********************************************************************/
static
inline
int
Prs_ManReadDeclaration
(
Prs_Man_t
*
p
,
int
Type
)
static
inline
int
Prs_ManReadDeclaration
(
Prs_Man_t
*
p
,
int
Type
)
{
{
int
i
,
Sig
,
RangeId
=
0
;
int
i
,
NameId
,
RangeId
=
0
;
Vec_Int_t
*
v
Sigs
[
4
]
=
{
&
p
->
pNtk
->
vInouts
,
&
p
->
pNtk
->
vInputs
,
&
p
->
pNtk
->
vOutp
uts
,
&
p
->
pNtk
->
vWires
};
Vec_Int_t
*
v
Names
[
4
]
=
{
&
p
->
pNtk
->
vInputs
,
&
p
->
pNtk
->
vOutputs
,
&
p
->
pNtk
->
vIno
uts
,
&
p
->
pNtk
->
vWires
};
Vec_Int_t
*
v
SigsR
[
4
]
=
{
&
p
->
pNtk
->
vInoutsR
,
&
p
->
pNtk
->
vInputsR
,
&
p
->
pNtk
->
vOutp
utsR
,
&
p
->
pNtk
->
vWiresR
};
Vec_Int_t
*
v
NamesR
[
4
]
=
{
&
p
->
pNtk
->
vInputsR
,
&
p
->
pNtk
->
vOutputsR
,
&
p
->
pNtk
->
vIno
utsR
,
&
p
->
pNtk
->
vWiresR
};
assert
(
Type
>=
PRS_VER_IN
O
UT
&&
Type
<=
PRS_VER_WIRE
);
assert
(
Type
>=
PRS_VER_IN
P
UT
&&
Type
<=
PRS_VER_WIRE
);
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
if
(
Prs_ManIsChar
(
p
,
'['
)
&&
!
(
RangeId
=
Prs_ManReadRange
(
p
))
)
return
0
;
if
(
Prs_ManIsChar
(
p
,
'['
)
&&
!
(
RangeId
=
Prs_ManReadRange
(
p
))
)
return
0
;
if
(
!
Prs_ManReadNameList
(
p
,
&
p
->
vTemp
,
';'
)
)
return
0
;
if
(
!
Prs_ManReadNameList
(
p
,
&
p
->
vTemp
,
';'
)
)
return
0
;
Vec_IntForEachEntry
(
&
p
->
vTemp
,
Sig
,
i
)
Vec_IntForEachEntry
(
&
p
->
vTemp
,
NameId
,
i
)
{
{
Vec_IntPush
(
vSigs
[
Type
-
PRS_VER_INOUT
],
Sig
);
Vec_IntPush
(
vNames
[
Type
-
PRS_VER_INPUT
],
NameId
);
Vec_IntPush
(
vSigsR
[
Type
-
PRS_VER_INOUT
],
RangeId
);
Vec_IntPush
(
vNamesR
[
Type
-
PRS_VER_INPUT
],
RangeId
);
if
(
Type
<
PRS_VER_WIRE
)
Vec_IntPush
(
&
p
->
pNtk
->
vOrder
,
Abc_Var2Lit2
(
NameId
,
Type
)
);
}
}
return
1
;
return
1
;
}
}
...
@@ -592,8 +594,8 @@ static inline int Prs_ManReadInstance( Prs_Man_t * p, int Func )
...
@@ -592,8 +594,8 @@ static inline int Prs_ManReadInstance( Prs_Man_t * p, int Func )
static
inline
int
Prs_ManReadArguments
(
Prs_Man_t
*
p
)
static
inline
int
Prs_ManReadArguments
(
Prs_Man_t
*
p
)
{
{
int
iRange
=
0
,
iType
=
-
1
;
int
iRange
=
0
,
iType
=
-
1
;
Vec_Int_t
*
vSigs
[
3
]
=
{
&
p
->
pNtk
->
vIn
outs
,
&
p
->
pNtk
->
vInputs
,
&
p
->
pNtk
->
vOutputs
};
Vec_Int_t
*
vSigs
[
3
]
=
{
&
p
->
pNtk
->
vIn
puts
,
&
p
->
pNtk
->
vOutputs
,
&
p
->
pNtk
->
vInouts
};
Vec_Int_t
*
vSigsR
[
3
]
=
{
&
p
->
pNtk
->
vIn
outsR
,
&
p
->
pNtk
->
vInputsR
,
&
p
->
pNtk
->
vOutp
utsR
};
Vec_Int_t
*
vSigsR
[
3
]
=
{
&
p
->
pNtk
->
vIn
putsR
,
&
p
->
pNtk
->
vOutputsR
,
&
p
->
pNtk
->
vIno
utsR
};
assert
(
Prs_ManIsChar
(
p
,
'('
)
);
assert
(
Prs_ManIsChar
(
p
,
'('
)
);
p
->
pCur
++
;
p
->
pCur
++
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
...
@@ -602,7 +604,7 @@ static inline int Prs_ManReadArguments( Prs_Man_t * p )
...
@@ -602,7 +604,7 @@ static inline int Prs_ManReadArguments( Prs_Man_t * p )
int
iName
=
Prs_ManReadName
(
p
);
int
iName
=
Prs_ManReadName
(
p
);
if
(
iName
==
0
)
return
0
;
if
(
iName
==
0
)
return
0
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
if
(
iName
>=
PRS_VER_IN
OUT
&&
iName
<=
PRS_VER_OUTP
UT
)
// declaration
if
(
iName
>=
PRS_VER_IN
PUT
&&
iName
<=
PRS_VER_INO
UT
)
// declaration
{
{
iType
=
iName
;
iType
=
iName
;
if
(
Prs_ManIsChar
(
p
,
'['
)
)
if
(
Prs_ManIsChar
(
p
,
'['
)
)
...
@@ -611,13 +613,15 @@ static inline int Prs_ManReadArguments( Prs_Man_t * p )
...
@@ -611,13 +613,15 @@ static inline int Prs_ManReadArguments( Prs_Man_t * p )
if
(
iRange
==
0
)
return
0
;
if
(
iRange
==
0
)
return
0
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
if
(
Prs_ManUtilSkipSpaces
(
p
)
)
return
0
;
}
}
iName
=
Prs_ManReadName
(
p
);
if
(
iName
==
0
)
return
0
;
}
}
if
(
iType
>
0
)
if
(
iType
>
0
)
{
{
Vec_IntPush
(
vSigs
[
iType
-
PRS_VER_INOUT
],
iName
);
Vec_IntPush
(
vSigs
[
iType
-
PRS_VER_INPUT
],
iName
);
Vec_IntPush
(
vSigsR
[
iType
-
PRS_VER_INOUT
],
iRange
);
Vec_IntPush
(
vSigsR
[
iType
-
PRS_VER_INPUT
],
iRange
);
Vec_IntPush
(
&
p
->
pNtk
->
vOrder
,
Abc_Var2Lit2
(
iName
,
iType
)
);
}
}
Vec_IntPush
(
&
p
->
pNtk
->
vOrder
,
iName
);
if
(
Prs_ManIsChar
(
p
,
')'
)
)
if
(
Prs_ManIsChar
(
p
,
')'
)
)
break
;
break
;
if
(
!
Prs_ManIsChar
(
p
,
','
)
)
return
Prs_ManErrorSet
(
p
,
"Expecting comma in the instance."
,
0
);
if
(
!
Prs_ManIsChar
(
p
,
','
)
)
return
Prs_ManErrorSet
(
p
,
"Expecting comma in the instance."
,
0
);
...
@@ -673,7 +677,7 @@ static inline int Prs_ManReadModule( Prs_Man_t * p )
...
@@ -673,7 +677,7 @@ static inline int Prs_ManReadModule( Prs_Man_t * p )
Prs_ManFinalizeNtk
(
p
);
Prs_ManFinalizeNtk
(
p
);
return
1
;
return
1
;
}
}
if
(
iToken
>=
PRS_VER_IN
O
UT
&&
iToken
<=
PRS_VER_WIRE
)
// declaration
if
(
iToken
>=
PRS_VER_IN
P
UT
&&
iToken
<=
PRS_VER_WIRE
)
// declaration
Status
=
Prs_ManReadDeclaration
(
p
,
iToken
);
Status
=
Prs_ManReadDeclaration
(
p
,
iToken
);
else
if
(
iToken
==
PRS_VER_REG
||
iToken
==
PRS_VER_DEFPARAM
)
// unsupported keywords
else
if
(
iToken
==
PRS_VER_REG
||
iToken
==
PRS_VER_DEFPARAM
)
// unsupported keywords
Status
=
Prs_ManUtilSkipUntil
(
p
,
';'
);
Status
=
Prs_ManUtilSkipUntil
(
p
,
';'
);
...
...
src/base/cba/cbaWriteVer.c
View file @
d6157c75
This diff is collapsed.
Click to expand it.
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