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
f04d3273
Commit
f04d3273
authored
Jun 19, 2014
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added quick GIG parser.
parent
f98f610b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
263 additions
and
0 deletions
+263
-0
abclib.dsp
+4
-0
src/aig/gia/giaGig.c
+199
-0
src/aig/gia/module.make
+1
-0
src/base/io/io.c
+59
-0
No files found.
abclib.dsp
View file @
f04d3273
...
@@ -3775,6 +3775,10 @@ SOURCE=.\src\aig\gia\giaFx.c
...
@@ -3775,6 +3775,10 @@ SOURCE=.\src\aig\gia\giaFx.c
# End Source File
# End Source File
# Begin Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaGig.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaGlitch.c
SOURCE=.\src\aig\gia\giaGlitch.c
# End Source File
# End Source File
# Begin Source File
# Begin Source File
...
...
src/aig/gia/giaGig.c
0 → 100644
View file @
f04d3273
/**CFile****************************************************************
FileName [giaGig.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Scalable AIG package.]
Synopsis [Parser for Gate-Inverter Graph by Niklas Een.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: giaGig.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "gia.h"
#include "misc/extra/extra.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
typedef
enum
{
GIG_NONE
=
0
,
GIG_RESET
=
1
,
GIG_PI
=
2
,
GIG_PO
=
3
,
GIG_SEQ
=
4
,
GIG_LUT
=
5
,
GIG_DELAY
=
6
,
GIG_BOX
=
7
,
GIG_SEL
=
8
,
GIG_BAR
=
9
,
GIG_UNUSED
=
10
};
static
char
*
s_GigNames
[
GIG_UNUSED
]
=
{
"NONE"
,
// GIG_NONE = 0
"Reset"
,
// GIG_RESET = 1
"PI"
,
// GIG_PI = 2
"PO"
,
// GIG_PO = 3
"Seq"
,
// GIG_SEQ = 4
"Lut4"
,
// GIG_LUT = 5
"Delay"
,
// GIG_DELAY = 6
"Box"
,
// GIG_BOX = 7
"Sel"
,
// GIG_SEL = 8
"Bar"
// GIG_BAR = 9
};
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManBuildGig
(
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vStore
)
{
int
i
,
Type
,
nObjs
[
GIG_UNUSED
]
=
{
0
};
printf
(
"Parsed %d objects and %d tokens.
\n
"
,
Vec_IntSize
(
vObjs
),
Vec_IntSize
(
vStore
)
);
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
{
Type
=
Vec_IntEntry
(
vStore
,
Vec_IntEntry
(
vObjs
,
i
)
+
1
);
nObjs
[
Type
]
++
;
}
printf
(
"Statistics: "
);
for
(
i
=
1
;
i
<
GIG_UNUSED
;
i
++
)
printf
(
"%s = %d "
,
s_GigNames
[
i
],
nObjs
[
i
]
);
printf
(
"
\n
"
);
return
NULL
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManReadGig
(
char
*
pFileName
)
{
Gia_Man_t
*
pNew
;
int
Type
,
Offset
,
fEndOfLine
,
Digit
,
nObjs
;
char
*
pChars
=
" w(-,)]
\r\t
"
;
char
*
pBuffer
=
Extra_FileReadContents
(
pFileName
);
char
*
pStart
=
pBuffer
,
*
pToken
;
Vec_Int_t
*
vObjs
,
*
vStore
;
if
(
pBuffer
==
NULL
)
printf
(
"Cannot open input file %s
\n
"
,
pFileName
);
// count objects
for
(
nObjs
=
0
,
pToken
=
pBuffer
;
*
pToken
;
pToken
++
)
nObjs
+=
(
int
)(
*
pToken
==
'\n'
);
// read objects
vObjs
=
Vec_IntAlloc
(
nObjs
);
vStore
=
Vec_IntAlloc
(
10
*
nObjs
);
while
(
1
)
{
// read net ID
pToken
=
strtok
(
pStart
,
pChars
);
pStart
=
NULL
;
if
(
pToken
==
NULL
)
break
;
// start new object
Vec_IntPush
(
vObjs
,
Vec_IntSize
(
vStore
)
);
// save net ID
assert
(
pToken
[
0
]
>=
'0'
&&
pToken
[
0
]
<=
'9'
);
Vec_IntPush
(
vStore
,
atoi
(
pToken
)
);
// read equal
pToken
=
strtok
(
pStart
,
pChars
);
assert
(
pToken
[
0
]
==
'='
);
// read type
pToken
=
strtok
(
pStart
,
pChars
);
fEndOfLine
=
0
;
if
(
pToken
[
strlen
(
pToken
)
-
1
]
==
'\n'
)
{
pToken
[
strlen
(
pToken
)
-
1
]
=
0
;
fEndOfLine
=
1
;
}
for
(
Type
=
GIG_RESET
;
Type
<
GIG_UNUSED
;
Type
++
)
if
(
!
strcmp
(
pToken
,
s_GigNames
[
Type
])
)
break
;
assert
(
Type
<
GIG_UNUSED
);
Vec_IntPush
(
vStore
,
Type
);
if
(
fEndOfLine
)
continue
;
// read fanins
Offset
=
Vec_IntSize
(
vStore
);
Vec_IntPush
(
vStore
,
0
);
while
(
1
)
{
pToken
=
strtok
(
pStart
,
pChars
);
if
(
pToken
==
NULL
||
pToken
[
0
]
==
'\n'
||
pToken
[
0
]
==
'['
)
break
;
assert
(
pToken
[
0
]
>=
'0'
&&
pToken
[
0
]
<=
'9'
);
Vec_IntPush
(
vStore
,
atoi
(
pToken
)
);
Vec_IntAddToEntry
(
vStore
,
Offset
,
1
);
}
assert
(
pToken
!=
NULL
);
if
(
pToken
[
0
]
==
'\n'
)
continue
;
assert
(
pToken
[
0
]
==
'['
);
// read attribute
pToken
++
;
if
(
Type
==
GIG_LUT
)
{
assert
(
strlen
(
pToken
)
==
4
);
Digit
=
Abc_TtReadHexDigit
(
pToken
[
0
]);
Digit
|=
Abc_TtReadHexDigit
(
pToken
[
1
])
<<
4
;
Digit
|=
Abc_TtReadHexDigit
(
pToken
[
2
])
<<
8
;
Digit
|=
Abc_TtReadHexDigit
(
pToken
[
3
])
<<
12
;
Vec_IntPush
(
vStore
,
Digit
);
}
else
{
assert
(
Type
==
GIG_DELAY
);
Vec_IntPush
(
vStore
,
atoi
(
pToken
)
);
}
// read end of line
pToken
=
strtok
(
pStart
,
pChars
);
assert
(
pToken
[
0
]
==
'\n'
);
}
ABC_FREE
(
pBuffer
);
// create AIG
pNew
=
Gia_ManBuildGig
(
vObjs
,
vStore
);
// cleanup
Vec_IntFree
(
vObjs
);
Vec_IntFree
(
vStore
);
return
pNew
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
src/aig/gia/module.make
View file @
f04d3273
...
@@ -24,6 +24,7 @@ SRC += src/aig/gia/giaAig.c \
...
@@ -24,6 +24,7 @@ SRC += src/aig/gia/giaAig.c \
src/aig/gia/giaFrames.c
\
src/aig/gia/giaFrames.c
\
src/aig/gia/giaFront.c
\
src/aig/gia/giaFront.c
\
src/aig/gia/giaFx.c
\
src/aig/gia/giaFx.c
\
src/aig/gia/giaGig.c
\
src/aig/gia/giaGlitch.c
\
src/aig/gia/giaGlitch.c
\
src/aig/gia/giaHash.c
\
src/aig/gia/giaHash.c
\
src/aig/gia/giaIf.c
\
src/aig/gia/giaIf.c
\
...
...
src/base/io/io.c
View file @
f04d3273
...
@@ -45,6 +45,7 @@ static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv );
...
@@ -45,6 +45,7 @@ static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv );
static
int
IoCommandReadTruth
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadTruth
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadVerilog
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadVerilog
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadStatus
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadStatus
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadGig
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandWrite
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandWrite
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandWriteHie
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandWriteHie
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
@@ -108,6 +109,7 @@ void Io_Init( Abc_Frame_t * pAbc )
...
@@ -108,6 +109,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_truth"
,
IoCommandReadTruth
,
1
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_truth"
,
IoCommandReadTruth
,
1
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_verilog"
,
IoCommandReadVerilog
,
1
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_verilog"
,
IoCommandReadVerilog
,
1
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_status"
,
IoCommandReadStatus
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_status"
,
IoCommandReadStatus
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"&read_gig"
,
IoCommandReadGig
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write"
,
IoCommandWrite
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write"
,
IoCommandWrite
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write_hie"
,
IoCommandWriteHie
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write_hie"
,
IoCommandWriteHie
,
0
);
...
@@ -1132,6 +1134,63 @@ usage:
...
@@ -1132,6 +1134,63 @@ usage:
return
1
;
return
1
;
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
IoCommandReadGig
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
Gia_Man_t
*
Gia_ManReadGig
(
char
*
pFileName
);
Gia_Man_t
*
pAig
;
char
*
pFileName
;
FILE
*
pFile
;
int
c
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"h"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
if
(
argc
!=
globalUtilOptind
+
1
)
{
goto
usage
;
}
// get the input file name
pFileName
=
argv
[
globalUtilOptind
];
if
(
(
pFile
=
fopen
(
pFileName
,
"r"
))
==
NULL
)
{
fprintf
(
pAbc
->
Err
,
"Cannot open input file
\"
%s
\"
.
\n
"
,
pFileName
);
return
1
;
}
fclose
(
pFile
);
// set the new network
pAig
=
Gia_ManReadGig
(
pFileName
);
//Abc_FrameUpdateGia( pAbc, pAig );
return
0
;
usage:
fprintf
(
pAbc
->
Err
,
"usage: &read_gig [-h] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
reads design in GIG format
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : prints the command summary
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : the name of a file to read
\n
"
);
return
1
;
}
/**Function*************************************************************
/**Function*************************************************************
...
...
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