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
7fab7fd1
Commit
7fab7fd1
authored
Sep 29, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added serialization of Mini AIG.
parent
8a91a9af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
6 deletions
+72
-6
src/aig/miniaig/miniaig.h
+62
-6
src/base/abci/abcMini.c
+10
-0
No files found.
src/aig/miniaig/miniaig.h
View file @
7fab7fd1
...
...
@@ -46,6 +46,7 @@ struct Mini_Aig_t_
{
int
nCap
;
int
nSize
;
int
nRegs
;
int
*
pArray
;
};
...
...
@@ -116,13 +117,21 @@ static int Mini_AigNodeIsPi( Mini_Aig_t * p, int Id ) { assert( Id >= 0
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
;
}
static
int
Mini_AigNodeIsAnd
(
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
;
}
// working with sequential AIGs
static
int
Mini_AigRegNum
(
Mini_Aig_t
*
p
)
{
return
p
->
nRegs
;
}
static
void
Mini_AigSetRegNum
(
Mini_Aig_t
*
p
,
int
n
)
{
p
->
nRegs
=
n
;
}
// iterators through objects
#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
// constructor/destructor
static
Mini_Aig_t
*
Mini_AigStart
()
{
Mini_Aig_t
*
p
;
p
=
MINI_AIG_ALLOC
(
Mini_Aig_t
,
1
);
p
->
nSize
=
0
;
p
=
MINI_AIG_CALLOC
(
Mini_Aig_t
,
1
);
p
->
nCap
=
MINI_AIG_START_SIZE
;
p
->
pArray
=
MINI_AIG_ALLOC
(
int
,
p
->
nCap
);
Mini_AigPush
(
p
,
MINI_AIG_NULL
,
MINI_AIG_NULL
);
...
...
@@ -133,6 +142,57 @@ static void Mini_AigStop( Mini_Aig_t * p )
MINI_AIG_FREE
(
p
->
pArray
);
MINI_AIG_FREE
(
p
);
}
static
void
Mini_AigPrintStats
(
Mini_Aig_t
*
p
)
{
int
i
,
nPis
,
nPos
,
nNodes
;
nPis
=
0
;
Mini_AigForEachPi
(
p
,
i
)
nPis
++
;
nPos
=
0
;
Mini_AigForEachPo
(
p
,
i
)
nPos
++
;
nNodes
=
0
;
Mini_AigForEachAnd
(
p
,
i
)
nNodes
++
;
printf
(
"PI = %d. PO = %d. Node = %d.
\n
"
,
nPis
,
nPos
,
nNodes
);
}
// serialization
static
void
Mini_AigDump
(
Mini_Aig_t
*
p
,
char
*
pFileName
)
{
FILE
*
pFile
;
int
RetValue
;
pFile
=
fopen
(
pFileName
,
"wb"
);
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open file for writing
\"
%s
\"
.
\n
"
,
pFileName
);
return
;
}
RetValue
=
fwrite
(
&
p
->
nSize
,
sizeof
(
int
),
1
,
pFile
);
RetValue
=
fwrite
(
&
p
->
nRegs
,
sizeof
(
int
),
1
,
pFile
);
RetValue
=
fwrite
(
p
->
pArray
,
sizeof
(
int
),
p
->
nSize
,
pFile
);
fclose
(
pFile
);
}
static
Mini_Aig_t
*
Mini_AigLoad
(
char
*
pFileName
)
{
Mini_Aig_t
*
p
;
FILE
*
pFile
;
int
RetValue
,
nSize
;
pFile
=
fopen
(
pFileName
,
"rb"
);
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open file for reading
\"
%s
\"
.
\n
"
,
pFileName
);
return
NULL
;
}
RetValue
=
fread
(
&
nSize
,
sizeof
(
int
),
1
,
pFile
);
p
=
MINI_AIG_CALLOC
(
Mini_Aig_t
,
1
);
p
->
nSize
=
p
->
nCap
=
nSize
;
p
->
pArray
=
MINI_AIG_ALLOC
(
int
,
p
->
nCap
);
RetValue
=
fread
(
&
p
->
nRegs
,
sizeof
(
int
),
1
,
pFile
);
RetValue
=
fread
(
p
->
pArray
,
sizeof
(
int
),
p
->
nSize
,
pFile
);
fclose
(
pFile
);
return
p
;
}
// creating nodes
...
...
@@ -176,10 +236,6 @@ static int Mini_AigXor( Mini_Aig_t * p, int Lit0, int 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 @
7fab7fd1
...
...
@@ -186,6 +186,16 @@ void Abc_NtkMiniAigTest( Abc_Ntk_t * pNtk )
Mini_AigStop
(
p
);
Abc_NtkPrintStats
(
pNtkNew
,
0
,
0
,
0
,
0
,
0
,
0
,
0
);
Abc_NtkDelete
(
pNtkNew
);
// test dumping
p
=
Abc_NtkToMiniAig
(
pNtk
);
Mini_AigDump
(
p
,
"miniaig.data"
);
Mini_AigPrintStats
(
p
);
Mini_AigStop
(
p
);
p
=
Mini_AigLoad
(
"miniaig.data"
);
Mini_AigPrintStats
(
p
);
Mini_AigStop
(
p
);
}
/*
...
...
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