Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
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
sv2v
Commits
c0e38f79
Commit
c0e38f79
authored
Sep 15, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated CLI (backwards compatible)
parent
2a51d20f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
23 deletions
+78
-23
README.md
+11
-8
src/Job.hs
+65
-13
src/sv2v.hs
+2
-2
No files found.
README.md
View file @
c0e38f79
...
...
@@ -67,15 +67,18 @@ Below is the current usage printout. This interface is subject to change.
```
sv2v [OPTIONS] [FILES]
Common flags:
-e --exclude=CONV exclude a particular conversion (always,
Preprocessing:
-I --incdir=DIR Add directory to include search path
-D --define=NAME[=VALUE] Define a macro for preprocessing
--siloed Lex input files separately, so macros from
earlier files are not defined in later files
Conversion:
-E --exclude=CONV Exclude a particular conversion (always,
interface, or logic)
-i --incdir=DIR add directory to include search path
-d --define=NAME[=VALUE] define a macro for preprocessing
-o --oneunit put all files in one compilation unit, so macros
from earlier files remain defined in later files
-? --help Display help message
-V --version Print version information
-v --verbose Retain certain conversion artifacts
Other:
--help Display help message
--version Print version information
--numeric-version Print just the version number
```
...
...
src/Job.hs
View file @
c0e38f79
...
...
@@ -7,7 +7,9 @@
module
Job
where
import
System.IO
(
stderr
,
hPutStr
)
import
System.Console.CmdArgs
import
System.Environment
(
getArgs
,
withArgs
)
data
Exclude
=
Always
...
...
@@ -17,34 +19,84 @@ data Exclude
deriving
(
Show
,
Typeable
,
Data
,
Eq
)
data
Job
=
Job
{
exclude
::
[
Exclude
]
,
files
::
[
FilePath
]
{
files
::
[
FilePath
]
,
incdir
::
[
FilePath
]
,
define
::
[
String
]
,
oneunit
::
Bool
,
siloed
::
Bool
,
exclude
::
[
Exclude
]
,
verbose
::
Bool
}
deriving
(
Show
,
Typeable
,
Data
)
defaultJob
::
Job
defaultJob
=
Job
{
exclude
=
[]
&=
typ
"CONV"
&=
help
"exclude a particular conversion (always, interface, or logic)"
,
files
=
def
&=
args
&=
typ
"FILES"
,
incdir
=
def
&=
typDir
&=
help
"add directory to include search path"
,
define
=
def
&=
typ
"NAME[=VALUE]"
&=
help
(
"define a macro for"
++
" preprocessing"
)
,
oneunit
=
False
&=
help
(
"put all files in one compilation unit, so"
++
" macros from earlier files remain defined in later files"
)
,
verbose
=
False
&=
help
"retain certain conversion artifacts"
{
files
=
def
&=
args
&=
typ
"FILES"
,
incdir
=
nam_
"I"
&=
name
"incdir"
&=
typDir
&=
help
"Add directory to include search path"
&=
groupname
"Preprocessing"
,
define
=
nam_
"D"
&=
name
"define"
&=
typ
"NAME[=VALUE]"
&=
help
"Define a macro for preprocessing"
,
siloed
=
nam_
"siloed"
&=
help
(
"Lex input files separately, so"
++
" macros from earlier files are not defined in later files"
)
,
exclude
=
nam_
"exclude"
&=
name
"E"
&=
typ
"CONV"
&=
help
"Exclude a particular conversion (always, interface, or logic)"
&=
groupname
"Conversion"
,
verbose
=
nam
"verbose"
&=
help
"Retain certain conversion artifacts"
}
&=
program
"sv2v"
&=
summary
"sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins"
&=
details
[
"sv2v converts SystemVerilog to Verilog."
,
"More info: https://github.com/zachjs/sv2v"
]
&=
helpArg
[
explicit
,
name
"help"
,
groupname
"Other"
]
&=
versionArg
[
explicit
,
name
"version"
]
&=
verbosityArgs
[
ignore
]
[
ignore
]
where
-- borrowed from: https://github.com/ndmitchell/hlint
nam
xs
=
nam_
xs
&=
name
[
head
xs
]
nam_
xs
=
def
&=
name
xs
&=
explicit
type
DeprecationPhase
=
[
String
]
->
IO
[
String
]
oneunit
::
DeprecationPhase
oneunit
strs
=
do
let
strs'
=
filter
(
not
.
isOneunitArg
)
strs
if
strs
==
strs'
then
return
strs
else
do
hPutStr
stderr
$
"Deprecation warning: --oneunit has been removed, "
++
"and is now on by default
\n
"
return
strs'
where
isOneunitArg
::
String
->
Bool
isOneunitArg
"-o"
=
True
isOneunitArg
"--oneunit"
=
True
isOneunitArg
_
=
False
flagRename
::
String
->
String
->
DeprecationPhase
flagRename
before
after
strs
=
do
let
strs'
=
map
rename
strs
if
strs
==
strs'
then
return
strs
else
do
hPutStr
stderr
$
"Deprecation warning: "
++
before
++
" has been renamed to "
++
after
++
"
\n
"
return
strs'
where
rename
::
String
->
String
rename
arg
=
if
before
==
take
(
length
before
)
arg
then
after
++
drop
(
length
before
)
arg
else
arg
readJob
::
IO
Job
readJob
=
do
job
<-
cmdArgs
defaultJob
strs
<-
getArgs
strs'
<-
oneunit
strs
>>=
flagRename
"-i"
"-I"
>>=
flagRename
"-d"
"-D"
>>=
flagRename
"-e"
"-E"
>>=
flagRename
"-V"
"--version"
>>=
flagRename
"-?"
"--help"
job
<-
withArgs
(
strs'
)
$
cmdArgs
defaultJob
return
$
if
verbose
job
then
job
{
exclude
=
Succinct
:
exclude
job
}
else
job
src/sv2v.hs
View file @
c0e38f79
...
...
@@ -8,7 +8,7 @@ import System.IO
import
System.Exit
import
Data.List
(
elemIndex
)
import
Job
(
readJob
,
files
,
exclude
,
incdir
,
define
,
oneunit
)
import
Job
(
readJob
,
files
,
exclude
,
incdir
,
define
,
siloed
)
import
Convert
(
convert
)
import
Language.SystemVerilog.Parser
(
parseFiles
)
...
...
@@ -25,7 +25,7 @@ main = do
let
includePaths
=
incdir
job
let
defines
=
map
splitDefine
$
define
job
let
singleton
=
\
x
->
[
x
]
let
toFileLists
=
if
oneunit
job
then
singleton
else
map
singleton
let
toFileLists
=
if
siloed
job
then
map
singleton
else
singleton
astLists
<-
mapM
(
parseFiles
includePaths
defines
)
(
toFileLists
$
files
job
)
...
...
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