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
17ab7c71
Commit
17ab7c71
authored
Jul 02, 2008
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version abc80702_2
parent
303baf27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
221 additions
and
2 deletions
+221
-2
src/aig/ntl/ntlReadBlif.c
+37
-0
src/aig/ntl/ntlWriteBlif.c
+184
-2
No files found.
src/aig/ntl/ntlReadBlif.c
View file @
17ab7c71
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "ntl.h"
#include "ntl.h"
#include "bzlib.h"
#include "bzlib.h"
#include "zlib.h"
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
/// DECLARATIONS ///
...
@@ -84,6 +85,7 @@ static Ioa_ReadMod_t * Ioa_ReadModAlloc();
...
@@ -84,6 +85,7 @@ static Ioa_ReadMod_t * Ioa_ReadModAlloc();
static
void
Ioa_ReadModFree
(
Ioa_ReadMod_t
*
p
);
static
void
Ioa_ReadModFree
(
Ioa_ReadMod_t
*
p
);
static
char
*
Ioa_ReadLoadFile
(
char
*
pFileName
);
static
char
*
Ioa_ReadLoadFile
(
char
*
pFileName
);
static
char
*
Ioa_ReadLoadFileBz2
(
char
*
pFileName
);
static
char
*
Ioa_ReadLoadFileBz2
(
char
*
pFileName
);
static
char
*
Ioa_ReadLoadFileGz
(
char
*
pFileName
);
static
void
Ioa_ReadReadPreparse
(
Ioa_ReadMan_t
*
p
);
static
void
Ioa_ReadReadPreparse
(
Ioa_ReadMan_t
*
p
);
static
int
Ioa_ReadReadInterfaces
(
Ioa_ReadMan_t
*
p
);
static
int
Ioa_ReadReadInterfaces
(
Ioa_ReadMan_t
*
p
);
static
Ntl_Man_t
*
Ioa_ReadParse
(
Ioa_ReadMan_t
*
p
);
static
Ntl_Man_t
*
Ioa_ReadParse
(
Ioa_ReadMan_t
*
p
);
...
@@ -137,6 +139,8 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
...
@@ -137,6 +139,8 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
p
->
pFileName
=
pFileName
;
p
->
pFileName
=
pFileName
;
if
(
!
strncmp
(
pFileName
+
strlen
(
pFileName
)
-
4
,
".bz2"
,
4
)
)
if
(
!
strncmp
(
pFileName
+
strlen
(
pFileName
)
-
4
,
".bz2"
,
4
)
)
p
->
pBuffer
=
Ioa_ReadLoadFileBz2
(
pFileName
);
p
->
pBuffer
=
Ioa_ReadLoadFileBz2
(
pFileName
);
else
if
(
!
strncmp
(
pFileName
+
strlen
(
pFileName
)
-
3
,
".gz"
,
3
)
)
p
->
pBuffer
=
Ioa_ReadLoadFileGz
(
pFileName
);
else
else
p
->
pBuffer
=
Ioa_ReadLoadFile
(
pFileName
);
p
->
pBuffer
=
Ioa_ReadLoadFile
(
pFileName
);
if
(
p
->
pBuffer
==
NULL
)
if
(
p
->
pBuffer
==
NULL
)
...
@@ -541,6 +545,39 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
...
@@ -541,6 +545,39 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
/**Function*************************************************************
/**Function*************************************************************
Synopsis [Reads the file into a character buffer.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
char
*
Ioa_ReadLoadFileGz
(
char
*
pFileName
)
{
const
int
READ_BLOCK_SIZE
=
100000
;
FILE
*
pFile
;
char
*
pContents
;
int
amtRead
,
readBlock
,
nFileSize
=
READ_BLOCK_SIZE
;
pFile
=
gzopen
(
pFileName
,
"rb"
);
// if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
pContents
=
ALLOC
(
char
,
nFileSize
);
readBlock
=
0
;
while
((
amtRead
=
gzread
(
pFile
,
pContents
+
readBlock
*
READ_BLOCK_SIZE
,
READ_BLOCK_SIZE
))
==
READ_BLOCK_SIZE
)
{
//printf("%d: read %d bytes\n", readBlock, amtRead);
nFileSize
+=
READ_BLOCK_SIZE
;
pContents
=
REALLOC
(
char
,
pContents
,
nFileSize
);
++
readBlock
;
}
//printf("%d: read %d bytes\n", readBlock, amtRead);
assert
(
amtRead
!=
-
1
);
// indicates a zlib error
nFileSize
-=
(
READ_BLOCK_SIZE
-
amtRead
);
gzclose
(
pFile
);
return
pContents
;
}
/**Function*************************************************************
Synopsis [Prepares the parsing.]
Synopsis [Prepares the parsing.]
Description [Performs several preliminary operations:
Description [Performs several preliminary operations:
...
...
src/aig/ntl/ntlWriteBlif.c
View file @
17ab7c71
...
@@ -23,8 +23,9 @@
...
@@ -23,8 +23,9 @@
#include "ntl.h"
#include "ntl.h"
#include "ioa.h"
#include "ioa.h"
#include "bzlib.h"
#include <stdarg.h>
#include <stdarg.h>
#include "bzlib.h"
#include "zlib.h"
#ifdef _WIN32
#ifdef _WIN32
#define vsnprintf _vsnprintf
#define vsnprintf _vsnprintf
...
@@ -286,6 +287,180 @@ int fprintfBz2(bz2file * b, char * fmt, ...) {
...
@@ -286,6 +287,180 @@ int fprintfBz2(bz2file * b, char * fmt, ...) {
}
}
}
}
/**Function*************************************************************
Synopsis [Writes one model into the BLIF file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Ioa_WriteBlifModelGz
(
gzFile
pFile
,
Ntl_Mod_t
*
pModel
,
int
fMain
)
{
Ntl_Obj_t
*
pObj
;
Ntl_Net_t
*
pNet
;
float
Delay
;
int
i
,
k
;
gzprintf
(
pFile
,
".model %s
\n
"
,
pModel
->
pName
);
if
(
pModel
->
attrWhite
||
pModel
->
attrBox
||
pModel
->
attrComb
||
pModel
->
attrKeep
)
{
gzprintf
(
pFile
,
".attrib"
);
gzprintf
(
pFile
,
" %s"
,
pModel
->
attrWhite
?
"white"
:
"black"
);
gzprintf
(
pFile
,
" %s"
,
pModel
->
attrBox
?
"box"
:
"logic"
);
gzprintf
(
pFile
,
" %s"
,
pModel
->
attrComb
?
"comb"
:
"seq"
);
// gzprintf( pFile, " %s", pModel->attrKeep? "keep" : "sweep" );
gzprintf
(
pFile
,
"
\n
"
);
}
gzprintf
(
pFile
,
".inputs"
);
Ntl_ModelForEachPi
(
pModel
,
pObj
,
i
)
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanout0
(
pObj
)
->
pName
);
gzprintf
(
pFile
,
"
\n
"
);
gzprintf
(
pFile
,
".outputs"
);
Ntl_ModelForEachPo
(
pModel
,
pObj
,
i
)
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanin0
(
pObj
)
->
pName
);
gzprintf
(
pFile
,
"
\n
"
);
// write delays
if
(
pModel
->
vDelays
)
{
for
(
i
=
0
;
i
<
Vec_IntSize
(
pModel
->
vDelays
);
i
+=
3
)
{
gzprintf
(
pFile
,
".delay"
);
if
(
Vec_IntEntry
(
pModel
->
vDelays
,
i
)
!=
-
1
)
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanout0
(
Ntl_ModelPi
(
pModel
,
Vec_IntEntry
(
pModel
->
vDelays
,
i
)))
->
pName
);
if
(
Vec_IntEntry
(
pModel
->
vDelays
,
i
+
1
)
!=
-
1
)
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanin0
(
Ntl_ModelPo
(
pModel
,
Vec_IntEntry
(
pModel
->
vDelays
,
i
+
1
)))
->
pName
);
gzprintf
(
pFile
,
" %.3f"
,
Aig_Int2Float
(
Vec_IntEntry
(
pModel
->
vDelays
,
i
+
2
))
);
gzprintf
(
pFile
,
"
\n
"
);
}
}
if
(
pModel
->
vTimeInputs
)
{
for
(
i
=
0
;
i
<
Vec_IntSize
(
pModel
->
vTimeInputs
);
i
+=
2
)
{
if
(
fMain
)
gzprintf
(
pFile
,
".input_arrival"
);
else
gzprintf
(
pFile
,
".input_required"
);
if
(
Vec_IntEntry
(
pModel
->
vTimeInputs
,
i
)
!=
-
1
)
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanout0
(
Ntl_ModelPi
(
pModel
,
Vec_IntEntry
(
pModel
->
vTimeInputs
,
i
)))
->
pName
);
Delay
=
Aig_Int2Float
(
Vec_IntEntry
(
pModel
->
vTimeInputs
,
i
+
1
));
if
(
Delay
==
-
TIM_ETERNITY
)
gzprintf
(
pFile
,
" -inf"
);
else
if
(
Delay
==
TIM_ETERNITY
)
gzprintf
(
pFile
,
" inf"
);
else
gzprintf
(
pFile
,
" %.3f"
,
Delay
);
gzprintf
(
pFile
,
"
\n
"
);
}
}
if
(
pModel
->
vTimeOutputs
)
{
for
(
i
=
0
;
i
<
Vec_IntSize
(
pModel
->
vTimeOutputs
);
i
+=
2
)
{
if
(
fMain
)
gzprintf
(
pFile
,
".output_required"
);
else
gzprintf
(
pFile
,
".output_arrival"
);
if
(
Vec_IntEntry
(
pModel
->
vTimeOutputs
,
i
)
!=
-
1
)
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanin0
(
Ntl_ModelPo
(
pModel
,
Vec_IntEntry
(
pModel
->
vTimeOutputs
,
i
)))
->
pName
);
Delay
=
Aig_Int2Float
(
Vec_IntEntry
(
pModel
->
vTimeOutputs
,
i
+
1
));
if
(
Delay
==
-
TIM_ETERNITY
)
gzprintf
(
pFile
,
" -inf"
);
else
if
(
Delay
==
TIM_ETERNITY
)
gzprintf
(
pFile
,
" inf"
);
else
gzprintf
(
pFile
,
" %.3f"
,
Delay
);
gzprintf
(
pFile
,
"
\n
"
);
}
}
// write objects
Ntl_ModelForEachObj
(
pModel
,
pObj
,
i
)
{
if
(
Ntl_ObjIsNode
(
pObj
)
)
{
gzprintf
(
pFile
,
".names"
);
Ntl_ObjForEachFanin
(
pObj
,
pNet
,
k
)
gzprintf
(
pFile
,
" %s"
,
pNet
->
pName
);
gzprintf
(
pFile
,
" %s
\n
"
,
Ntl_ObjFanout0
(
pObj
)
->
pName
);
gzprintf
(
pFile
,
"%s"
,
pObj
->
pSop
);
}
else
if
(
Ntl_ObjIsLatch
(
pObj
)
)
{
gzprintf
(
pFile
,
".latch"
);
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanin0
(
pObj
)
->
pName
);
gzprintf
(
pFile
,
" %s"
,
Ntl_ObjFanout0
(
pObj
)
->
pName
);
assert
(
pObj
->
LatchId
.
regType
==
0
||
pObj
->
LatchId
.
regClass
==
0
);
if
(
pObj
->
LatchId
.
regType
)
{
if
(
pObj
->
LatchId
.
regType
==
1
)
gzprintf
(
pFile
,
" fe"
);
else
if
(
pObj
->
LatchId
.
regType
==
2
)
gzprintf
(
pFile
,
" re"
);
else
if
(
pObj
->
LatchId
.
regType
==
3
)
gzprintf
(
pFile
,
" ah"
);
else
if
(
pObj
->
LatchId
.
regType
==
4
)
gzprintf
(
pFile
,
" al"
);
else
if
(
pObj
->
LatchId
.
regType
==
5
)
gzprintf
(
pFile
,
" as"
);
else
assert
(
0
);
}
else
if
(
pObj
->
LatchId
.
regClass
)
gzprintf
(
pFile
,
" %d"
,
pObj
->
LatchId
.
regClass
);
if
(
pObj
->
pClock
)
gzprintf
(
pFile
,
" %s"
,
pObj
->
pClock
->
pName
);
gzprintf
(
pFile
,
" %d"
,
pObj
->
LatchId
.
regInit
);
gzprintf
(
pFile
,
"
\n
"
);
}
else
if
(
Ntl_ObjIsBox
(
pObj
)
)
{
gzprintf
(
pFile
,
".subckt %s"
,
pObj
->
pImplem
->
pName
);
Ntl_ObjForEachFanin
(
pObj
,
pNet
,
k
)
gzprintf
(
pFile
,
" %s=%s"
,
Ntl_ModelPiName
(
pObj
->
pImplem
,
k
),
pNet
->
pName
);
Ntl_ObjForEachFanout
(
pObj
,
pNet
,
k
)
gzprintf
(
pFile
,
" %s=%s"
,
Ntl_ModelPoName
(
pObj
->
pImplem
,
k
),
pNet
->
pName
);
gzprintf
(
pFile
,
"
\n
"
);
}
}
gzprintf
(
pFile
,
".end
\n\n
"
);
}
/**Function*************************************************************
Synopsis [Writes the logic network into the BLIF file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Ioa_WriteBlifGz
(
Ntl_Man_t
*
p
,
char
*
pFileName
)
{
Ntl_Mod_t
*
pModel
;
int
i
;
gzFile
pFile
;
// start the output stream
pFile
=
gzopen
(
pFileName
,
"wb"
);
// if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
if
(
pFile
==
NULL
)
{
fprintf
(
stdout
,
"Ioa_WriteBlif(): Cannot open the output file
\"
%s
\"
.
\n
"
,
pFileName
);
return
;
}
gzprintf
(
pFile
,
"# Benchmark
\"
%s
\"
written by ABC-8 on %s
\n
"
,
p
->
pName
,
Ioa_TimeStamp
()
);
// write the models
Ntl_ManForEachModel
(
p
,
pModel
,
i
)
Ioa_WriteBlifModelGz
(
pFile
,
pModel
,
i
==
0
);
// close the file
gzclose
(
pFile
);
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -443,8 +618,15 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
...
@@ -443,8 +618,15 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
{
{
Ntl_Mod_t
*
pModel
;
Ntl_Mod_t
*
pModel
;
int
i
,
bzError
;
int
i
,
bzError
;
bz2file
b
;
bz2file
b
;
// write the GZ file
if
(
!
strncmp
(
pFileName
+
strlen
(
pFileName
)
-
3
,
".gz"
,
3
))
{
Ioa_WriteBlifGz
(
p
,
pFileName
);
return
;
}
memset
(
&
b
,
0
,
sizeof
(
b
));
memset
(
&
b
,
0
,
sizeof
(
b
));
b
.
nBytesMax
=
(
1
<<
12
);
b
.
nBytesMax
=
(
1
<<
12
);
b
.
buf
=
ALLOC
(
char
,
b
.
nBytesMax
);
b
.
buf
=
ALLOC
(
char
,
b
.
nBytesMax
);
...
...
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