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
35a0587d
Commit
35a0587d
authored
Nov 20, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preserve else block association (resolved #56)
parent
c1f027e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletions
+66
-1
src/Language/SystemVerilog/AST/Stmt.hs
+18
-1
test/basic/else_prec.sv
+46
-0
test/basic/else_prec.v
+2
-0
No files found.
src/Language/SystemVerilog/AST/Stmt.hs
View file @
35a0587d
...
@@ -94,7 +94,7 @@ instance Show Stmt where
...
@@ -94,7 +94,7 @@ instance Show Stmt where
show
(
Forever
s
)
=
printf
"forever %s"
(
show
s
)
show
(
Forever
s
)
=
printf
"forever %s"
(
show
s
)
show
(
Foreach
x
i
s
)
=
printf
"foreach (%s [ %s ]) %s"
x
(
commas
$
map
(
maybe
""
id
)
i
)
(
show
s
)
show
(
Foreach
x
i
s
)
=
printf
"foreach (%s [ %s ]) %s"
x
(
commas
$
map
(
maybe
""
id
)
i
)
(
show
s
)
show
(
If
u
a
b
Null
)
=
printf
"%sif (%s)%s"
(
maybe
""
showPad
u
)
(
show
a
)
(
showBranch
b
)
show
(
If
u
a
b
Null
)
=
printf
"%sif (%s)%s"
(
maybe
""
showPad
u
)
(
show
a
)
(
showBranch
b
)
show
(
If
u
a
b
c
)
=
printf
"%sif (%s)%s
\n
else%s"
(
maybe
""
showPad
u
)
(
show
a
)
(
showBranch
b
)
(
showElseBranch
c
)
show
(
If
u
a
b
c
)
=
printf
"%sif (%s)%s
\n
else%s"
(
maybe
""
showPad
u
)
(
show
a
)
(
showB
lockedB
ranch
b
)
(
showElseBranch
c
)
show
(
Return
e
)
=
printf
"return %s;"
(
show
e
)
show
(
Return
e
)
=
printf
"return %s;"
(
show
e
)
show
(
Timing
t
s
)
=
printf
"%s%s"
(
show
t
)
(
showShortBranch
s
)
show
(
Timing
t
s
)
=
printf
"%s%s"
(
show
t
)
(
showShortBranch
s
)
show
(
Trigger
b
x
)
=
printf
"->%s %s;"
(
if
b
then
""
else
">"
)
x
show
(
Trigger
b
x
)
=
printf
"->%s %s;"
(
if
b
then
""
else
">"
)
x
...
@@ -107,6 +107,23 @@ showBranch :: Stmt -> String
...
@@ -107,6 +107,23 @@ showBranch :: Stmt -> String
showBranch
(
block
@
Block
{})
=
' '
:
show
block
showBranch
(
block
@
Block
{})
=
' '
:
show
block
showBranch
stmt
=
'
\n
'
:
(
indent
$
show
stmt
)
showBranch
stmt
=
'
\n
'
:
(
indent
$
show
stmt
)
showBlockedBranch
::
Stmt
->
String
showBlockedBranch
stmt
=
showBranch
$
if
isControl
then
Block
Seq
""
[]
[
stmt
]
else
stmt
where
isControl
=
case
stmt
of
If
{}
->
True
For
{}
->
True
While
{}
->
True
RepeatL
{}
->
True
DoWhile
{}
->
True
Forever
{}
->
True
Foreach
{}
->
True
_
->
False
showElseBranch
::
Stmt
->
String
showElseBranch
::
Stmt
->
String
showElseBranch
(
stmt
@
If
{})
=
' '
:
show
stmt
showElseBranch
(
stmt
@
If
{})
=
' '
:
show
stmt
showElseBranch
stmt
=
showBranch
stmt
showElseBranch
stmt
=
showBranch
stmt
...
...
test/basic/else_prec.sv
0 → 100644
View file @
35a0587d
module
top
;
integer
i
;
task
t
;
input
a
,
b
,
c
;
begin
$
display
(
"1 (%b, %b, %b)"
,
a
,
b
,
c
)
;
if
(
a
)
begin
if
(
b
)
begin
$
display
(
"FOO"
)
;
end
end
else
begin
if
(
c
)
begin
$
display
(
"BAR"
)
;
end
end
$
display
(
"2 (%b, %b, %b)"
,
a
,
b
,
c
)
;
if
(
a
)
begin
for
(
i
=
0
;
i
<
1
;
++
i
)
if
(
b
)
begin
$
display
(
"FOO"
)
;
end
end
else
begin
if
(
c
)
begin
$
display
(
"BAR"
)
;
end
end
end
endtask
initial
begin
t
(
0
,
0
,
0
)
;
t
(
0
,
0
,
1
)
;
t
(
0
,
1
,
0
)
;
t
(
0
,
1
,
1
)
;
t
(
1
,
0
,
0
)
;
t
(
1
,
0
,
1
)
;
t
(
1
,
1
,
0
)
;
t
(
1
,
1
,
1
)
;
end
endmodule
test/basic/else_prec.v
0 → 100644
View file @
35a0587d
// Reference file is already plain Verilog
`include
"else_prec.sv"
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