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
ada07311
Commit
ada07311
authored
Oct 01, 2020
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New command 'read_sf'.
parent
f1eb9339
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
0 deletions
+128
-0
src/base/io/io.c
+73
-0
src/base/io/ioUtil.c
+55
-0
No files found.
src/base/io/io.c
View file @
ada07311
...
...
@@ -24,6 +24,10 @@
#include "proof/abs/abs.h"
#include "sat/bmc/bmc.h"
#ifdef WIN32
#define unlink _unlink
#endif
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
...
...
@@ -49,6 +53,7 @@ static int IoCommandReadVerilog ( 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
IoCommandReadJson
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
IoCommandReadSF
(
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
);
...
...
@@ -118,6 +123,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_status"
,
IoCommandReadStatus
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"&read_gig"
,
IoCommandReadGig
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_json"
,
IoCommandReadJson
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"read_sf"
,
IoCommandReadSF
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write"
,
IoCommandWrite
,
0
);
Cmd_CommandAdd
(
pAbc
,
"I/O"
,
"write_hie"
,
IoCommandWriteHie
,
0
);
...
...
@@ -1415,6 +1421,73 @@ usage:
return
1
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
IoCommandReadSF
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Io_TransformSF2PLA
(
char
*
pNameIn
,
char
*
pNameOut
);
Abc_Ntk_t
*
pNtk
;
FILE
*
pFile
;
char
*
pFileName
,
*
pFileTemp
=
"_temp_sf_.pla"
;
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
);
Io_TransformSF2PLA
(
pFileName
,
pFileTemp
);
pNtk
=
Io_Read
(
pFileTemp
,
IO_FILE_PLA
,
1
,
0
);
unlink
(
pFileTemp
);
if
(
pNtk
==
NULL
)
return
1
;
ABC_FREE
(
pNtk
->
pName
);
pNtk
->
pName
=
Extra_FileNameGeneric
(
pFileName
);
ABC_FREE
(
pNtk
->
pSpec
);
pNtk
->
pSpec
=
Abc_UtilStrsav
(
pFileName
);
// replace the current network
Abc_FrameReplaceCurrentNetwork
(
pAbc
,
pNtk
);
Abc_FrameClearVerifStatus
(
pAbc
);
return
0
;
usage:
fprintf
(
pAbc
->
Err
,
"usage: read_sf [-h] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
reads file in SF 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*************************************************************
...
...
src/base/io/ioUtil.c
View file @
ada07311
...
...
@@ -862,6 +862,61 @@ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mo
}
}
/**Function*************************************************************
Synopsis [Tranform SF into PLA.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Io_TransformSF2PLA
(
char
*
pNameIn
,
char
*
pNameOut
)
{
int
fStart
=
0
,
Size
=
1000000
;
char
*
pBuffer
,
*
pToken
;
FILE
*
pFileIn
=
fopen
(
pNameIn
,
"rb"
);
FILE
*
pFileOut
=
fopen
(
pNameOut
,
"wb"
);
if
(
pFileIn
==
NULL
)
{
if
(
pFileOut
)
fclose
(
pFileOut
);
printf
(
"Cannot open file
\"
%s
\"
for reading.
\n
"
,
pNameIn
);
return
;
}
if
(
pFileOut
==
NULL
)
{
if
(
pFileIn
)
fclose
(
pFileIn
);
printf
(
"Cannot open file
\"
%s
\"
for reading.
\n
"
,
pNameOut
);
return
;
}
pBuffer
=
ABC_ALLOC
(
char
,
Size
);
fprintf
(
pFileOut
,
".type fd
\n
"
);
while
(
fgets
(
pBuffer
,
Size
,
pFileIn
)
)
{
if
(
strstr
(
pBuffer
,
"END_SDF"
)
)
break
;
if
(
strstr
(
pBuffer
,
"SDF"
)
)
{
fgets
(
pBuffer
,
Size
,
pFileIn
);
if
(
(
pToken
=
strtok
(
pBuffer
,
"
\t\r\n
"
))
)
fprintf
(
pFileOut
,
".i %d
\n
"
,
atoi
(
pToken
)
);
if
(
(
pToken
=
strtok
(
NULL
,
"
\t\r\n
"
))
)
fprintf
(
pFileOut
,
".o %d
\n
"
,
atoi
(
pToken
)
);
if
(
(
pToken
=
strtok
(
NULL
,
"
\t\r\n
"
))
)
fprintf
(
pFileOut
,
".p %d
\n
"
,
atoi
(
pToken
)
);
fStart
=
1
;
}
else
if
(
fStart
)
fprintf
(
pFileOut
,
"%s"
,
pBuffer
);
}
fprintf
(
pFileOut
,
".e
\n
"
);
fclose
(
pFileIn
);
fclose
(
pFileOut
);
ABC_FREE
(
pBuffer
);
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
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