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
2b2f05ba
Commit
2b2f05ba
authored
Jan 13, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various transformations of Cba_Ntk_t.
parent
ee72b500
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
577 additions
and
111 deletions
+577
-111
src/base/cba/cba.h
+113
-63
src/base/cba/cbaBlast.c
+212
-0
src/base/cba/cbaBuild.c
+80
-45
src/base/cba/cbaNtk.c
+170
-1
src/base/cba/cbaSimple.c
+1
-1
src/base/cba/cbaWriteBlif.c
+1
-1
No files found.
src/base/cba/cba.h
View file @
2b2f05ba
...
...
@@ -46,13 +46,13 @@ ABC_NAMESPACE_HEADER_START
// network objects
typedef
enum
{
CBA_OBJ_NONE
=
0
,
// 0: unused
CBA_OBJ_B
ARBUF
,
// 1: barrier buffer
CBA_OBJ_
PI
,
// 2: in
put
CBA_OBJ_P
O
,
// 3: out
put
CBA_OBJ_P
IO
,
// 4: in
put
CBA_OBJ_
NODE
,
// 5: node
CBA_OBJ_
BOX
,
// 6: box
CBA_OBJ_
PIN
,
// 7: box output
CBA_OBJ_B
I
,
// 1: box input
CBA_OBJ_
BO
,
// 2: box out
put
CBA_OBJ_P
I
,
// 3: in
put
CBA_OBJ_P
O
,
// 4: out
put
CBA_OBJ_
PIO
,
// 5: input
CBA_OBJ_
NODE
,
// 6: node
CBA_OBJ_
BOX
,
// 7: box
CBA_OBJ_LATCH
,
// 8: latch
CBA_OBJ_UNKNOWN
// 9: unknown
}
Cba_ObjType_t
;
...
...
@@ -91,6 +91,11 @@ struct Cba_Man_t_
Vec_Set_t
Mem
;
// memory
Vec_Ptr_t
vNtks
;
// networks
int
iRoot
;
// root network
Vec_Int_t
vCopies
;
// copies
Vec_Int_t
*
vBuf2RootNtk
;
Vec_Int_t
*
vBuf2RootObj
;
Vec_Int_t
*
vBuf2LeafNtk
;
Vec_Int_t
*
vBuf2LeafObj
;
};
// network
...
...
@@ -99,6 +104,11 @@ struct Cba_Ntk_t_
{
char
*
pName
;
// name
Cba_Man_t
*
pDesign
;
// design
int
Id
;
// network ID
int
iBoxNtk
;
// instance network ID
int
iBoxObj
;
// instance object ID
int
nObjs
;
// object counter
int
iObjStart
;
// first object in global order
// interface
Vec_Int_t
vInouts
;
// inouts (used by parser to store signals as NameId)
Vec_Int_t
vInputs
;
// inputs (used by parser to store signals as NameId)
...
...
@@ -106,65 +116,85 @@ struct Cba_Ntk_t_
Vec_Int_t
vWires
;
// wires (used by parser to store signals as NameId)
// objects
Vec_Int_t
vTypes
;
// types (used by parser to store Cba_PrsType_t)
Vec_Int_t
vFuncs
;
// functions (used by parser to store function)
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)
Vec_Int_t
vFuncs
;
// functions (used by parser to store function)
(node: function; box: model; CI/CO: index)
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
Vec_Int_t
vCopies
;
// copy pointers
};
static
inline
char
*
Cba_ManName
(
Cba_Man_t
*
p
)
{
return
p
->
pName
;
}
static
inline
int
Cba_ManNtkNum
(
Cba_Man_t
*
p
)
{
return
Vec_PtrSize
(
&
p
->
vNtks
)
-
1
;
}
static
inline
int
Cba_ManNtkId
(
Cba_Man_t
*
p
,
char
*
pName
)
{
return
Abc_NamStrFind
(
p
->
pModels
,
pName
);
}
static
inline
Cba_Ntk_t
*
Cba_ManNtk
(
Cba_Man_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
(
Cba_Ntk_t
*
)
Vec_PtrEntry
(
&
p
->
vNtks
,
i
);
}
static
inline
Cba_Ntk_t
*
Cba_ManRoot
(
Cba_Man_t
*
p
)
{
return
Cba_ManNtk
(
p
,
p
->
iRoot
);
}
static
inline
Vec_Set_t
*
Cba_ManMem
(
Cba_Man_t
*
p
)
{
return
&
p
->
Mem
;
}
static
inline
int
Cba_ManMemSave
(
Cba_Man_t
*
p
,
int
*
d
,
int
s
)
{
return
Vec_SetAppend
(
Cba_ManMem
(
p
),
d
,
s
);
}
static
inline
int
*
Cba_ManMemRead
(
Cba_Man_t
*
p
,
int
h
)
{
return
h
?
(
int
*
)
Vec_SetEntry
(
Cba_ManMem
(
p
),
h
)
:
NULL
;
}
static
inline
char
*
Cba_NtkName
(
Cba_Ntk_t
*
p
)
{
return
p
->
pName
;
}
static
inline
Cba_Man_t
*
Cba_NtkMan
(
Cba_Ntk_t
*
p
)
{
return
p
->
pDesign
;
}
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_NtkNodeNum
(
Cba_Ntk_t
*
p
)
{
return
Cba_NtkObjNum
(
p
)
-
Cba_NtkPiNum
(
p
)
-
Cba_NtkPoNum
(
p
)
-
Cba_NtkBoxNum
(
p
);
}
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
);
}
static
inline
char
*
Cba_NtkStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Abc_NamStr
(
p
->
pDesign
->
pNames
,
i
);
}
static
inline
char
*
Cba_NtkModelStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Abc_NamStr
(
p
->
pDesign
->
pModels
,
i
);
}
static
inline
char
*
Cba_NtkFuncStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Abc_NamStr
(
p
->
pDesign
->
pFuncs
,
i
);
}
static
inline
Vec_Set_t
*
Cba_NtkMem
(
Cba_Ntk_t
*
p
)
{
return
Cba_ManMem
(
p
->
pDesign
);
}
static
inline
int
Cba_NtkMemSave
(
Cba_Ntk_t
*
p
,
int
*
d
,
int
s
)
{
return
Cba_ManMemSave
(
p
->
pDesign
,
d
,
s
);
}
static
inline
int
*
Cba_NtkMemRead
(
Cba_Ntk_t
*
p
,
int
h
)
{
return
Cba_ManMemRead
(
p
->
pDesign
,
h
);
}
static
inline
Cba_ObjType_t
Cba_ObjType
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vTypes
,
i
);
}
static
inline
int
Cba_ObjIsPi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PI
;
}
static
inline
int
Cba_ObjIsPo
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PO
;
}
static
inline
int
Cba_ObjIsNode
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_NODE
;
}
static
inline
int
Cba_ObjIsBox
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_BOX
;
}
static
inline
int
Cba_ObjIsPin
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PIN
;
}
static
inline
int
Cba_ObjFuncId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vFuncs
,
i
);
}
static
inline
int
Cba_ObjInstId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vInstIds
,
i
);
}
static
inline
int
*
Cba_ObjFaninArray
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkMemRead
(
p
,
Vec_IntEntry
(
&
p
->
vFanins
,
i
));
}
static
inline
int
Cba_ObjFaninNum
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
*
Cba_ObjFaninArray
(
p
,
i
);
}
static
inline
int
*
Cba_ObjFanins
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjFaninArray
(
p
,
i
)
+
1
;
}
static
inline
Vec_Int_t
*
Cba_ObjFaninVec
(
Cba_Ntk_t
*
p
,
int
i
)
{
static
Vec_Int_t
V
;
V
.
pArray
=
Cba_ObjFaninArray
(
p
,
i
);
V
.
nSize
=
V
.
nCap
=
V
.
pArray
?
*
V
.
pArray
++
:
0
;
return
&
V
;
}
static
inline
Vec_Int_t
*
Cba_ObjFaninVec2
(
Cba_Ntk_t
*
p
,
int
i
)
{
static
Vec_Int_t
W
;
W
.
pArray
=
Cba_ObjFaninArray
(
p
,
i
);
W
.
nSize
=
W
.
nCap
=
W
.
pArray
?
*
W
.
pArray
++
:
0
;
return
&
W
;
}
static
inline
Cba_Ntk_t
*
Cba_ObjModel
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsBox
(
p
,
i
));
return
Cba_ManNtk
(
p
->
pDesign
,
Cba_ObjFuncId
(
p
,
i
));
}
static
inline
int
Cba_ObjNameId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vNameIds
,
i
);
}
static
inline
int
Cba_ObjRangeId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vRanges
,
i
);
}
static
inline
int
Cba_ObjCopyId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vCopies
,
i
);
}
static
inline
char
*
Cba_ObjFuncStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjFuncId
(
p
,
i
));
}
static
inline
char
*
Cba_ObjInstStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjInstId
(
p
,
i
));
}
static
inline
char
*
Cba_ObjNameStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjNameId
(
p
,
i
));
}
static
inline
char
*
Cba_ObjRangeStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjRangeId
(
p
,
i
));
}
static
inline
char
*
Cba_ManName
(
Cba_Man_t
*
p
)
{
return
p
->
pName
;
}
static
inline
int
Cba_ManNtkNum
(
Cba_Man_t
*
p
)
{
return
Vec_PtrSize
(
&
p
->
vNtks
)
-
1
;
}
static
inline
int
Cba_ManNtkId
(
Cba_Man_t
*
p
,
char
*
pName
)
{
return
Abc_NamStrFind
(
p
->
pModels
,
pName
);
}
static
inline
Cba_Ntk_t
*
Cba_ManNtk
(
Cba_Man_t
*
p
,
int
i
)
{
assert
(
i
>
0
);
return
(
Cba_Ntk_t
*
)
Vec_PtrEntry
(
&
p
->
vNtks
,
i
);
}
static
inline
Cba_Ntk_t
*
Cba_ManRoot
(
Cba_Man_t
*
p
)
{
return
Cba_ManNtk
(
p
,
p
->
iRoot
);
}
static
inline
Vec_Set_t
*
Cba_ManMem
(
Cba_Man_t
*
p
)
{
return
&
p
->
Mem
;
}
static
inline
int
Cba_ManMemSave
(
Cba_Man_t
*
p
,
int
*
d
,
int
s
)
{
return
Vec_SetAppend
(
Cba_ManMem
(
p
),
d
,
s
);
}
static
inline
int
*
Cba_ManMemRead
(
Cba_Man_t
*
p
,
int
h
)
{
return
h
?
(
int
*
)
Vec_SetEntry
(
Cba_ManMem
(
p
),
h
)
:
NULL
;
}
static
inline
int
Cba_NtkId
(
Cba_Ntk_t
*
p
)
{
return
p
->
Id
;
}
static
inline
char
*
Cba_NtkName
(
Cba_Ntk_t
*
p
)
{
return
p
->
pName
;
}
static
inline
Cba_Man_t
*
Cba_NtkMan
(
Cba_Ntk_t
*
p
)
{
return
p
->
pDesign
;
}
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_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
);
}
static
inline
char
*
Cba_NtkStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Abc_NamStr
(
p
->
pDesign
->
pNames
,
i
);
}
static
inline
char
*
Cba_NtkModelStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Abc_NamStr
(
p
->
pDesign
->
pModels
,
i
);
}
static
inline
char
*
Cba_NtkFuncStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Abc_NamStr
(
p
->
pDesign
->
pFuncs
,
i
);
}
static
inline
Vec_Set_t
*
Cba_NtkMem
(
Cba_Ntk_t
*
p
)
{
return
Cba_ManMem
(
p
->
pDesign
);
}
static
inline
int
Cba_NtkMemSave
(
Cba_Ntk_t
*
p
,
int
*
d
,
int
s
)
{
return
Cba_ManMemSave
(
p
->
pDesign
,
d
,
s
);
}
static
inline
int
*
Cba_NtkMemRead
(
Cba_Ntk_t
*
p
,
int
h
)
{
return
Cba_ManMemRead
(
p
->
pDesign
,
h
);
}
static
inline
Cba_Ntk_t
*
Cba_NtkHost
(
Cba_Ntk_t
*
p
)
{
return
Cba_ManNtk
(
p
->
pDesign
,
p
->
iBoxNtk
);
}
static
inline
void
Cba_NtkSetHost
(
Cba_Ntk_t
*
p
,
int
n
,
int
i
)
{
p
->
iBoxNtk
=
n
;
p
->
iBoxObj
=
i
;
}
static
inline
Vec_Int_t
*
Cba_NtkCopies
(
Cba_Ntk_t
*
p
)
{
return
&
p
->
pDesign
->
vCopies
;
}
static
inline
int
Cba_NtkCopy
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
Cba_NtkCopies
(
p
),
p
->
iObjStart
+
i
);
}
static
inline
void
Cba_NtkSetCopy
(
Cba_Ntk_t
*
p
,
int
i
,
int
x
)
{
Vec_IntWriteEntry
(
Cba_NtkCopies
(
p
),
p
->
iObjStart
+
i
,
x
);
}
static
inline
Cba_ObjType_t
Cba_ObjType
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vTypes
,
i
);
}
static
inline
int
Cba_ObjFuncId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vFuncs
,
i
);
}
static
inline
int
Cba_ObjInstId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vInstIds
,
i
);
}
static
inline
int
Cba_ObjFaninId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vFanins
,
i
);
}
static
inline
int
Cba_ObjNameId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vNameIds
,
i
);
}
static
inline
int
Cba_ObjRangeId
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Vec_IntEntry
(
&
p
->
vRanges
,
i
);
}
static
inline
int
Cba_ObjIsPi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PI
;
}
static
inline
int
Cba_ObjIsPo
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_PO
;
}
static
inline
int
Cba_ObjIsBi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_BI
;
}
static
inline
int
Cba_ObjIsBo
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_BO
;
}
static
inline
int
Cba_ObjIsNode
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_NODE
;
}
static
inline
int
Cba_ObjIsBox
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjType
(
p
,
i
)
==
CBA_OBJ_BOX
;
}
static
inline
int
Cba_ObjIsCi
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjIsPi
(
p
,
i
)
||
Cba_ObjIsBo
(
p
,
i
);
}
static
inline
int
Cba_ObjIsCo
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjIsPo
(
p
,
i
)
||
Cba_ObjIsBi
(
p
,
i
);
}
static
inline
int
Cba_ObjIsCio
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjIsCi
(
p
,
i
)
||
Cba_ObjIsCo
(
p
,
i
);
}
static
inline
int
Cba_ObjIsBio
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjIsBi
(
p
,
i
)
||
Cba_ObjIsBo
(
p
,
i
);
}
static
inline
int
Cba_ObjFanin0
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsPo
(
p
,
i
)
||
Cba_ObjIsBio
(
p
,
i
));
return
Cba_ObjFuncId
(
p
,
i
);
}
static
inline
int
*
Cba_ObjFaninArray
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsNode
(
p
,
i
));
return
Cba_NtkMemRead
(
p
,
Cba_ObjFaninId
(
p
,
i
));
}
static
inline
int
Cba_ObjFaninNum
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
*
Cba_ObjFaninArray
(
p
,
i
);
}
static
inline
int
*
Cba_ObjFanins
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ObjFaninArray
(
p
,
i
)
+
1
;
}
static
inline
Vec_Int_t
*
Cba_ObjFaninVec
(
Cba_Ntk_t
*
p
,
int
i
)
{
static
Vec_Int_t
V
;
V
.
pArray
=
Cba_ObjFaninArray
(
p
,
i
);
V
.
nSize
=
V
.
nCap
=
V
.
pArray
?
*
V
.
pArray
++
:
0
;
return
&
V
;
}
static
inline
Vec_Int_t
*
Cba_ObjFaninVec2
(
Cba_Ntk_t
*
p
,
int
i
)
{
static
Vec_Int_t
W
;
W
.
pArray
=
Cba_ObjFaninArray
(
p
,
i
);
W
.
nSize
=
W
.
nCap
=
W
.
pArray
?
*
W
.
pArray
++
:
0
;
return
&
W
;
}
static
inline
Cba_NodeType_t
Cba_ObjNodeType
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsNode
(
p
,
i
));
return
Cba_ObjFaninId
(
p
,
i
);
}
static
inline
int
Cba_ObjBoxModelId
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsBox
(
p
,
i
));
return
Cba_ObjFuncId
(
p
,
i
);
}
static
inline
Cba_Ntk_t
*
Cba_ObjBoxModel
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsBox
(
p
,
i
));
return
Cba_ManNtk
(
p
->
pDesign
,
Cba_ObjBoxModelId
(
p
,
i
));
}
static
inline
int
Cba_ObjBoxBi
(
Cba_Ntk_t
*
p
,
int
b
,
int
i
)
{
assert
(
Cba_ObjIsBox
(
p
,
i
));
return
b
-
Cba_NtkPiNum
(
Cba_ObjBoxModel
(
p
,
b
))
+
i
;
}
static
inline
int
Cba_ObjBoxBo
(
Cba_Ntk_t
*
p
,
int
b
,
int
i
)
{
assert
(
Cba_ObjIsBox
(
p
,
i
));
return
b
+
1
+
i
;
}
static
inline
int
Cba_ObjBiModelId
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsBi
(
p
,
i
));
while
(
!
Cba_ObjIsBox
(
p
,
i
))
i
++
;
return
Cba_ObjBoxModelId
(
p
,
i
);
}
static
inline
int
Cba_ObjBoModelId
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsBo
(
p
,
i
));
return
Cba_ObjBoxModelId
(
p
,
Cba_ObjFanin0
(
p
,
i
));
}
static
inline
Cba_Ntk_t
*
Cba_ObjBiModel
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManNtk
(
p
->
pDesign
,
Cba_ObjBiModelId
(
p
,
i
)
);
}
static
inline
Cba_Ntk_t
*
Cba_ObjBoModel
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_ManNtk
(
p
->
pDesign
,
Cba_ObjBoModelId
(
p
,
i
)
);
}
static
inline
int
Cba_ObjCioIndex
(
Cba_Ntk_t
*
p
,
int
i
)
{
assert
(
Cba_ObjIsCio
(
p
,
i
)
||
Cba_ObjIsBio
(
p
,
i
));
return
Cba_ObjFuncId
(
p
,
i
);
}
static
inline
char
*
Cba_ObjFuncStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjFuncId
(
p
,
i
));
}
static
inline
char
*
Cba_ObjInstStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjInstId
(
p
,
i
));
}
static
inline
char
*
Cba_ObjNameStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjNameId
(
p
,
i
));
}
static
inline
char
*
Cba_ObjRangeStr
(
Cba_Ntk_t
*
p
,
int
i
)
{
return
Cba_NtkStr
(
p
,
Cba_ObjRangeId
(
p
,
i
));
}
////////////////////////////////////////////////////////////////////////
...
...
@@ -179,9 +209,9 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { re
#define Cba_ManForEachNtk( p, pNtk, i ) \
for ( i = 1; (i <= Cba_ManNtkNum(p)) && (((pNtk) = Cba_ManNtk(p, i)), 1); i++ )
#define Cba_NtkForEachPi( p, iObj, i )
\
#define Cba_NtkForEachPi( p, iObj, i ) \
for ( i = 0; (i < Cba_NtkPiNum(p)) && (((iObj) = Vec_IntEntry(&p->vInputs, i)), 1); i++ )
#define Cba_NtkForEachPo( p, iObj, i )
\
#define Cba_NtkForEachPo( p, iObj, i ) \
for ( i = 0; (i < Cba_NtkPoNum(p)) && (((iObj) = Vec_IntEntry(&p->vOutputs, i)), 1); i++ )
#define Cba_NtkForEachObjType( p, Type, i ) \
...
...
@@ -189,6 +219,15 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { re
#define Cba_NtkForEachObjTypeFuncFanins( p, Type, Func, vFanins, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1) && (((Func) = Cba_ObjFuncId(p, i)), 1) && (((vFanins) = Cba_ObjFaninVec(p, i)), 1); i++ )
#define Cba_NtkForEachBox( p, iObj, i ) \
for ( i = 0; (i < Cba_NtkBoxNum(p)) && (((iObj) = Vec_IntEntry(&p->vBoxes, i)), 1); i++ )
#define Cba_NtkForEachNode( p, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_NODE ) {} else
#define Cba_NtkForEachCi( p, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_PI && Cba_ObjType(p, i) != CBA_OBJ_BO ) {} else
#define Cba_NtkForEachCo( p, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_PO && Cba_ObjType(p, i) != CBA_OBJ_BI ) {} else
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
...
...
@@ -237,6 +276,7 @@ static inline Cba_Ntk_t * Cba_NtkAlloc( Cba_Man_t * p, char * pName )
memset
(
pNtk
,
0
,
sizeof
(
Cba_Ntk_t
)
);
pNtk
->
pDesign
=
p
;
pNtk
->
pName
=
Vec_SetStrsav
(
Cba_ManMem
(
p
),
pName
);
pNtk
->
Id
=
Vec_PtrSize
(
&
p
->
vNtks
);
Vec_PtrPush
(
&
p
->
vNtks
,
pNtk
);
return
pNtk
;
}
...
...
@@ -254,6 +294,11 @@ static inline Cba_Man_t * Cba_ManAlloc( char * pFileName )
}
static
inline
void
Cba_ManFree
(
Cba_Man_t
*
p
)
{
Vec_IntFreeP
(
&
p
->
vBuf2LeafNtk
);
Vec_IntFreeP
(
&
p
->
vBuf2LeafObj
);
Vec_IntFreeP
(
&
p
->
vBuf2RootNtk
);
Vec_IntFreeP
(
&
p
->
vBuf2RootObj
);
ABC_FREE
(
p
->
vCopies
.
pArray
);
ABC_FREE
(
p
->
vNtks
.
pArray
);
Vec_SetFree_
(
&
p
->
Mem
);
Abc_NamStop
(
p
->
pNames
);
...
...
@@ -275,6 +320,8 @@ static inline int Cba_ManMemory( Cba_Man_t * p )
}
/*=== cbaBuild.c =========================================================*/
extern
Cba_Man_t
*
Cba_ManBuild
(
Cba_Man_t
*
p
);
/*=== cbaReadBlif.c =========================================================*/
extern
Cba_Man_t
*
Cba_PrsReadBlif
(
char
*
pFileName
);
/*=== cbaWriteBlif.c ========================================================*/
...
...
@@ -285,8 +332,11 @@ extern Cba_Man_t * Cba_PrsReadVerilog( char * pFileName );
extern
void
Cba_PrsWriteVerilog
(
char
*
pFileName
,
Cba_Man_t
*
pDes
);
/*=== cbaNtk.c =========================================================*/
extern
void
Cba_ManAssignInternNames
(
Cba_Man_t
*
p
);
/*=== cbaBuild.c =========================================================*/
extern
Cba_Man_t
*
Cba_ManBuild
(
Cba_Man_t
*
p
);
extern
int
Cba_NtkNodeNum
(
Cba_Ntk_t
*
p
);
extern
int
Cba_ManObjNum
(
Cba_Man_t
*
p
);
extern
void
Cba_ManSetNtkBoxes
(
Cba_Man_t
*
p
);
extern
Cba_Man_t
*
Cba_ManDupStart
(
Cba_Man_t
*
p
,
Vec_Int_t
*
vObjCounts
);
extern
Cba_Man_t
*
Cba_ManDup
(
Cba_Man_t
*
p
);
...
...
src/base/cba/cbaBlast.c
View file @
2b2f05ba
...
...
@@ -19,6 +19,7 @@
***********************************************************************/
#include "cba.h"
#include "base/abc/abc.h"
ABC_NAMESPACE_IMPL_START
...
...
@@ -41,7 +42,218 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
void
Cba_ManExtractSave
(
Cba_Man_t
*
p
,
int
iLNtk
,
int
iLObj
,
int
iRNtk
,
int
iRObj
)
{
Vec_IntPush
(
p
->
vBuf2LeafNtk
,
iLNtk
);
Vec_IntPush
(
p
->
vBuf2LeafObj
,
iLObj
);
Vec_IntPush
(
p
->
vBuf2RootNtk
,
iRNtk
);
Vec_IntPush
(
p
->
vBuf2RootObj
,
iRObj
);
}
int
Cba_ManExtract_rec
(
Gia_Man_t
*
pNew
,
Cba_Ntk_t
*
p
,
int
i
)
{
int
iRes
=
Cba_NtkCopy
(
p
,
i
);
if
(
iRes
>=
0
)
return
iRes
;
if
(
Cba_ObjIsCo
(
p
,
i
)
)
iRes
=
Cba_ManExtract_rec
(
pNew
,
p
,
Cba_ObjFanin0
(
p
,
i
)
);
else
if
(
Cba_ObjIsBo
(
p
,
i
)
)
{
Cba_Ntk_t
*
pBox
=
Cba_ObjBoModel
(
p
,
i
);
int
iObj
=
Cba_NtkPo
(
pBox
,
Cba_ObjCioIndex
(
p
,
i
)
);
iRes
=
Cba_ManExtract_rec
(
pNew
,
pBox
,
iObj
);
iRes
=
Gia_ManAppendBuf
(
pNew
,
iRes
);
Cba_ManExtractSave
(
p
->
pDesign
,
Cba_NtkId
(
p
),
i
,
Cba_NtkId
(
pBox
),
iObj
);
}
else
if
(
Cba_ObjIsPi
(
p
,
i
)
)
{
Cba_Ntk_t
*
pHost
=
Cba_NtkHost
(
p
);
int
iObj
=
Cba_ObjBoxBi
(
pHost
,
p
->
iBoxObj
,
Cba_ObjCioIndex
(
p
,
i
)
);
iRes
=
Cba_ManExtract_rec
(
pNew
,
pHost
,
iObj
);
iRes
=
Gia_ManAppendBuf
(
pNew
,
iRes
);
Cba_ManExtractSave
(
p
->
pDesign
,
Cba_NtkId
(
p
),
i
,
Cba_NtkId
(
pHost
),
iObj
);
}
else
if
(
Cba_ObjIsNode
(
p
,
i
)
)
{
int
*
pFanins
=
Cba_ObjFaninArray
(
p
,
i
);
int
k
,
pLits
[
3
],
Type
=
Cba_ObjNodeType
(
p
,
i
);
assert
(
pFanins
[
0
]
<=
3
);
for
(
k
=
0
;
k
<
pFanins
[
0
];
k
++
)
pLits
[
k
]
=
Cba_ManExtract_rec
(
pNew
,
p
,
pFanins
[
k
+
1
]
);
if
(
Type
==
CBA_NODE_AND
)
iRes
=
Gia_ManHashAnd
(
pNew
,
pLits
[
0
],
pLits
[
1
]
);
else
if
(
Type
==
CBA_NODE_OR
)
iRes
=
Gia_ManHashAnd
(
pNew
,
pLits
[
0
],
pLits
[
1
]
);
else
if
(
Type
==
CBA_NODE_XOR
)
iRes
=
Gia_ManHashXor
(
pNew
,
pLits
[
0
],
pLits
[
1
]
);
else
if
(
Type
==
CBA_NODE_XNOR
)
iRes
=
Abc_LitNot
(
Gia_ManHashXor
(
pNew
,
pLits
[
0
],
pLits
[
1
]
)
);
else
assert
(
0
),
iRes
=
-
1
;
}
else
assert
(
0
);
Cba_NtkSetCopy
(
p
,
i
,
iRes
);
return
iRes
;
}
Gia_Man_t
*
Cba_ManExtract
(
Cba_Man_t
*
p
,
int
fVerbose
)
{
Cba_Ntk_t
*
pRoot
=
Cba_ManRoot
(
p
);
Gia_Man_t
*
pNew
,
*
pTemp
;
int
i
,
iObj
;
p
->
vBuf2LeafNtk
=
Vec_IntAlloc
(
1000
);
p
->
vBuf2LeafObj
=
Vec_IntAlloc
(
1000
);
p
->
vBuf2RootNtk
=
Vec_IntAlloc
(
1000
);
p
->
vBuf2RootObj
=
Vec_IntAlloc
(
1000
);
// start the manager
pNew
=
Gia_ManStart
(
Cba_ManObjNum
(
p
)
);
pNew
->
pName
=
Abc_UtilStrsav
(
p
->
pName
);
pNew
->
pSpec
=
Abc_UtilStrsav
(
p
->
pSpec
);
Vec_IntFill
(
&
p
->
vCopies
,
Cba_ManObjNum
(
p
),
-
1
);
Cba_NtkForEachPi
(
pRoot
,
iObj
,
i
)
Cba_NtkSetCopy
(
pRoot
,
iObj
,
Gia_ManAppendCi
(
pNew
)
);
Cba_NtkForEachPo
(
pRoot
,
iObj
,
i
)
Cba_ManExtract_rec
(
pNew
,
pRoot
,
iObj
);
Cba_NtkForEachPo
(
pRoot
,
iObj
,
i
)
Gia_ManAppendCo
(
pNew
,
Cba_NtkCopy
(
pRoot
,
iObj
)
);
assert
(
Vec_IntSize
(
p
->
vBuf2LeafNtk
)
==
pNew
->
nBufs
);
// cleanup
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
Gia_ManStop
(
pTemp
);
// Gia_ManPrintStats( pNew, NULL );
// pNew = Gia_ManSweepHierarchy( pTemp = pNew );
// Gia_ManStop( pTemp );
// Gia_ManPrintStats( pNew, NULL );
return
pNew
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
// return the array of object counters for each network
void
Cba_ManCountNodes_rec
(
Cba_Man_t
*
p
,
Abc_Obj_t
*
pObj
,
int
iNtk
,
Vec_Int_t
*
vObjCounts
,
Vec_Int_t
*
vBufDrivers
,
Vec_Int_t
*
vObj2Ntk
,
Vec_Int_t
*
vObj2Obj
)
{
if
(
Abc_ObjIsBarBuf
(
pObj
)
)
{
Abc_Obj_t
*
pFanin
=
Abc_ObjFanin0
(
pObj
);
if
(
Abc_ObjIsPi
(
pFanin
)
||
(
Abc_ObjIsNode
(
pFanin
)
&&
Abc_ObjFaninNum
(
pFanin
)
>
0
)
)
Vec_IntAddToEntry
(
vBufDrivers
,
iNtk
,
1
);
Cba_ManCountNodes_rec
(
p
,
Abc_ObjFanin0
(
pObj
),
pObj
->
iTemp
,
vObjCounts
,
vBufDrivers
,
vObj2Ntk
,
vObj2Obj
);
}
else
if
(
Abc_ObjFaninNum
(
pObj
)
>
0
)
{
Abc_Obj_t
*
pFanin
;
int
i
;
Abc_ObjForEachFanin
(
pObj
,
pFanin
,
i
)
Cba_ManCountNodes_rec
(
p
,
pFanin
,
iNtk
,
vObjCounts
,
vBufDrivers
,
vObj2Ntk
,
vObj2Obj
);
Vec_IntWriteEntry
(
vObj2Ntk
,
Abc_ObjId
(
pObj
),
iNtk
);
Vec_IntWriteEntry
(
vObj2Obj
,
Abc_ObjId
(
pObj
),
Vec_IntEntry
(
vObjCounts
,
iNtk
)
);
Vec_IntAddToEntry
(
vObjCounts
,
iNtk
,
1
);
}
}
Vec_Int_t
*
Cba_ManCountNodes
(
Cba_Man_t
*
p
,
Abc_Ntk_t
*
pAbcNtk
,
Vec_Int_t
*
vBuf2RootNtk
,
Vec_Int_t
**
pvObj2Ntk
,
Vec_Int_t
**
pvObj2Obj
)
{
Cba_Ntk_t
*
pNtk
;
Abc_Obj_t
*
pObj
;
Vec_Int_t
*
vObjCounts
=
Vec_IntStart
(
Cba_ManNtkNum
(
p
)
+
1
);
Vec_Int_t
*
vBufDrivers
=
Vec_IntStart
(
Cba_ManNtkNum
(
p
)
+
1
);
// set networks to which barbufs belong
int
i
,
k
,
iBox
,
iBarBuf
=
Vec_IntSize
(
vBuf2RootNtk
);
assert
(
Vec_IntSize
(
vBuf2RootNtk
)
==
pAbcNtk
->
nBarBufs2
);
Abc_NtkForEachNodeReverse
(
pAbcNtk
,
pObj
,
i
)
pObj
->
iTemp
=
Vec_IntEntry
(
vBuf2RootNtk
,
--
iBarBuf
);
assert
(
iBarBuf
==
0
);
// start with primary inputs
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
Vec_IntAddToEntry
(
vObjCounts
,
i
,
Cba_NtkPiNum
(
pNtk
)
);
Cba_NtkForEachBox
(
pNtk
,
iBox
,
k
)
Vec_IntAddToEntry
(
vObjCounts
,
i
,
Cba_NtkPiNum
(
Cba_ObjBoxModel
(
pNtk
,
iBox
))
+
Cba_NtkPoNum
(
Cba_ObjBoxModel
(
pNtk
,
iBox
))
+
1
);
}
// count internal nodes (network is in topo order)
*
pvObj2Ntk
=
Vec_IntStartFull
(
Abc_NtkObjNumMax
(
pAbcNtk
)
);
*
pvObj2Obj
=
Vec_IntStartFull
(
Abc_NtkObjNumMax
(
pAbcNtk
)
);
Abc_NtkForEachPo
(
pAbcNtk
,
pObj
,
i
)
Cba_ManCountNodes_rec
(
p
,
Abc_ObjFanin0
(
pObj
),
p
->
iRoot
,
vObjCounts
,
vBufDrivers
,
*
pvObj2Ntk
,
*
pvObj2Obj
);
// count PIs, POs, and PO drivers
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Vec_IntAddToEntry
(
vObjCounts
,
i
,
2
*
Cba_NtkPoNum
(
pNtk
)
-
Vec_IntEntry
(
vBufDrivers
,
i
)
);
Vec_IntFree
(
vBufDrivers
);
return
vObjCounts
;
}
Cba_Man_t
*
Cba_ManInsert
(
Cba_Man_t
*
p
,
Abc_Ntk_t
*
pAbcNtk
,
int
fVerbose
)
{
Cba_Man_t
*
pNew
;
Cba_Ntk_t
*
pNtk
;
Abc_Obj_t
*
pObj
,
*
pFanin
;
Vec_Int_t
*
vObj2Ntk
,
*
vObj2Obj
;
Vec_Int_t
*
vObjCounts
=
Cba_ManCountNodes
(
p
,
pAbcNtk
,
p
->
vBuf2RootNtk
,
&
vObj2Ntk
,
&
vObj2Obj
);
Vec_Int_t
*
vFanins
;
int
i
,
k
,
iNtk
,
iBuf
=
0
;
// create initial mapping
pNew
=
Cba_ManDupStart
(
p
,
vObjCounts
);
// set PIs point to the leaves
Abc_NtkForEachPi
(
pAbcNtk
,
pObj
,
i
)
{
Vec_IntWriteEntry
(
vObj2Ntk
,
Abc_ObjId
(
pObj
),
p
->
iRoot
);
Vec_IntWriteEntry
(
vObj2Obj
,
Abc_ObjId
(
pObj
),
i
);
}
// set buffers to point to the leaves
assert
(
Vec_IntSize
(
p
->
vBuf2LeafNtk
)
==
pAbcNtk
->
nBarBufs2
);
assert
(
Vec_IntSize
(
p
->
vBuf2LeafObj
)
==
pAbcNtk
->
nBarBufs2
);
Abc_NtkForEachBarBuf
(
pAbcNtk
,
pObj
,
i
)
{
Vec_IntWriteEntry
(
vObj2Ntk
,
Abc_ObjId
(
pObj
),
Vec_IntEntry
(
p
->
vBuf2LeafNtk
,
iBuf
)
);
Vec_IntWriteEntry
(
vObj2Obj
,
Abc_ObjId
(
pObj
),
Vec_IntEntry
(
p
->
vBuf2LeafObj
,
iBuf
)
);
iBuf
++
;
}
assert
(
iBuf
==
pAbcNtk
->
nBarBufs2
);
// copy internal nodes
vFanins
=
Vec_IntAlloc
(
100
);
Abc_NtkForEachNode
(
pAbcNtk
,
pObj
,
i
)
{
if
(
Abc_ObjIsBarBuf
(
pObj
)
)
continue
;
if
(
Abc_ObjFaninNum
(
pObj
)
==
0
)
continue
;
Vec_IntClear
(
vFanins
);
iNtk
=
Vec_IntEntry
(
vObj2Ntk
,
Abc_ObjId
(
pObj
));
Abc_ObjForEachFanin
(
pObj
,
pFanin
,
k
)
{
assert
(
Vec_IntEntry
(
vObj2Ntk
,
Abc_ObjId
(
pFanin
))
==
iNtk
);
Vec_IntPush
(
vFanins
,
Vec_IntEntry
(
vObj2Obj
,
Abc_ObjId
(
pFanin
))
);
}
pNtk
=
Cba_ManNtk
(
pNew
,
iNtk
);
Vec_IntPush
(
&
pNtk
->
vTypes
,
CBA_OBJ_NODE
);
Vec_IntPush
(
&
pNtk
->
vFuncs
,
-
1
);
Vec_IntPush
(
&
pNtk
->
vFanins
,
Cba_ManHandleArray
(
pNew
,
vFanins
)
);
}
// set buffers to point to the roots
assert
(
Vec_IntSize
(
p
->
vBuf2RootNtk
)
==
pAbcNtk
->
nBarBufs2
);
assert
(
Vec_IntSize
(
p
->
vBuf2RootObj
)
==
pAbcNtk
->
nBarBufs2
);
iBuf
=
0
;
Abc_NtkForEachBarBuf
(
pAbcNtk
,
pObj
,
i
)
{
Vec_IntWriteEntry
(
vObj2Ntk
,
Abc_ObjId
(
pObj
),
Vec_IntEntry
(
p
->
vBuf2RootNtk
,
iBuf
)
);
Vec_IntWriteEntry
(
vObj2Obj
,
Abc_ObjId
(
pObj
),
Vec_IntEntry
(
p
->
vBuf2RootObj
,
iBuf
)
);
iBuf
++
;
}
assert
(
iBuf
==
pAbcNtk
->
nBarBufs2
);
// connect driven root nodes
Vec_IntFree
(
vObj2Ntk
);
Vec_IntFree
(
vObj2Obj
);
return
pNew
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
...
...
src/base/cba/cbaBuild.c
View file @
2b2f05ba
...
...
@@ -51,9 +51,9 @@ ABC_NAMESPACE_IMPL_START
***********************************************************************/
// replaces NameIds of formal names by their index in the box model
void
Cba_
RemapBox
(
Cba_Ntk_t
*
pNtk
,
int
iBox
,
Vec_Int_t
*
vMap
)
void
Cba_
BoxRemap
(
Cba_Ntk_t
*
pNtk
,
int
iBox
,
Vec_Int_t
*
vMap
)
{
Cba_Ntk_t
*
pBoxModel
=
Cba_ObjModel
(
pNtk
,
iBox
);
Cba_Ntk_t
*
pBoxModel
=
Cba_Obj
Box
Model
(
pNtk
,
iBox
);
Vec_Int_t
*
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iBox
);
int
i
,
NameId
;
// map formal names into I/O indexes
...
...
@@ -80,19 +80,19 @@ void Cba_RemapBox( Cba_Ntk_t * pNtk, int iBox, Vec_Int_t * vMap )
Cba_NtkForEachPo
(
pBoxModel
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
}
void
Cba_RemapBoxes
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
)
void
Cba_
Ntk
RemapBoxes
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
)
{
int
Type
,
iBox
;
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iBox
)
if
(
Type
==
CBA_OBJ_BOX
)
Cba_
RemapBox
(
pNtk
,
iBox
,
vMap
);
Cba_
BoxRemap
(
pNtk
,
iBox
,
vMap
);
}
Cba_Ntk_t
*
Cba_NtkBuild
(
Cba_Man_t
*
pNew
,
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vBoxes
,
Vec_Int_t
*
vTemp
)
// create maps of NameId and boxes
int
Cba_NtkCreateMap
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vBoxes
)
{
Vec_Int_t
*
vFanins
;
Cba_Ntk_t
*
pNtkNew
,
*
pNtkBox
;
int
i
,
iObj
,
ObjId
,
FaninId
,
Type
,
Index
,
NameId
;
int
nBoxes
=
0
,
nObjCount
=
0
,
NonDriven
=
0
;
int
i
,
iObj
,
Type
,
Index
,
NameId
;
int
nObjCount
=
0
;
// map old name IDs into new object IDs
Vec_IntClear
(
vBoxes
);
...
...
@@ -104,10 +104,10 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
{
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
if
(
Type
==
CBA_OBJ_NODE
)
{
// consider node output name
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
NameId
=
Vec_IntEntry
(
vFanins
,
0
);
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
printf
(
"Node output name %d is already driven.
\n
"
,
NameId
);
...
...
@@ -115,13 +115,16 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
else
if
(
Type
==
CBA_OBJ_BOX
)
{
Cba_Ntk_t
*
pNtkBox
=
Cba_ObjBoxModel
(
pNtk
,
iObj
);
nObjCount
+=
Cba_NtkPiNum
(
pNtkBox
);
Vec_IntPush
(
vBoxes
,
nObjCount
++
);
pNtkBox
=
Cba_ObjModel
(
pNtk
,
iObj
);
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
Vec_IntForEachEntry
(
vFanins
,
Index
,
i
)
{
i
++
;
if
(
Index
<
Cba_NtkPiNum
(
pNtkBox
)
)
continue
;
assert
(
Index
-
Cba_NtkPiNum
(
pNtkBox
)
<
Cba_NtkPoNum
(
pNtkBox
)
);
// consider box output name
NameId
=
Vec_IntEntry
(
vFanins
,
i
);
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
...
...
@@ -131,14 +134,45 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
nObjCount
+=
Cba_NtkPoNum
(
pNtkBox
);
}
}
// check non-driven nets
// add outputs
nObjCount
+=
Cba_NtkPoNum
(
pNtk
);
return
nObjCount
;
}
void
Cba_NtkCleanMap
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
)
{
Vec_Int_t
*
vFanins
;
int
i
,
iObj
,
Type
,
NameId
;
Cba_NtkForEachPi
(
pNtk
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
{
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
if
(
Type
==
CBA_OBJ_NODE
)
{
Vec_IntForEachEntry
(
vFanins
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
}
else
if
(
Type
==
CBA_OBJ_BOX
)
{
Vec_IntForEachEntry
(
vFanins
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
Vec_IntEntry
(
vFanins
,
++
i
),
-
1
);
}
}
Cba_NtkForEachPo
(
pNtk
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
}
int
Cba_NtkCheckNonDriven
(
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
int
nObjCount
)
{
Vec_Int_t
*
vFanins
;
int
i
,
iObj
,
Type
,
NameId
,
Index
;
int
NonDriven
=
0
;
// check non-driven nets
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
{
if
(
Type
==
CBA_OBJ_NODE
)
{
// consider node input names
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
Vec_IntForEachEntryStart
(
vFanins
,
NameId
,
i
,
1
)
{
if
(
Vec_IntEntry
(
vMap
,
NameId
)
!=
-
1
)
...
...
@@ -149,7 +183,8 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
else
if
(
Type
==
CBA_OBJ_BOX
)
{
pNtkBox
=
Cba_ObjModel
(
pNtk
,
iObj
);
Cba_Ntk_t
*
pNtkBox
=
Cba_ObjBoxModel
(
pNtk
,
iObj
);
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
Vec_IntForEachEntry
(
vFanins
,
Index
,
i
)
{
i
++
;
...
...
@@ -173,16 +208,22 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
if
(
NonDriven
>
0
)
printf
(
"Detected %d non-driven nets.
\n
"
,
NonDriven
);
assert
(
NonDriven
==
0
);
return
NonDriven
;
}
Cba_Ntk_t
*
Cba_NtkBuild
(
Cba_Man_t
*
pNew
,
Cba_Ntk_t
*
pNtk
,
Vec_Int_t
*
vMap
,
Vec_Int_t
*
vBoxes
,
Vec_Int_t
*
vTemp
,
int
nObjCount
)
{
Vec_Int_t
*
vFanins
;
Cba_Ntk_t
*
pNtkNew
,
*
pNtkBox
;
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
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vTypes
,
nObjCount
+
Cba_NtkPoNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFuncs
,
nObjCount
+
Cba_NtkPoNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFanins
,
nObjCount
+
Cba_NtkPoNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vNameIds
,
nObjCount
+
Cba_NtkPoNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vTypes
,
nObjCount
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFuncs
,
nObjCount
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFanins
,
nObjCount
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vNameIds
,
nObjCount
);
Cba_ManSetupArray
(
pNew
,
&
pNtkNew
->
vBoxes
,
vBoxes
);
// fill object information
...
...
@@ -212,7 +253,9 @@ 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
++
);
pNtkBox
=
Cba_ObjModel
(
pNtk
,
iObj
);
pNtkBox
=
Cba_ObjBoxModel
(
pNtk
,
iObj
);
Cba_NtkSetHost
(
pNtkBox
,
Cba_NtkId
(
pNtk
),
ObjId
);
// collect fanins
Vec_IntFill
(
vTemp
,
Cba_NtkPiNum
(
pNtkBox
),
-
1
);
Vec_IntForEachEntry
(
vFanins
,
Index
,
i
)
{
...
...
@@ -225,6 +268,13 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
Vec_IntForEachEntry
(
vTemp
,
Index
,
i
)
assert
(
Index
>=
0
);
// create box inputs
for
(
i
=
0
;
i
<
Cba_NtkPiNum
(
pNtkBox
);
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
))
);
}
// craete box
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
,
CBA_OBJ_BOX
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
,
Cba_ManNtkId
(
pNew
,
Cba_NtkName
(
pNtkBox
))
);
...
...
@@ -232,8 +282,8 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
// create box outputs
for
(
i
=
1
;
i
<=
Cba_NtkPoNum
(
pNtkBox
);
i
++
)
{
Vec_IntWriteEntry
(
&
pNtkNew
->
vTypes
,
ObjId
+
i
,
CBA_OBJ_
PIN
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vFuncs
,
ObjId
+
i
,
-
1
);
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
)
);
}
}
...
...
@@ -241,7 +291,7 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
assert
(
nBoxes
==
Vec_IntSize
(
vBoxes
)
);
Cba_NtkForEachPo
(
pNtk
,
NameId
,
i
)
{
ObjId
=
nObjCount
+
i
;
ObjId
=
nObjCount
-
Cba_NtkPoNum
(
pNtk
)
+
i
;
FaninId
=
Vec_IntEntry
(
vMap
,
NameId
);
assert
(
FaninId
!=
-
1
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vOutputs
,
i
,
ObjId
);
...
...
@@ -252,26 +302,6 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
FaninId
,
-
1
);
Vec_IntWriteEntry
(
&
pNtkNew
->
vNameIds
,
ObjId
,
NameId
);
}
// clean map
Cba_NtkForEachPi
(
pNtk
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
Cba_NtkForEachObjType
(
pNtk
,
Type
,
iObj
)
{
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
if
(
Type
==
CBA_OBJ_NODE
)
{
Vec_IntForEachEntry
(
vFanins
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
}
else
if
(
Type
==
CBA_OBJ_BOX
)
{
Vec_IntForEachEntry
(
vFanins
,
Index
,
i
)
Vec_IntWriteEntry
(
vMap
,
Vec_IntEntry
(
vFanins
,
++
i
),
-
1
);
}
}
Cba_NtkForEachPo
(
pNtk
,
NameId
,
i
)
Vec_IntWriteEntry
(
vMap
,
NameId
,
-
1
);
return
pNtkNew
;
}
Cba_Man_t
*
Cba_ManBuild
(
Cba_Man_t
*
p
)
...
...
@@ -280,13 +310,18 @@ Cba_Man_t * Cba_ManBuild( Cba_Man_t * 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
;
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_RemapBoxes
(
pNtk
,
vMap
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkBuild
(
p
,
pNtk
,
vMap
,
vBoxes
,
vTemp
);
{
Cba_NtkRemapBoxes
(
pNtk
,
vMap
);
nObjs
=
Cba_NtkCreateMap
(
pNtk
,
vMap
,
vBoxes
);
Cba_NtkCheckNonDriven
(
pNtk
,
vMap
,
nObjs
);
Cba_NtkBuild
(
pNew
,
pNtk
,
vMap
,
vBoxes
,
vTemp
,
nObjs
);
Cba_NtkCleanMap
(
pNtk
,
vMap
);
}
Vec_IntFree
(
vTemp
);
Vec_IntFree
(
vBoxes
);
Vec_IntFree
(
vMap
);
...
...
src/base/cba/cbaNtk.c
View file @
2b2f05ba
...
...
@@ -47,7 +47,7 @@ void Cba_ManAssignInternNamesNtk( Cba_Ntk_t * p )
int
nDigits
=
Abc_Base10Log
(
Cba_NtkObjNum
(
p
)
);
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
{
if
(
Type
==
CBA_OBJ_NODE
||
Type
==
CBA_OBJ_PIN
)
if
(
Type
==
CBA_OBJ_NODE
)
{
char
Buffer
[
100
];
sprintf
(
Buffer
,
"%s%0*d"
,
"_n_"
,
nDigits
,
i
);
...
...
@@ -63,6 +63,175 @@ void Cba_ManAssignInternNames( Cba_Man_t * p )
Cba_ManAssignInternNamesNtk
(
pNtk
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Cba_NtkNodeNum
(
Cba_Ntk_t
*
p
)
{
int
iObj
,
Count
=
0
;
Cba_NtkForEachNode
(
p
,
iObj
)
Count
++
;
return
Count
;
}
int
Cba_ManObjNum
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
,
Count
=
0
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
{
pNtk
->
iObjStart
=
Count
;
Count
+=
Cba_NtkObjNum
(
pNtk
);
}
return
Count
;
}
void
Cba_ManSetNtkBoxes
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
,
*
pBox
;
int
i
,
k
,
Type
;
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkForEachObjType
(
pNtk
,
Type
,
k
)
if
(
Type
==
CBA_OBJ_BOX
)
{
pBox
=
Cba_ObjBoxModel
(
pNtk
,
k
);
assert
(
pBox
->
iBoxNtk
==
0
);
pBox
->
iBoxNtk
=
i
;
pBox
->
iBoxObj
=
k
;
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Cba_ObjDup
(
Cba_Ntk_t
*
pNew
,
Cba_Ntk_t
*
p
,
int
iObj
)
{
if
(
Cba_ObjIsPi
(
p
,
iObj
)
)
Vec_IntWriteEntry
(
&
pNew
->
vInputs
,
Cba_ObjFuncId
(
pNew
,
iObj
),
pNew
->
nObjs
);
if
(
Cba_ObjIsPo
(
p
,
iObj
)
)
Vec_IntWriteEntry
(
&
pNew
->
vOutputs
,
Cba_ObjFuncId
(
pNew
,
iObj
),
pNew
->
nObjs
);
if
(
Cba_ObjIsBox
(
p
,
iObj
)
)
Vec_IntPush
(
&
pNew
->
vBoxes
,
pNew
->
nObjs
);
Vec_IntWriteEntry
(
&
pNew
->
vTypes
,
pNew
->
nObjs
,
Cba_ObjType
(
p
,
iObj
)
);
Vec_IntWriteEntry
(
&
pNew
->
vFuncs
,
pNew
->
nObjs
,
Cba_ObjFuncId
(
pNew
,
iObj
)
);
Vec_IntWriteEntry
(
&
pNew
->
vNameIds
,
pNew
->
nObjs
,
Cba_ObjNameId
(
p
,
iObj
)
);
Cba_NtkSetCopy
(
p
,
iObj
,
pNew
->
nObjs
++
);
}
// allocates memory
Cba_Ntk_t
*
Cba_NtkDupAlloc
(
Cba_Man_t
*
pNew
,
Cba_Ntk_t
*
pNtk
,
int
nObjs
)
{
Cba_Ntk_t
*
pNtkNew
=
Cba_NtkAlloc
(
pNew
,
Cba_NtkName
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vInputs
,
Cba_NtkPiNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vOutputs
,
Cba_NtkPoNum
(
pNtk
)
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vTypes
,
nObjs
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFuncs
,
nObjs
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vFanins
,
nObjs
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vNameIds
,
nObjs
);
Cba_ManFetchArray
(
pNew
,
&
pNtkNew
->
vBoxes
,
Cba_NtkBoxNum
(
pNtk
)
);
Vec_IntShrink
(
&
pNtkNew
->
vBoxes
,
0
);
return
pNtkNew
;
}
// duplicate PI/PO/boxes
int
Cba_NtkDupStart
(
Cba_Ntk_t
*
pNew
,
Cba_Ntk_t
*
p
)
{
int
i
,
k
,
iObj
;
pNew
->
nObjs
=
0
;
Cba_NtkForEachPi
(
p
,
iObj
,
i
)
Cba_ObjDup
(
pNew
,
p
,
iObj
);
Cba_NtkForEachPo
(
p
,
iObj
,
i
)
Cba_ObjDup
(
pNew
,
p
,
iObj
);
Cba_NtkForEachBox
(
p
,
iObj
,
i
)
{
Cba_Ntk_t
*
pBox
=
Cba_ObjBoxModel
(
p
,
iObj
);
for
(
k
=
0
;
k
<
Cba_NtkPiNum
(
pBox
);
k
++
)
Cba_ObjDup
(
pNew
,
p
,
Cba_ObjBoxBi
(
p
,
iObj
,
k
)
);
Cba_ObjDup
(
pNew
,
p
,
iObj
);
for
(
k
=
0
;
k
<
Cba_NtkPoNum
(
pBox
);
k
++
)
Cba_ObjDup
(
pNew
,
p
,
Cba_ObjBoxBo
(
p
,
iObj
,
k
)
);
}
return
pNew
->
nObjs
;
}
// duplicate internal nodes
void
Cba_NtkDupNodes
(
Cba_Ntk_t
*
pNew
,
Cba_Ntk_t
*
p
,
Vec_Int_t
*
vTemp
)
{
Vec_Int_t
*
vFanins
;
int
i
,
k
,
Type
,
iTerm
,
iObj
;
Cba_NtkForEachNode
(
p
,
iObj
)
Cba_ObjDup
(
pNew
,
p
,
iObj
);
// connect
Cba_NtkForEachObjType
(
p
,
Type
,
i
)
{
if
(
Type
==
CBA_OBJ_PI
||
Type
==
CBA_OBJ_BOX
)
continue
;
if
(
Type
==
CBA_OBJ_PO
||
Type
==
CBA_OBJ_BI
||
Type
==
CBA_OBJ_BO
)
{
Vec_IntWriteEntry
(
&
pNew
->
vFanins
,
Cba_NtkCopy
(
p
,
i
),
Cba_NtkCopy
(
p
,
Cba_ObjFanin0
(
p
,
i
))
);
continue
;
}
assert
(
Type
==
CBA_OBJ_NODE
);
Vec_IntClear
(
vTemp
);
vFanins
=
Cba_ObjFaninVec
(
p
,
i
);
Vec_IntForEachEntry
(
vFanins
,
iTerm
,
k
)
Vec_IntPush
(
vTemp
,
Cba_NtkCopy
(
p
,
iTerm
)
);
Vec_IntWriteEntry
(
&
pNew
->
vFanins
,
Cba_NtkCopy
(
p
,
i
),
Cba_ManHandleArray
(
pNew
->
pDesign
,
vTemp
)
);
}
}
// finalize network
void
Cba_NtkDupFinish
(
Cba_Ntk_t
*
pNew
)
{
int
iObj
;
// add constant drivers
Cba_NtkForEachCo
(
pNew
,
iObj
)
{
}
// restrict
Vec_IntShrink
(
&
pNew
->
vTypes
,
pNew
->
nObjs
);
Vec_IntShrink
(
&
pNew
->
vFuncs
,
pNew
->
nObjs
);
Vec_IntShrink
(
&
pNew
->
vFanins
,
pNew
->
nObjs
);
Vec_IntShrink
(
&
pNew
->
vNameIds
,
pNew
->
nObjs
);
}
Cba_Man_t
*
Cba_ManDupStart
(
Cba_Man_t
*
p
,
Vec_Int_t
*
vObjCounts
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
Cba_Man_t
*
pNew
=
Cba_ManAlloc
(
Cba_ManName
(
p
)
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkDupAlloc
(
pNew
,
pNtk
,
vObjCounts
?
Cba_NtkObjNum
(
pNtk
)
:
Vec_IntEntry
(
vObjCounts
,
i
)
);
Vec_IntFill
(
&
p
->
vCopies
,
Cba_ManObjNum
(
pNew
),
-
1
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkDupStart
(
Cba_ManNtk
(
pNew
,
i
),
pNtk
);
return
pNew
;
}
Cba_Man_t
*
Cba_ManDup
(
Cba_Man_t
*
p
)
{
Cba_Ntk_t
*
pNtk
;
int
i
;
Vec_Int_t
*
vTemp
=
Vec_IntAlloc
(
100
);
Cba_Man_t
*
pNew
=
Cba_ManDupStart
(
p
,
NULL
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkDupNodes
(
Cba_ManNtk
(
pNew
,
i
),
pNtk
,
vTemp
);
Cba_ManForEachNtk
(
p
,
pNtk
,
i
)
Cba_NtkDupFinish
(
Cba_ManNtk
(
pNew
,
i
)
);
Vec_IntClear
(
vTemp
);
return
pNew
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/base/cba/cbaSimple.c
View file @
2b2f05ba
...
...
@@ -554,7 +554,7 @@ Vec_Ptr_t * Ptr_CbaDeriveBox( Cba_Ntk_t * pNtk, int iObj )
{
int
i
,
iTerm
;
Vec_Int_t
*
vFanins
=
Cba_ObjFaninVec
(
pNtk
,
iObj
);
Cba_Ntk_t
*
pModel
=
Cba_ObjModel
(
pNtk
,
iObj
);
Cba_Ntk_t
*
pModel
=
Cba_Obj
Box
Model
(
pNtk
,
iObj
);
Vec_Ptr_t
*
vBox
=
Vec_PtrAlloc
(
2
+
Cba_NtkPiNum
(
pModel
)
+
Cba_NtkPoNum
(
pModel
)
);
assert
(
Cba_ObjIsBox
(
pNtk
,
iObj
)
);
assert
(
Cba_NtkPiNum
(
pModel
)
==
Vec_IntSize
(
vFanins
)
);
...
...
src/base/cba/cbaWriteBlif.c
View file @
2b2f05ba
...
...
@@ -143,7 +143,7 @@ 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_Ntk_t
*
pModel
=
Cba_Obj
Box
Model
(
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
)
...
...
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