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
fb248e1c
Commit
fb248e1c
authored
Dec 16, 2021
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding new command %yosys.
parent
8e72ac36
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
288 additions
and
0 deletions
+288
-0
abclib.dsp
+4
-0
src/base/wlc/wlcCom.c
+120
-0
src/base/wln/module.make
+1
-0
src/base/wln/wlnRtl.c
+163
-0
No files found.
abclib.dsp
View file @
fb248e1c
...
...
@@ -1147,6 +1147,10 @@ SOURCE=.\src\base\wln\wlnRetime.c
# End Source File
# Begin Source File
SOURCE=.\src\base\wln\wlnRtl.c
# End Source File
# Begin Source File
SOURCE=.\src\base\wln\wlnWlc.c
# End Source File
# Begin Source File
...
...
src/base/wlc/wlcCom.c
View file @
fb248e1c
...
...
@@ -32,6 +32,7 @@ ABC_NAMESPACE_IMPL_START
static
int
Abc_CommandReadWlc
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandWriteWlc
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandYosys
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandPs
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandCone
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbs
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
...
@@ -79,6 +80,7 @@ void Wlc_Init( Abc_Frame_t * pAbc )
{
Cmd_CommandAdd
(
pAbc
,
"Word level"
,
"%read"
,
Abc_CommandReadWlc
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Word level"
,
"%write"
,
Abc_CommandWriteWlc
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Word level"
,
"%yosys"
,
Abc_CommandYosys
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Word level"
,
"%ps"
,
Abc_CommandPs
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Word level"
,
"%cone"
,
Abc_CommandCone
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Word level"
,
"%abs"
,
Abc_CommandAbs
,
0
);
...
...
@@ -295,6 +297,124 @@ usage:
return
1
;
}
/**Function********************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
******************************************************************************/
int
Abc_CommandYosys
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
Gia_Man_t
*
Wln_BlastSystemVerilog
(
char
*
pFileName
,
char
*
pTopModule
,
int
fSkipStrash
,
int
fInvert
,
int
fVerbose
);
extern
Wln_Ntk_t
*
Wln_ReadSystemVerilog
(
char
*
pFileName
,
char
*
pTopModule
,
int
fVerbose
);
FILE
*
pFile
;
char
*
pFileName
=
NULL
;
char
*
pTopModule
=
NULL
;
int
fCollapse
=
0
;
int
fBlast
=
0
;
int
fInvert
=
0
;
int
fSkipStrash
=
0
;
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"Tcaisvh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'T'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-T
\"
should be followed by a file name.
\n
"
);
goto
usage
;
}
pTopModule
=
argv
[
globalUtilOptind
];
globalUtilOptind
++
;
break
;
case
'c'
:
fCollapse
^=
1
;
break
;
case
'a'
:
fBlast
^=
1
;
break
;
case
'i'
:
fInvert
^=
1
;
break
;
case
's'
:
fSkipStrash
^=
1
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
if
(
argc
!=
globalUtilOptind
+
1
)
{
printf
(
"Abc_CommandReadWlc(): Input file name should be given on the command line.
\n
"
);
return
0
;
}
// get the file name
pFileName
=
argv
[
globalUtilOptind
];
if
(
(
pFile
=
fopen
(
pFileName
,
"r"
))
==
NULL
)
{
Abc_Print
(
1
,
"Cannot open input file
\"
%s
\"
. "
,
pFileName
);
if
(
(
pFileName
=
Extra_FileGetSimilarName
(
pFileName
,
".v"
,
".sv"
,
NULL
,
NULL
,
NULL
))
)
Abc_Print
(
1
,
"Did you mean
\"
%s
\"
?"
,
pFileName
);
Abc_Print
(
1
,
"
\n
"
);
return
0
;
}
fclose
(
pFile
);
// perform reading
if
(
fBlast
)
{
Gia_Man_t
*
pNew
=
NULL
;
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
pNew
=
Wln_BlastSystemVerilog
(
pFileName
,
pTopModule
,
fSkipStrash
,
fInvert
,
fVerbose
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"sv"
)
)
pNew
=
Wln_BlastSystemVerilog
(
pFileName
,
pTopModule
,
fSkipStrash
,
fInvert
,
fVerbose
);
else
{
printf
(
"Abc_CommandYosys(): Unknown file extension.
\n
"
);
return
0
;
}
Abc_FrameUpdateGia
(
pAbc
,
pNew
);
}
else
{
Wln_Ntk_t
*
pNtk
=
NULL
;
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
pNtk
=
Wln_ReadSystemVerilog
(
pFileName
,
pTopModule
,
fVerbose
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"sv"
)
)
pNtk
=
Wln_ReadSystemVerilog
(
pFileName
,
pTopModule
,
fVerbose
);
else
{
printf
(
"Abc_CommandYosys(): Unknown file extension.
\n
"
);
return
0
;
}
//Wlc_AbcUpdateNtk( pAbc, pNtk );
}
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: %%yosys [-T <module>] [-caisvh] <file_name>
\n
"
);
Abc_Print
(
-
2
,
"
\t
reads Verilog or SystemVerilog using Yosys
\n
"
);
Abc_Print
(
-
2
,
"
\t
-T : specify the top module name (default uses
\"
-auto-top
\"\n
"
);
Abc_Print
(
-
2
,
"
\t
-c : toggle collapsing the design using Yosys [default = %s]
\n
"
,
fCollapse
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-a : toggle bit-blasting the design using Yosys [default = %s]
\n
"
,
fBlast
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-i : toggle interting the outputs (useful for miters) [default = %s]
\n
"
,
fInvert
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-s : toggle no structural hashing during bit-blasting [default = %s]
\n
"
,
fSkipStrash
?
"no strash"
:
"strash"
);
Abc_Print
(
-
2
,
"
\t
-v : toggle printing verbose information [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
}
/**Function********************************************************************
...
...
src/base/wln/module.make
View file @
fb248e1c
...
...
@@ -4,5 +4,6 @@ SRC += src/base/wln/wln.c \
src/base/wln/wlnNtk.c
\
src/base/wln/wlnObj.c
\
src/base/wln/wlnRetime.c
\
src/base/wln/wlnRtl.c
\
src/base/wln/wlnWlc.c
\
src/base/wln/wlnWriteVer.c
src/base/wln/wlnRtl.c
0 → 100644
View file @
fb248e1c
/**CFile****************************************************************
FileName [wlnRtl.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Word-level network.]
Synopsis [Constructing WLN network from Rtl data structure.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - September 23, 2018.]
Revision [$Id: wlnRtl.c,v 1.00 2018/09/23 00:00:00 alanmi Exp $]
***********************************************************************/
#include "wln.h"
#include "base/main/main.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Wln_Ntk_t
*
Wln_ReadRtl
(
char
*
pFileName
)
{
return
NULL
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
char
*
Wln_GetYosysName
()
{
char
*
pYosysName
=
NULL
;
char
*
pYosysNameWin
=
"yosys.exe"
;
char
*
pYosysNameUnix
=
"yosys"
;
if
(
Abc_FrameReadFlag
(
"yosyswin"
)
)
pYosysNameWin
=
Abc_FrameReadFlag
(
"yosyswin"
);
if
(
Abc_FrameReadFlag
(
"yosysunix"
)
)
pYosysNameUnix
=
Abc_FrameReadFlag
(
"yosysunix"
);
#ifdef WIN32
pYosysName
=
pYosysNameWin
;
#else
pYosysName
=
pYosysNameUnix
;
#endif
return
pYosysName
;
}
int
Wln_ConvertToRtl
(
char
*
pCommand
,
char
*
pFileTemp
)
{
FILE
*
pFile
;
if
(
system
(
pCommand
)
==
-
1
)
{
fprintf
(
stdout
,
"Cannot execute
\"
%s
\"
.
\n
"
,
pCommand
);
return
0
;
}
if
(
(
pFile
=
fopen
(
pFileTemp
,
"r"
))
==
NULL
)
{
fprintf
(
stdout
,
"Cannot open intermediate file
\"
%s
\"
.
\n
"
,
pFileTemp
);
return
0
;
}
fclose
(
pFile
);
return
1
;
}
Wln_Ntk_t
*
Wln_ReadSystemVerilog
(
char
*
pFileName
,
char
*
pTopModule
,
int
fVerbose
)
{
Wln_Ntk_t
*
pNtk
=
NULL
;
char
Command
[
1000
];
char
*
pFileTemp
=
"_temp_.rtlil"
;
int
fSVlog
=
strstr
(
pFileName
,
".sv"
)
!=
NULL
;
sprintf
(
Command
,
"%s -qp
\"
read_verilog %s%s; hierarchy %s%s; flatten; proc; write_rtlil %s
\"
"
,
Wln_GetYosysName
(),
fSVlog
?
"-sv "
:
""
,
pFileName
,
pTopModule
?
"-top "
:
"-auto-top"
,
pTopModule
?
pTopModule
:
""
,
pFileTemp
);
if
(
fVerbose
)
printf
(
"%s
\n
"
,
Command
);
if
(
!
Wln_ConvertToRtl
(
Command
,
pFileTemp
)
)
{
return
NULL
;
}
pNtk
=
Wln_ReadRtl
(
pFileTemp
);
if
(
pNtk
==
NULL
)
{
printf
(
"Dumped the design into file
\"
%s
\"
.
\n
"
,
pFileTemp
);
return
NULL
;
}
#ifdef WIN32
_unlink
(
pFileTemp
);
#else
unlink
(
pFileTemp
);
#endif
return
pNtk
;
}
Gia_Man_t
*
Wln_BlastSystemVerilog
(
char
*
pFileName
,
char
*
pTopModule
,
int
fSkipStrash
,
int
fInvert
,
int
fVerbose
)
{
Gia_Man_t
*
pGia
=
NULL
;
char
Command
[
1000
];
char
*
pFileTemp
=
"_temp_.aig"
;
int
fSVlog
=
strstr
(
pFileName
,
".sv"
)
!=
NULL
;
sprintf
(
Command
,
"%s -qp
\"
read_verilog %s%s; hierarchy %s%s; flatten; proc; aigmap; write_aiger %s
\"
"
,
Wln_GetYosysName
(),
fSVlog
?
"-sv "
:
""
,
pFileName
,
pTopModule
?
"-top "
:
"-auto-top"
,
pTopModule
?
pTopModule
:
""
,
pFileTemp
);
if
(
fVerbose
)
printf
(
"%s
\n
"
,
Command
);
if
(
!
Wln_ConvertToRtl
(
Command
,
pFileTemp
)
)
return
NULL
;
pGia
=
Gia_AigerRead
(
pFileTemp
,
0
,
fSkipStrash
,
0
);
if
(
pGia
==
NULL
)
{
printf
(
"Converting to AIG has failed.
\n
"
);
return
NULL
;
}
ABC_FREE
(
pGia
->
pName
);
pGia
->
pName
=
pTopModule
?
Abc_UtilStrsav
(
pTopModule
)
:
Extra_FileNameGeneric
(
Extra_FileNameWithoutPath
(
pFileName
)
);
#ifdef WIN32
_unlink
(
pFileTemp
);
#else
unlink
(
pFileTemp
);
#endif
// complement the outputs
if
(
fInvert
)
{
Gia_Obj_t
*
pObj
;
int
i
;
Gia_ManForEachPo
(
pGia
,
pObj
,
i
)
Gia_ObjFlipFaninC0
(
pObj
);
}
return
pGia
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_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