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
5cf9d6dd
Commit
5cf9d6dd
authored
Sep 29, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with mini AIG manager.
parent
ae1dddbc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
44 deletions
+60
-44
src/base/abc/miniaig.h
+16
-13
src/base/abci/abcMini.c
+40
-31
src/base/main/main.h
+4
-0
No files found.
src/base/abc/miniaig.h
View file @
5cf9d6dd
...
...
@@ -73,7 +73,7 @@ static void Mini_AigGrow( Mini_Aig_t * p, int nCapMin )
}
static
void
Mini_AigPush
(
Mini_Aig_t
*
p
,
int
Lit0
,
int
Lit1
)
{
if
(
p
->
nSize
>=
p
->
nCap
+
1
)
if
(
p
->
nSize
+
2
>
p
->
nCap
)
{
if
(
p
->
nCap
<
MINI_AIG_START_SIZE
)
Mini_AigGrow
(
p
,
MINI_AIG_START_SIZE
);
...
...
@@ -110,7 +110,7 @@ static int Mini_AigLitIsConst0( int Lit ) { return Lit == 0
static
int
Mini_AigLitIsConst1
(
int
Lit
)
{
return
Lit
==
1
;
}
static
int
Mini_AigLitIsConst
(
int
Lit
)
{
return
Lit
==
0
||
Lit
==
1
;
}
static
int
Mini_AigN
umNodes
(
Mini_Aig_t
*
p
)
{
return
p
->
nSize
/
2
;
}
static
int
Mini_AigN
odeNum
(
Mini_Aig_t
*
p
)
{
return
p
->
nSize
/
2
;
}
static
int
Mini_AigNodeIsConst
(
Mini_Aig_t
*
p
,
int
Id
)
{
assert
(
Id
>=
0
);
return
Id
==
0
;
}
static
int
Mini_AigNodeIsPi
(
Mini_Aig_t
*
p
,
int
Id
)
{
assert
(
Id
>=
0
);
return
Id
>
0
&&
Mini_AigNodeFanin0
(
p
,
Id
)
==
MINI_AIG_NULL
;
}
static
int
Mini_AigNodeIsPo
(
Mini_Aig_t
*
p
,
int
Id
)
{
assert
(
Id
>=
0
);
return
Id
>
0
&&
Mini_AigNodeFanin0
(
p
,
Id
)
!=
MINI_AIG_NULL
&&
Mini_AigNodeFanin1
(
p
,
Id
)
==
MINI_AIG_NULL
;
}
...
...
@@ -118,15 +118,12 @@ static int Mini_AigNodeIsAnd( Mini_Aig_t * p, int Id ) { assert( Id >= 0
// constructor/destructor
static
Mini_Aig_t
*
Mini_AigStart
(
int
nCap
)
static
Mini_Aig_t
*
Mini_AigStart
()
{
Mini_Aig_t
*
p
;
assert
(
nCap
>
0
);
p
=
MINI_AIG_ALLOC
(
Mini_Aig_t
,
1
);
if
(
nCap
<
MINI_AIG_START_SIZE
)
nCap
=
MINI_AIG_START_SIZE
;
p
->
nSize
=
0
;
p
->
nCap
=
nCap
;
p
->
nCap
=
MINI_AIG_START_SIZE
;
p
->
pArray
=
MINI_AIG_ALLOC
(
int
,
p
->
nCap
);
Mini_AigPush
(
p
,
MINI_AIG_NULL
,
MINI_AIG_NULL
);
return
p
;
...
...
@@ -142,14 +139,14 @@ static void Mini_AigStop( Mini_Aig_t * p )
// (constant node is created when AIG manager is created)
static
int
Mini_AigCreatePi
(
Mini_Aig_t
*
p
)
{
int
Lit
=
Mini_AigN
umNodes
(
p
);
int
Lit
=
Mini_AigN
odeNum
(
p
);
Mini_AigPush
(
p
,
MINI_AIG_NULL
,
MINI_AIG_NULL
);
return
Lit
;
}
static
int
Mini_AigCreatePo
(
Mini_Aig_t
*
p
,
int
Lit0
)
{
int
Lit
=
Mini_AigN
umNodes
(
p
);
assert
(
Lit0
>=
0
&&
Lit0
<
2
*
Mini_AigN
umNodes
(
p
)
);
int
Lit
=
Mini_AigN
odeNum
(
p
);
assert
(
Lit0
>=
0
&&
Lit0
<
2
*
Mini_AigN
odeNum
(
p
)
);
Mini_AigPush
(
p
,
Lit0
,
MINI_AIG_NULL
);
return
Lit
;
}
...
...
@@ -157,9 +154,9 @@ static int Mini_AigCreatePo( Mini_Aig_t * p, int Lit0 )
// boolean operations
static
int
Mini_AigAnd
(
Mini_Aig_t
*
p
,
int
Lit0
,
int
Lit1
)
{
int
Lit
=
Mini_AigN
umNodes
(
p
);
assert
(
Lit0
>=
0
&&
Lit0
<
2
*
Mini_AigN
umNodes
(
p
)
);
assert
(
Lit1
>=
0
&&
Lit1
<
2
*
Mini_AigN
umNodes
(
p
)
);
int
Lit
=
Mini_AigN
odeNum
(
p
);
assert
(
Lit0
>=
0
&&
Lit0
<
2
*
Mini_AigN
odeNum
(
p
)
);
assert
(
Lit1
>=
0
&&
Lit1
<
2
*
Mini_AigN
odeNum
(
p
)
);
Mini_AigPush
(
p
,
Lit0
,
Lit1
);
return
Lit
;
}
...
...
@@ -178,6 +175,12 @@ static int Mini_AigXor( Mini_Aig_t * p, int Lit0, int Lit1 )
return
Mini_AigMux
(
p
,
Lit0
,
Mini_AigLitNot
(
Lit1
),
Lit1
);
}
#define Mini_AigForEachPi( p, i ) for (i = 1; i < Mini_AigNodeNum(p); i++) if ( !Mini_AigNodeIsPi(p, i) ) else
#define Mini_AigForEachPo( p, i ) for (i = 1; i < Mini_AigNodeNum(p); i++) if ( !Mini_AigNodeIsPo(p, i) ) else
#define Mini_AigForEachAnd( p, i ) for (i = 1; i < Mini_AigNodeNum(p); i++) if ( !Mini_AigNodeIsAnd(p, i) ) else
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
...
...
src/base/abci/abcMini.c
View file @
5cf9d6dd
...
...
@@ -29,9 +29,6 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static
Mini_Aig_t
*
Abc_NtkToMini
(
Abc_Ntk_t
*
pNtk
);
static
Abc_Ntk_t
*
Abc_NtkFromMini
(
Abc_Ntk_t
*
pNtkOld
,
Mini_Aig_t
*
p
);
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
...
...
@@ -50,20 +47,15 @@ static Abc_Ntk_t * Abc_NtkFromMini( Abc_Ntk_t * pNtkOld, Mini_Aig_t * p );
Abc_Obj_t
*
Abc_NodeFanin0Copy
(
Abc_Ntk_t
*
pNtk
,
Vec_Int_t
*
vCopies
,
Mini_Aig_t
*
p
,
int
Id
)
{
int
Lit
=
Mini_AigNodeFanin0
(
p
,
Id
);
Lit
=
Abc_LitNotCond
(
Vec_IntEntry
(
vCopies
,
Abc_Lit2Var
(
Lit
)),
Abc_LitIsCompl
(
Lit
)
);
return
Abc_Obj
NotCond
(
Abc_NtkObj
(
pNtk
,
Abc_Lit2Var
(
Lit
)),
Abc_LitIsCompl
(
Lit
)
);
int
Abc
Lit
=
Abc_LitNotCond
(
Vec_IntEntry
(
vCopies
,
Abc_Lit2Var
(
Lit
)),
Abc_LitIsCompl
(
Lit
)
);
return
Abc_Obj
FromLit
(
pNtk
,
AbcLit
);
}
Abc_Obj_t
*
Abc_NodeFanin1Copy
(
Abc_Ntk_t
*
pNtk
,
Vec_Int_t
*
vCopies
,
Mini_Aig_t
*
p
,
int
Id
)
{
int
Lit
=
Mini_AigNodeFanin1
(
p
,
Id
);
Lit
=
Abc_LitNotCond
(
Vec_IntEntry
(
vCopies
,
Abc_Lit2Var
(
Lit
)),
Abc_LitIsCompl
(
Lit
)
);
return
Abc_ObjNotCond
(
Abc_NtkObj
(
pNtk
,
Abc_Lit2Var
(
Lit
)),
Abc_LitIsCompl
(
Lit
)
);
}
int
Abc_NodeToLit
(
Abc_Obj_t
*
pObj
)
{
return
Abc_LitNotCond
(
Abc_ObjId
(
Abc_ObjRegular
(
pObj
)),
Abc_ObjIsComplement
(
pObj
)
);
int
AbcLit
=
Abc_LitNotCond
(
Vec_IntEntry
(
vCopies
,
Abc_Lit2Var
(
Lit
)),
Abc_LitIsCompl
(
Lit
)
);
return
Abc_ObjFromLit
(
pNtk
,
AbcLit
);
}
Abc_Ntk_t
*
Abc_NtkFromMiniAig
(
Mini_Aig_t
*
p
)
{
Abc_Ntk_t
*
pNtk
;
...
...
@@ -71,12 +63,12 @@ Abc_Ntk_t * Abc_NtkFromMiniAig( Mini_Aig_t * p )
Vec_Int_t
*
vCopies
;
int
i
,
nNodes
;
// get the number of nodes
nNodes
=
Mini_AigN
umNodes
(
p
);
nNodes
=
Mini_AigN
odeNum
(
p
);
// create ABC network
pNtk
=
Abc_NtkAlloc
(
ABC_NTK_STRASH
,
ABC_FUNC_AIG
,
1
);
// create mapping from MiniAIG into ABC objects
// create mapping from MiniAIG
objects
into ABC objects
vCopies
=
Vec_IntAlloc
(
nNodes
);
Vec_IntPush
(
vCopies
,
Abc_LitNot
(
Abc_
Node
ToLit
(
Abc_AigConst1
(
pNtk
)))
);
Vec_IntPush
(
vCopies
,
Abc_LitNot
(
Abc_
Obj
ToLit
(
Abc_AigConst1
(
pNtk
)))
);
// iterate through the objects
for
(
i
=
1
;
i
<
nNodes
;
i
++
)
{
...
...
@@ -87,7 +79,7 @@ Abc_Ntk_t * Abc_NtkFromMiniAig( Mini_Aig_t * p )
else
if
(
Mini_AigNodeIsAnd
(
p
,
i
)
)
pObj
=
Abc_AigAnd
((
Abc_Aig_t
*
)
pNtk
->
pManFunc
,
Abc_NodeFanin0Copy
(
pNtk
,
vCopies
,
p
,
i
),
Abc_NodeFanin1Copy
(
pNtk
,
vCopies
,
p
,
i
));
else
assert
(
0
);
Vec_IntPush
(
vCopies
,
Abc_
Node
ToLit
(
pObj
)
);
Vec_IntPush
(
vCopies
,
Abc_
Obj
ToLit
(
pObj
)
);
}
Abc_AigCleanup
(
(
Abc_Aig_t
*
)
pNtk
->
pManFunc
);
Vec_IntFree
(
vCopies
);
...
...
@@ -109,26 +101,34 @@ Abc_Ntk_t * Abc_NtkFromMiniAig( Mini_Aig_t * p )
SeeAlso []
***********************************************************************/
int
Abc_NodeFanin0Copy2
(
Abc_Obj_t
*
pObj
)
{
return
Abc_LitNotCond
(
Abc_ObjFanin0
(
pObj
)
->
iTemp
,
Abc_ObjFaninC0
(
pObj
)
);
}
int
Abc_NodeFanin1Copy2
(
Abc_Obj_t
*
pObj
)
{
return
Abc_LitNotCond
(
Abc_ObjFanin1
(
pObj
)
->
iTemp
,
Abc_ObjFaninC1
(
pObj
)
);
}
Mini_Aig_t
*
Abc_NtkToMiniAig
(
Abc_Ntk_t
*
pNtk
)
{
Mini_Aig_t
*
p
=
NULL
;
/*
Mini_Aig_t
*
p
;
Abc_Obj_t
*
pObj
;
int
i
;
assert
(
Abc_NtkIsStrash
(
pNtk
)
);
// create the manager
p = Hop_ManStart();
// transfer the pointers to the basic nodes
Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Hop_ManConst1(p);
p
=
Mini_AigStart
();
// create mapping from MiniAIG into ABC objects
Abc_NtkCleanCopy
(
pNtk
);
Abc_AigConst1
(
pNtk
)
->
iTemp
=
Mini_AigLitConst1
();
// create primary inputs
Abc_NtkForEachCi
(
pNtk
,
pObj
,
i
)
pObj->
pCopy = (Abc_Obj_t *)Hop_Obj
CreatePi(p);
//
perform the conversion of the internal nodes (assumes DFS ordering)
pObj
->
iTemp
=
Mini_Aig
CreatePi
(
p
);
//
create internal nodes
Abc_NtkForEachNode
(
pNtk
,
pObj
,
i
)
pObj->
pCopy = (Abc_Obj_t *)Hop_And( p, (Hop_Obj_t *)Abc_ObjChild0Copy(pObj), (Hop_Obj_t *)Abc_ObjChild1Copy
(pObj) );
// create
the PO
s
pObj
->
iTemp
=
Mini_AigAnd
(
p
,
Abc_NodeFanin0Copy2
(
pObj
),
Abc_NodeFanin1Copy2
(
pObj
)
);
// create
primary output
s
Abc_NtkForEachCo
(
pNtk
,
pObj
,
i
)
Hop_ObjCreatePo( p, (Hop_Obj_t *)Abc_ObjChild0Copy(pObj) );
Hop_ManCleanup( p );
*/
pObj
->
iTemp
=
Mini_AigCreatePo
(
p
,
Abc_NodeFanin0Copy2
(
pObj
)
);
return
p
;
}
...
...
@@ -143,16 +143,25 @@ Mini_Aig_t * Abc_NtkToMiniAig( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
void
Abc_NtkInputMiniAig
(
Mini_Aig_t
*
p
)
void
Abc_NtkInputMiniAig
(
Abc_Frame_t
*
pAbc
,
void
*
p
)
{
Abc_Ntk_t
*
pNtk
;
Abc_Frame_t
*
pAbc
=
Abc_FrameReadGlobalFrame
();
if
(
pAbc
==
NULL
)
printf
(
"ABC framework is not initialized by calling Abc_Start()
\n
"
);
pNtk
=
Abc_NtkFromMiniAig
(
p
);
pNtk
=
Abc_NtkFromMiniAig
(
(
Mini_Aig_t
*
)
p
);
Abc_FrameReplaceCurrentNetwork
(
pAbc
,
pNtk
);
// Abc_NtkDelete( pNtk );
}
void
*
Abc_NtkOutputMiniAig
(
Abc_Frame_t
*
pAbc
)
{
Abc_Ntk_t
*
pNtk
;
if
(
pAbc
==
NULL
)
printf
(
"ABC framework is not initialized by calling Abc_Start()
\n
"
);
pNtk
=
Abc_FrameReadNtk
(
pAbc
);
if
(
pNtk
==
NULL
)
printf
(
"Current network in ABC framework is not defined.
\n
"
);
return
Abc_NtkToMiniAig
(
pNtk
);
}
////////////////////////////////////////////////////////////////////////
...
...
src/base/main/main.h
View file @
5cf9d6dd
...
...
@@ -131,6 +131,10 @@ extern ABC_DLL void Abc_FrameSetCex( Abc_Cex_t * pCex );
extern
ABC_DLL
void
Abc_FrameSetNFrames
(
int
nFrames
);
extern
ABC_DLL
void
Abc_FrameSetStatus
(
int
Status
);
/*=== mainFrame.c ===========================================================*/
extern
ABC_DLL
void
Abc_NtkInputMiniAig
(
Abc_Frame_t
*
pAbc
,
void
*
p
);
extern
ABC_DLL
void
*
Abc_NtkOutputMiniAig
(
Abc_Frame_t
*
pAbc
);
ABC_NAMESPACE_HEADER_END
...
...
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