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
407ba590
Commit
407ba590
authored
Sep 05, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add internal --dump-prefix utility
parent
d335d2ff
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
12 deletions
+47
-12
README.md
+2
-0
src/Convert.hs
+38
-9
src/Job.hs
+4
-0
src/sv2v.hs
+3
-3
No files found.
README.md
View file @
407ba590
...
@@ -103,6 +103,8 @@ Conversion:
...
@@ -103,6 +103,8 @@ Conversion:
Other:
Other:
--oversized-numbers Disable standard-imposed 32-bit limit on unsized
--oversized-numbers Disable standard-imposed 32-bit limit on unsized
number literals (e.g., 'h1_ffff_ffff, 4294967296)
number literals (e.g., 'h1_ffff_ffff, 4294967296)
--dump-prefix=PATH Create intermediate output files with the given
path prefix; used for internal debugging
--help Display help message
--help Display help message
--version Print version information
--version Print version information
--numeric-version Print just the version number
--numeric-version Print just the version number
...
...
src/Convert.hs
View file @
407ba590
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
module
Convert
(
convert
)
where
module
Convert
(
convert
)
where
import
Control.Monad
((
>=>
))
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
import
qualified
Job
(
Exclude
(
..
))
import
qualified
Job
(
Exclude
(
..
))
...
@@ -53,6 +55,7 @@ import qualified Convert.Unsigned
...
@@ -53,6 +55,7 @@ import qualified Convert.Unsigned
import
qualified
Convert.Wildcard
import
qualified
Convert.Wildcard
type
Phase
=
[
AST
]
->
[
AST
]
type
Phase
=
[
AST
]
->
[
AST
]
type
IOPhase
=
[
AST
]
->
IO
[
AST
]
type
Selector
=
Job
.
Exclude
->
Phase
->
Phase
type
Selector
=
Job
.
Exclude
->
Phase
->
Phase
finalPhases
::
Selector
->
[
Phase
]
finalPhases
::
Selector
->
[
Phase
]
...
@@ -109,22 +112,48 @@ initialPhases selectExclude =
...
@@ -109,22 +112,48 @@ initialPhases selectExclude =
,
Convert
.
UnnamedGenBlock
.
convert
,
Convert
.
UnnamedGenBlock
.
convert
]
]
convert
::
[
Job
.
Exclude
]
->
Phase
convert
::
FilePath
->
[
Job
.
Exclude
]
->
IOPhase
convert
excludes
=
convert
dumpPrefix
excludes
=
final
.
loopMain
.
initial
step
"parse"
id
>=>
step
"initial"
initial
>=>
loop
1
"main"
main
>=>
step
"final"
final
where
where
final
=
combine
$
finalPhases
selectExclude
final
=
combine
$
finalPhases
selectExclude
main
=
combine
$
mainPhases
selectExclude
main
=
combine
$
mainPhases
selectExclude
initial
=
combine
$
initialPhases
selectExclude
initial
=
combine
$
initialPhases
selectExclude
combine
=
foldr1
(
.
)
combine
=
foldr1
(
.
)
loopMain
::
Phase
loopMain
descriptions
=
if
descriptions
==
descriptions'
then
descriptions
else
loopMain
descriptions'
where
descriptions'
=
main
descriptions
selectExclude
::
Selector
selectExclude
::
Selector
selectExclude
exclude
phase
=
selectExclude
exclude
phase
=
if
elem
exclude
excludes
if
elem
exclude
excludes
then
id
then
id
else
phase
else
phase
dumper
::
String
->
IOPhase
dumper
=
if
null
dumpPrefix
then
const
return
else
fileDumper
dumpPrefix
-- add debug dumping to a phase
step
::
String
->
Phase
->
IOPhase
step
key
=
(
dumper
key
.
)
-- add convergence and debug dumping to a phase
loop
::
Int
->
String
->
Phase
->
IOPhase
loop
idx
key
phase
files
=
if
files
==
files'
then
return
files
else
dumper
key'
files'
>>=
loop
(
idx
+
1
)
key
phase
where
files'
=
phase
files
key'
=
key
++
"_"
++
show
idx
-- pass through dumper which writes ASTs to a file
fileDumper
::
String
->
String
->
IOPhase
fileDumper
prefix
key
files
=
do
let
path
=
prefix
++
key
++
".sv"
let
output
=
show
$
concat
files
writeFile
path
output
return
files
src/Job.hs
View file @
407ba590
...
@@ -44,6 +44,7 @@ data Job = Job
...
@@ -44,6 +44,7 @@ data Job = Job
,
write
::
Write
,
write
::
Write
,
writeRaw
::
String
,
writeRaw
::
String
,
oversizedNumbers
::
Bool
,
oversizedNumbers
::
Bool
,
dumpPrefix
::
FilePath
}
deriving
(
Typeable
,
Data
)
}
deriving
(
Typeable
,
Data
)
version
::
String
version
::
String
...
@@ -76,6 +77,9 @@ defaultJob = Job
...
@@ -76,6 +77,9 @@ defaultJob = Job
&=
help
(
"Disable standard-imposed 32-bit limit on unsized number"
&=
help
(
"Disable standard-imposed 32-bit limit on unsized number"
++
" literals (e.g., 'h1_ffff_ffff, 4294967296)"
)
++
" literals (e.g., 'h1_ffff_ffff, 4294967296)"
)
&=
groupname
"Other"
&=
groupname
"Other"
,
dumpPrefix
=
def
&=
name
"dump-prefix"
&=
explicit
&=
typ
"PATH"
&=
help
(
"Create intermediate output files with the given path prefix;"
++
" used for internal debugging"
)
}
}
&=
program
"sv2v"
&=
program
"sv2v"
&=
summary
(
"sv2v "
++
version
)
&=
summary
(
"sv2v "
++
version
)
...
...
src/sv2v.hs
View file @
407ba590
...
@@ -89,9 +89,9 @@ main = do
...
@@ -89,9 +89,9 @@ main = do
exitFailure
exitFailure
Right
asts
->
do
Right
asts
->
do
-- convert the files if requested
-- convert the files if requested
let
asts'
=
if
passThrough
job
asts'
<-
if
passThrough
job
the
n
asts
then
retur
n
asts
else
convert
(
exclude
job
)
asts
else
convert
(
dumpPrefix
job
)
(
exclude
job
)
asts
emptyWarnings
(
concat
asts
)
(
concat
asts'
)
emptyWarnings
(
concat
asts
)
(
concat
asts'
)
-- write the converted files out
-- write the converted files out
writeOutput
(
write
job
)
(
files
job
)
asts'
writeOutput
(
write
job
)
(
files
job
)
asts'
...
...
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