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
6a4e94e7
Commit
6a4e94e7
authored
Aug 09, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to Cba data-structure.
parent
356217ef
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
32 deletions
+58
-32
src/base/cba/cba.h
+0
-0
src/base/cba/cbaNtk.c
+3
-3
src/base/cba/cbaPrs.h
+8
-10
src/base/cba/cbaReadBlif.c
+1
-1
src/base/cba/cbaReadVer.c
+0
-0
src/base/cba/cbaWriteVer.c
+28
-10
src/misc/util/utilNam.c
+2
-6
src/misc/vec/vecHash.h
+16
-2
No files found.
src/base/cba/cba.h
View file @
6a4e94e7
This diff is collapsed.
Click to expand it.
src/base/cba/cbaNtk.c
View file @
6a4e94e7
...
...
@@ -489,7 +489,7 @@ void Cba_NtkCollapse_rec( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vSigs, in
}
Cba_Man_t
*
Cba_ManCollapse
(
Cba_Man_t
*
p
,
int
TypeBuf
)
{
Cba_Man_t
*
pNew
=
Cba_ManAlloc
(
p
->
pSpec
,
1
,
Abc_NamRef
(
p
->
pStrs
),
Abc_NamRef
(
p
->
pFuns
),
Abc_NamStart
(
100
,
24
)
);
Cba_Man_t
*
pNew
=
Cba_ManAlloc
(
p
->
pSpec
,
1
,
Abc_NamRef
(
p
->
pStrs
),
Abc_NamRef
(
p
->
pFuns
),
Abc_NamStart
(
100
,
24
)
,
Hash_IntManRef
(
p
->
vHash
)
);
Cba_Ntk_t
*
pRoot
=
Cba_ManRoot
(
p
),
*
pRootNew
;
Vec_Int_t
*
vSigs
=
Vec_IntAlloc
(
1000
);
int
i
,
iObj
,
iObjNew
,
iFon
,
nObjs
=
0
,
nFins
=
0
,
nFons
=
0
;
...
...
@@ -660,7 +660,7 @@ void Cba_ManExtractGroupInt( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vObjs,
}
Cba_Man_t
*
Cba_ManExtractGroup
(
Cba_Man_t
*
p
,
Vec_Int_t
*
vObjs
)
{
Cba_Man_t
*
pNew
=
Cba_ManAlloc
(
p
->
pSpec
,
1
,
Abc_NamRef
(
p
->
pStrs
),
Abc_NamRef
(
p
->
pFuns
),
Abc_NamStart
(
100
,
24
)
);
Cba_Man_t
*
pNew
=
Cba_ManAlloc
(
p
->
pSpec
,
1
,
Abc_NamRef
(
p
->
pStrs
),
Abc_NamRef
(
p
->
pFuns
),
Abc_NamStart
(
100
,
24
)
,
Hash_IntManRef
(
p
->
vHash
)
);
Cba_Ntk_t
*
pRoot
=
Cba_ManRoot
(
p
),
*
pRootNew
;
Vec_Int_t
*
vFonIns
=
Cba_NtkCollectInFons
(
pRoot
,
vObjs
);
Vec_Int_t
*
vFonOuts
=
Cba_NtkCollectOutFons
(
pRoot
,
vObjs
);
...
...
@@ -743,7 +743,7 @@ static inline int Cba_NtkInsertGiaObj( Cba_Ntk_t * p, Gia_Man_t * pGia, int iObj
}
Cba_Man_t
*
Cba_ManDeriveFromGia
(
Gia_Man_t
*
pGia
)
{
Cba_Man_t
*
p
=
Cba_ManAlloc
(
pGia
->
pSpec
,
1
,
NULL
,
NULL
,
NULL
);
Cba_Man_t
*
p
=
Cba_ManAlloc
(
pGia
->
pSpec
,
1
,
NULL
,
NULL
,
NULL
,
NULL
);
Cba_Ntk_t
*
pNtk
=
Cba_NtkAlloc
(
p
,
Abc_NamStrFindOrAdd
(
p
->
pStrs
,
pGia
->
pName
,
NULL
),
Gia_ManCiNum
(
pGia
),
Gia_ManCoNum
(
pGia
),
1000
,
2000
,
2000
);
Vec_Int_t
*
vLit2Fon
=
Vec_IntStartFull
(
2
*
Gia_ManObjNum
(
pGia
)
);
int
i
,
iObj
,
iObjNew
,
NameId
,
iLit0
,
iFon0
;
...
...
src/base/cba/cbaPrs.h
View file @
6a4e94e7
...
...
@@ -61,6 +61,7 @@ struct Prs_Ntk_t_
unsigned
fHasCZs
:
1
;
Abc_Nam_t
*
pStrs
;
Abc_Nam_t
*
pFuns
;
Hash_IntMan_t
*
vHash
;
// interface
Vec_Int_t
vOrder
;
// order of signals
// signal names
...
...
@@ -91,6 +92,7 @@ struct Prs_Man_t_
char
*
pCur
;
// current position
Abc_Nam_t
*
pStrs
;
// string manager
Abc_Nam_t
*
pFuns
;
// cover manager
Hash_IntMan_t
*
vHash
;
// variable ranges
Prs_Ntk_t
*
pNtk
;
// current network
Vec_Ptr_t
*
vNtks
;
// input networks
// temporary data
...
...
@@ -188,6 +190,7 @@ static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices )
p
->
pNtk
->
fSlices
=
fSlices
;
p
->
pNtk
->
pStrs
=
Abc_NamRef
(
p
->
pStrs
);
p
->
pNtk
->
pFuns
=
Abc_NamRef
(
p
->
pFuns
);
p
->
pNtk
->
vHash
=
Hash_IntManRef
(
p
->
vHash
);
Vec_PtrPush
(
p
->
vNtks
,
p
->
pNtk
);
}
static
inline
void
Prs_ManFinalizeNtk
(
Prs_Man_t
*
p
)
...
...
@@ -229,16 +232,6 @@ static inline void Prs_NtkAddBox( Prs_Ntk_t * p, int ModName, int InstName, Vec_
Vec_IntPush
(
&
p
->
vBoxes
,
InstName
);
Vec_IntAppend
(
&
p
->
vBoxes
,
vTemp
);
}
// parsing range
static
inline
void
Prs_NtkParseRange
(
Prs_Ntk_t
*
p
,
int
RangeId
,
int
*
pLeft
,
int
*
pRight
)
{
char
*
pRange
=
Prs_NtkStr
(
p
,
RangeId
);
char
*
pPivot
=
strchr
(
pRange
,
':'
);
*
pLeft
=
atoi
(
pRange
+
1
);
*
pRight
=
pPivot
?
atoi
(
pPivot
+
1
)
:
*
pLeft
;
}
static
inline
char
*
Prs_ManLoadFile
(
char
*
pFileName
,
char
**
ppLimit
)
{
char
*
pBuffer
;
...
...
@@ -280,6 +273,8 @@ static inline Prs_Man_t * Prs_ManAlloc( char * pFileName )
p
->
pStrs
=
Abc_NamStart
(
1000
,
24
);
p
->
pFuns
=
Abc_NamStart
(
100
,
24
);
p
->
vNtks
=
Vec_PtrAlloc
(
100
);
p
->
vHash
=
Hash_IntManStart
(
1000
);
// Hash_Int2ManInsert( p->vHash, 0, 0, 0 );
return
p
;
}
...
...
@@ -287,6 +282,7 @@ static inline void Prs_NtkFree( Prs_Ntk_t * p )
{
if
(
p
->
pStrs
)
Abc_NamDeref
(
p
->
pStrs
);
if
(
p
->
pFuns
)
Abc_NamDeref
(
p
->
pFuns
);
if
(
p
->
vHash
)
Hash_IntManDeref
(
p
->
vHash
);
Vec_IntErase
(
&
p
->
vOrder
);
Vec_IntErase
(
&
p
->
vInouts
);
Vec_IntErase
(
&
p
->
vInputs
);
...
...
@@ -315,6 +311,7 @@ static inline void Prs_ManFree( Prs_Man_t * p )
{
if
(
p
->
pStrs
)
Abc_NamDeref
(
p
->
pStrs
);
if
(
p
->
pFuns
)
Abc_NamDeref
(
p
->
pFuns
);
if
(
p
->
vHash
)
Hash_IntManDeref
(
p
->
vHash
);
if
(
p
->
vNtks
)
Prs_ManVecFree
(
p
->
vNtks
);
// temporary
Vec_StrErase
(
&
p
->
vCover
);
...
...
@@ -424,6 +421,7 @@ static inline char * Ptr_TypeToName( Cba_ObjType_t Type )
if
(
Type
==
CBA_BOX_MAJ
)
return
"maj"
;
if
(
Type
==
CBA_BOX_SHARP
)
return
"sharp"
;
if
(
Type
==
CBA_BOX_SHARPL
)
return
"sharpl"
;
if
(
Type
==
CBA_BOX_TRI
)
return
"bufifl"
;
assert
(
0
);
return
"???"
;
}
...
...
src/base/cba/cbaReadBlif.c
View file @
6a4e94e7
...
...
@@ -592,7 +592,7 @@ Cba_Man_t * Prs_ManBuildCbaBlif( char * pFileName, Vec_Ptr_t * vDes )
Abc_Nam_t
*
pStrs
=
Abc_NamRef
(
pPrsRoot
->
pStrs
);
Abc_Nam_t
*
pFuns
=
Abc_NamRef
(
pPrsRoot
->
pFuns
);
Abc_Nam_t
*
pMods
=
Abc_NamStart
(
100
,
24
);
Cba_Man_t
*
p
=
Cba_ManAlloc
(
pFileName
,
Vec_PtrSize
(
vDes
),
pStrs
,
pFuns
,
pMods
);
Cba_Man_t
*
p
=
Cba_ManAlloc
(
pFileName
,
Vec_PtrSize
(
vDes
),
pStrs
,
pFuns
,
pMods
,
NULL
);
// initialize networks
Vec_PtrForEachEntry
(
Prs_Ntk_t
*
,
vDes
,
pPrsNtk
,
i
)
{
...
...
src/base/cba/cbaReadVer.c
View file @
6a4e94e7
This diff is collapsed.
Click to expand it.
src/base/cba/cbaWriteVer.c
View file @
6a4e94e7
...
...
@@ -112,6 +112,7 @@ static void Prs_ManWriteVerilogBoxes( FILE * pFile, Prs_Ntk_t * p )
Prs_NtkForEachBox
(
p
,
vBox
,
i
)
{
Cba_ObjType_t
NtkId
=
Prs_BoxNtk
(
p
,
i
);
char
*
pNtkName
=
Prs_NtkStr
(
p
,
Prs_BoxName
(
p
,
i
));
if
(
NtkId
==
CBA_BOX_MUX
)
Prs_ManWriteVerilogMux
(
pFile
,
p
,
vBox
);
else
if
(
Prs_BoxIsNode
(
p
,
i
)
)
// node ------- check order of fanins
...
...
@@ -304,16 +305,31 @@ char * Cba_FonGetName( Cba_Ntk_t * p, int i )
char
*
pName
=
Cba_FonNameStr
(
p
,
i
);
if
(
pName
==
NULL
)
return
pName
;
if
(
Cba_ObjType
(
p
,
Cba_FonObj
(
p
,
i
))
==
CBA_BOX_SLICE
)
return
pName
;
if
(
Cba_NameIsLegalInVerilog
(
pName
)
)
return
pName
;
return
Vec_StrPrintF
(
Abc_NamBuffer
(
Cba_NtkNam
(
p
)),
"
\\
%s "
,
pName
);
}
char
*
Cba_ManGetSliceName
(
Cba_Ntk_t
*
p
,
int
iFon
,
int
Left
,
int
Right
)
{
char
*
pName
=
Cba_FonNameStr
(
p
,
iFon
);
if
(
Cba_NameIsLegalInVerilog
(
pName
)
)
if
(
Left
==
Right
)
return
Vec_StrPrintF
(
Abc_NamBuffer
(
Cba_NtkNam
(
p
)),
"%s[%d]"
,
pName
,
Right
);
else
return
Vec_StrPrintF
(
Abc_NamBuffer
(
Cba_NtkNam
(
p
)),
"%s[%d:%d]"
,
pName
,
Left
,
Right
);
else
if
(
Left
==
Right
)
return
Vec_StrPrintF
(
Abc_NamBuffer
(
Cba_NtkNam
(
p
)),
"
\\
%s [%d]"
,
pName
,
Right
);
else
return
Vec_StrPrintF
(
Abc_NamBuffer
(
Cba_NtkNam
(
p
)),
"
\\
%s [%d:%d]"
,
pName
,
Left
,
Right
);
}
void
Cba_ManWriteFonRange
(
Cba_Ntk_t
*
p
,
int
iFon
)
{
Vec_Str_t
*
vStr
=
&
p
->
pDesign
->
vOut
;
if
(
Cba_FonIsConst
(
iFon
)
||
(
Cba_FonRange
(
p
,
iFon
)
==
1
&&
Cba_FonRight
(
p
,
iFon
)
==
0
)
)
if
(
Cba_FonIsConst
(
iFon
)
||
(
Cba_FonRange
Size
(
p
,
iFon
)
==
1
&&
Cba_FonRight
(
p
,
iFon
)
==
0
)
)
return
;
Vec_StrPrintF
(
vStr
,
"[%d:%d] "
,
Cba_FonLeft
(
p
,
iFon
),
Cba_FonRight
(
p
,
iFon
)
);
...
...
@@ -329,7 +345,7 @@ void Cba_ManWriteFonName( Cba_Ntk_t * p, int iFon, int fInlineConcat, int fInput
Cba_ManWriteCatIn
(
p
,
Cba_FonObj
(
p
,
iFon
)
);
else
{
int
Range
=
fInput
?
Cba_FonRange
(
p
,
iFon
)
:
0
;
int
Range
=
fInput
?
Cba_FonRange
Size
(
p
,
iFon
)
:
0
;
if
(
fInput
&&
Range
>
1
)
Vec_StrPush
(
vStr
,
'{'
);
Vec_StrPrintStr
(
vStr
,
Cba_FonIsConst
(
iFon
)
?
Cba_NtkConst
(
p
,
Cba_FonConst
(
iFon
))
:
Cba_FonGetName
(
p
,
iFon
)
);
...
...
@@ -590,8 +606,8 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
{
int
iFonIn
=
Cba_ObjFinFon
(
p
,
iObj
,
0
);
int
iFonOut
=
Cba_ObjFon0
(
p
,
iObj
);
int
nBitsIn
=
Cba_FonRange
(
p
,
iFonIn
);
int
nBitsOut
=
Cba_FonRange
(
p
,
iFonOut
);
int
nBitsIn
=
Cba_FonRange
Size
(
p
,
iFonIn
);
int
nBitsOut
=
Cba_FonRange
Size
(
p
,
iFonOut
);
assert
(
(
1
<<
nBitsIn
)
==
nBitsOut
);
// function [15:0] res;
Vec_StrPrintStr
(
vStr
,
" function "
);
...
...
@@ -606,12 +622,14 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
// casez (i)
Vec_StrPrintStr
(
vStr
,
" casez(i)
\n
"
);
// 2'b00: res = 4'b0001;
Cba_ObjForEachFinFon
(
p
,
iObj
,
iFin
,
iFon
,
i
)
for
(
i
=
0
;
i
<
(
1
<<
nBitsIn
);
i
++
)
{
Vec_StrPrintF
(
vStr
,
" %d
\'
b: "
,
nBitsIn
);
Vec_StrPrintF
(
vStr
,
" %d
\'
b"
,
nBitsIn
);
for
(
k
=
nBitsIn
-
1
;
k
>=
0
;
k
--
)
Vec_StrPrintNum
(
vStr
,
(
i
>>
k
)
&
1
);
Vec_StrPrintStr
(
vStr
,
": _func_"
);
Cba_ManWriteFonName
(
p
,
iFonOut
,
0
,
0
);
Vec_StrPrintF
(
vStr
,
" = %d
\'
b%*d;
\n
"
,
nBitsOut
,
nBitsOut
,
0
);
Vec_StrPrintF
(
vStr
,
" = %d
\'
b%
0
*d;
\n
"
,
nBitsOut
,
nBitsOut
,
0
);
Vec_StrWriteEntry
(
vStr
,
Vec_StrSize
(
vStr
)
-
i
-
3
,
'1'
);
}
Vec_StrPrintStr
(
vStr
,
" endcase
\n
"
);
...
...
@@ -639,8 +657,8 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
int
iFonSet
=
Cba_ObjFinFon
(
p
,
iObj
,
1
);
int
iFonRst
=
Cba_ObjFinFon
(
p
,
iObj
,
2
);
int
iFonC
=
Cba_ObjFinFon
(
p
,
iObj
,
3
);
int
Range
=
Cba_FonRange
(
p
,
iFonQ
);
assert
(
Cba_FonRange
(
p
,
iFonSet
)
==
1
&&
Cba_FonRang
e
(
p
,
iFonRst
)
==
1
);
int
Range
=
Cba_FonRange
Size
(
p
,
iFonQ
);
assert
(
Cba_FonRange
Size
(
p
,
iFonSet
)
==
1
&&
Cba_FonRangeSiz
e
(
p
,
iFonRst
)
==
1
);
// reg [3:0] Q;
Vec_StrPrintStr
(
vStr
,
" reg "
);
Cba_ManWriteFonRange
(
p
,
iFonQ
);
...
...
src/misc/util/utilNam.c
View file @
6a4e94e7
...
...
@@ -133,13 +133,9 @@ void Abc_NamStop( Abc_Nam_t * p )
***********************************************************************/
void
Abc_NamPrint
(
Abc_Nam_t
*
p
)
{
int
h
,
i
,
Counter
=
0
;
int
h
,
i
;
Vec_IntForEachEntryStart
(
&
p
->
vInt2Handle
,
h
,
i
,
1
)
if
(
Abc_NamHandleToStr
(
p
,
h
)[
0
]
==
'['
)
Abc_Print
(
1
,
"%s "
,
Abc_NamHandleToStr
(
p
,
h
)
),
Counter
++
;
// Abc_Print( 1, "%d=\n%s\n", i, Abc_NamHandleToStr(p, h) );
// Abc_Print( 1, "\n" );
printf
(
" %d
\n
"
,
Counter
);
Abc_Print
(
1
,
"%d=
\n
%s
\n
"
,
i
,
Abc_NamHandleToStr
(
p
,
h
)
);
}
/**Function*************************************************************
...
...
src/misc/vec/vecHash.h
View file @
6a4e94e7
...
...
@@ -53,6 +53,7 @@ struct Hash_IntMan_t_
{
Vec_Int_t
*
vTable
;
// hash table
Vec_Int_t
*
vObjs
;
// hash objects
int
nRefs
;
// reference counter for the manager
};
////////////////////////////////////////////////////////////////////////
...
...
@@ -74,7 +75,7 @@ static inline void Hash_Int2ObjSetData2( Hash_IntMan_t * p, int i, in
/**Function*************************************************************
Synopsis [Hash
ing data entries composed of nSize inte
gers.]
Synopsis [Hash
es pairs of inter
gers.]
Description []
...
...
@@ -90,6 +91,7 @@ static inline Hash_IntMan_t * Hash_IntManStart( int nSize )
p
->
vTable
=
Vec_IntStart
(
Abc_PrimeCudd
(
nSize
)
);
p
->
vObjs
=
Vec_IntAlloc
(
4
*
nSize
);
Vec_IntFill
(
p
->
vObjs
,
4
,
0
);
p
->
nRefs
=
1
;
return
p
;
}
static
inline
void
Hash_IntManStop
(
Hash_IntMan_t
*
p
)
...
...
@@ -98,6 +100,18 @@ static inline void Hash_IntManStop( Hash_IntMan_t * p )
Vec_IntFree
(
p
->
vTable
);
ABC_FREE
(
p
);
}
static
inline
Hash_IntMan_t
*
Hash_IntManRef
(
Hash_IntMan_t
*
p
)
{
p
->
nRefs
++
;
return
p
;
}
static
inline
void
Hash_IntManDeref
(
Hash_IntMan_t
*
p
)
{
if
(
p
==
NULL
)
return
;
if
(
--
p
->
nRefs
==
0
)
Hash_IntManStop
(
p
);
}
static
inline
int
Hash_IntManEntryNum
(
Hash_IntMan_t
*
p
)
{
return
Vec_IntSize
(
p
->
vObjs
)
/
4
-
1
;
...
...
@@ -172,7 +186,7 @@ static inline int Hash_Int2ManInsert( Hash_IntMan_t * p, int iData0, int iData1,
/**Function*************************************************************
Synopsis []
Synopsis [
Hashes triples of intergers.
]
Description []
...
...
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