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.
...
@@ -67,15 +67,18 @@ Below is the current usage printout. This interface is subject to change.
```
```
sv2v [OPTIONS] [FILES]
sv2v [OPTIONS] [FILES]
Common flags:
Preprocessing:
-e --exclude=CONV exclude a particular conversion (always,
-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)
interface, or logic)
-i --incdir=DIR add directory to include search path
-v --verbose Retain certain conversion artifacts
-d --define=NAME[=VALUE] define a macro for preprocessing
Other:
-o --oneunit put all files in one compilation unit, so macros
--help Display help message
from earlier files remain defined in later files
--version Print version information
-? --help Display help message
-V --version Print version information
--numeric-version Print just the version number
--numeric-version Print just the version number
```
```
...
...
src/Job.hs
View file @
c0e38f79
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
module
Job
where
module
Job
where
import
System.IO
(
stderr
,
hPutStr
)
import
System.Console.CmdArgs
import
System.Console.CmdArgs
import
System.Environment
(
getArgs
,
withArgs
)
data
Exclude
data
Exclude
=
Always
=
Always
...
@@ -17,34 +19,84 @@ data Exclude
...
@@ -17,34 +19,84 @@ data Exclude
deriving
(
Show
,
Typeable
,
Data
,
Eq
)
deriving
(
Show
,
Typeable
,
Data
,
Eq
)
data
Job
=
Job
data
Job
=
Job
{
exclude
::
[
Exclude
]
{
files
::
[
FilePath
]
,
files
::
[
FilePath
]
,
incdir
::
[
FilePath
]
,
incdir
::
[
FilePath
]
,
define
::
[
String
]
,
define
::
[
String
]
,
oneunit
::
Bool
,
siloed
::
Bool
,
exclude
::
[
Exclude
]
,
verbose
::
Bool
,
verbose
::
Bool
}
deriving
(
Show
,
Typeable
,
Data
)
}
deriving
(
Show
,
Typeable
,
Data
)
defaultJob
::
Job
defaultJob
::
Job
defaultJob
=
Job
defaultJob
=
Job
{
exclude
=
[]
&=
typ
"CONV"
{
files
=
def
&=
args
&=
typ
"FILES"
&=
help
"exclude a particular conversion (always, interface, or logic)"
,
incdir
=
nam_
"I"
&=
name
"incdir"
&=
typDir
,
files
=
def
&=
args
&=
typ
"FILES"
&=
help
"Add directory to include search path"
,
incdir
=
def
&=
typDir
&=
help
"add directory to include search path"
&=
groupname
"Preprocessing"
,
define
=
def
&=
typ
"NAME[=VALUE]"
&=
help
(
"define a macro for"
,
define
=
nam_
"D"
&=
name
"define"
&=
typ
"NAME[=VALUE]"
++
" preprocessing"
)
&=
help
"Define a macro for preprocessing"
,
oneunit
=
False
&=
help
(
"put all files in one compilation unit, so"
,
siloed
=
nam_
"siloed"
&=
help
(
"Lex input files separately, so"
++
" macros from earlier files remain defined in later files"
)
++
" macros from earlier files are not defined in later files"
)
,
verbose
=
False
&=
help
"retain certain conversion artifacts"
,
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"
&=
program
"sv2v"
&=
summary
"sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins"
&=
summary
"sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins"
&=
details
[
"sv2v converts SystemVerilog to Verilog."
&=
details
[
"sv2v converts SystemVerilog to Verilog."
,
"More info: https://github.com/zachjs/sv2v"
]
,
"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
::
IO
Job
readJob
=
do
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
return
$
if
verbose
job
then
job
{
exclude
=
Succinct
:
exclude
job
}
then
job
{
exclude
=
Succinct
:
exclude
job
}
else
job
else
job
src/sv2v.hs
View file @
c0e38f79
...
@@ -8,7 +8,7 @@ import System.IO
...
@@ -8,7 +8,7 @@ import System.IO
import
System.Exit
import
System.Exit
import
Data.List
(
elemIndex
)
import
Data.List
(
elemIndex
)
import
Job
(
readJob
,
files
,
exclude
,
incdir
,
define
,
oneunit
)
import
Job
(
readJob
,
files
,
exclude
,
incdir
,
define
,
siloed
)
import
Convert
(
convert
)
import
Convert
(
convert
)
import
Language.SystemVerilog.Parser
(
parseFiles
)
import
Language.SystemVerilog.Parser
(
parseFiles
)
...
@@ -25,7 +25,7 @@ main = do
...
@@ -25,7 +25,7 @@ main = do
let
includePaths
=
incdir
job
let
includePaths
=
incdir
job
let
defines
=
map
splitDefine
$
define
job
let
defines
=
map
splitDefine
$
define
job
let
singleton
=
\
x
->
[
x
]
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
astLists
<-
mapM
(
parseFiles
includePaths
defines
)
(
parseFiles
includePaths
defines
)
(
toFileLists
$
files
job
)
(
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