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
10885206
Commit
10885206
authored
Jun 17, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefix bare generate blocks with conditionals in codegen
parent
404385b0
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
34 additions
and
30 deletions
+34
-30
src/Language/SystemVerilog/AST/GenItem.hs
+13
-8
test/basic/array.v
+1
-1
test/basic/cast.v
+1
-1
test/basic/decl_scope.v
+3
-3
test/basic/interface_generate.v
+1
-1
test/basic/interface_infer.v
+2
-2
test/basic/interface_nested.v
+3
-3
test/basic/interface_param.v
+2
-2
test/basic/interface_shadow.v
+2
-2
test/basic/interface_struct.v
+1
-1
test/basic/logic_tf.v
+3
-3
test/basic/stmt_task.sv
+1
-1
test/basic/struct_scope.v
+1
-1
test/lib/functions.sh
+0
-1
No files found.
src/Language/SystemVerilog/AST/GenItem.hs
View file @
10885206
...
@@ -31,26 +31,31 @@ data GenItem
...
@@ -31,26 +31,31 @@ data GenItem
instance
Show
GenItem
where
instance
Show
GenItem
where
showList
i
_
=
unlines'
$
map
show
i
showList
i
_
=
unlines'
$
map
show
i
show
(
GenBlock
x
i
)
=
show
(
GenBlock
x
i
)
=
printf
"begin%s
\n
%s
\n
end"
"if (1) "
++
showBareBlock
(
GenBlock
x
i
)
(
if
null
x
then
""
else
" : "
++
x
)
(
indent
$
show
i
)
show
(
GenCase
e
cs
)
=
show
(
GenCase
e
cs
)
=
printf
"case (%s)
\n
%s
\n
endcase"
(
show
e
)
bodyStr
printf
"case (%s)
\n
%s
\n
endcase"
(
show
e
)
bodyStr
where
bodyStr
=
indent
$
unlines'
$
map
showGenCase
cs
where
bodyStr
=
indent
$
unlines'
$
map
showGenCase
cs
show
(
GenIf
e
a
GenNull
)
=
printf
"if (%s) %s"
(
show
e
)
(
show
a
)
show
(
GenIf
e
a
GenNull
)
=
printf
"if (%s) %s"
(
show
e
)
(
show
BareBlock
a
)
show
(
GenIf
e
a
b
)
=
printf
"if (%s) %s
\n
else %s"
(
show
e
)
(
showBlockedBranch
a
)
(
show
b
)
show
(
GenIf
e
a
b
)
=
printf
"if (%s) %s
\n
else %s"
(
show
e
)
(
showBlockedBranch
a
)
(
show
BareBlock
b
)
show
(
GenFor
(
x1
,
e1
)
c
(
x2
,
o2
,
e2
)
s
)
=
show
(
GenFor
(
x1
,
e1
)
c
(
x2
,
o2
,
e2
)
s
)
=
printf
"for (%s = %s; %s; %s %s %s) %s"
printf
"for (%s = %s; %s; %s %s %s) %s"
x1
(
show
e1
)
x1
(
show
e1
)
(
show
c
)
(
show
c
)
x2
(
show
o2
)
(
show
e2
)
x2
(
show
o2
)
(
show
e2
)
(
if
s
==
GenNull
then
"begin end"
else
show
s
)
(
if
s
==
GenNull
then
"begin end"
else
show
BareBlock
s
)
show
(
GenNull
)
=
";"
show
(
GenNull
)
=
";"
show
(
GenModuleItem
item
)
=
show
item
show
(
GenModuleItem
item
)
=
show
item
showBareBlock
::
GenItem
->
String
showBareBlock
(
GenBlock
x
i
)
=
printf
"begin%s
\n
%s
\n
end"
(
if
null
x
then
""
else
" : "
++
x
)
(
indent
$
show
i
)
showBareBlock
item
=
show
item
showBlockedBranch
::
GenItem
->
String
showBlockedBranch
::
GenItem
->
String
showBlockedBranch
genItem
=
showBlockedBranch
genItem
=
show
$
show
BareBlock
$
if
isControl
genItem
if
isControl
genItem
then
GenBlock
""
[
genItem
]
then
GenBlock
""
[
genItem
]
else
genItem
else
genItem
...
@@ -65,5 +70,5 @@ showBlockedBranch genItem =
...
@@ -65,5 +70,5 @@ showBlockedBranch genItem =
type
GenCase
=
([
Expr
],
GenItem
)
type
GenCase
=
([
Expr
],
GenItem
)
showGenCase
::
GenCase
->
String
showGenCase
::
GenCase
->
String
showGenCase
(
a
,
b
)
=
printf
"%s: %s"
exprStr
(
show
b
)
showGenCase
(
a
,
b
)
=
printf
"%s: %s"
exprStr
(
show
BareBlock
b
)
where
exprStr
=
if
null
a
then
"default"
else
commas
$
map
show
a
where
exprStr
=
if
null
a
then
"default"
else
commas
$
map
show
a
test/basic/array.v
View file @
10885206
...
@@ -11,7 +11,7 @@ module top;
...
@@ -11,7 +11,7 @@ module top;
assign
c
=
x
?
d
:
e
;
assign
c
=
x
?
d
:
e
;
generate
generate
begin
:
A
if
(
1
)
begin
:
A
wire
[
1
:
0
]
c
[
0
:
2
]
;
wire
[
1
:
0
]
c
[
0
:
2
]
;
wire
[
5
:
0
]
d
;
wire
[
5
:
0
]
d
;
end
end
...
...
test/basic/cast.v
View file @
10885206
module
top
;
module
top
;
generate
generate
begin
:
A
if
(
1
)
begin
:
A
reg
signed
[
31
:
0
]
x
;
reg
signed
[
31
:
0
]
x
;
end
end
endgenerate
endgenerate
...
...
test/basic/decl_scope.v
View file @
10885206
...
@@ -3,13 +3,13 @@ module top;
...
@@ -3,13 +3,13 @@ module top;
initial
$
display
(
"A t %0d"
,
1
)
;
initial
$
display
(
"A t %0d"
,
1
)
;
initial
$
display
(
"A top.t %0d"
,
1
)
;
initial
$
display
(
"A top.t %0d"
,
1
)
;
generate
generate
begin
:
X
if
(
1
)
begin
:
X
wire
[
1
:
0
]
t
;
wire
[
1
:
0
]
t
;
initial
$
display
(
"B t %0d"
,
2
)
;
initial
$
display
(
"B t %0d"
,
2
)
;
initial
$
display
(
"B top.t %0d"
,
1
)
;
initial
$
display
(
"B top.t %0d"
,
1
)
;
initial
$
display
(
"B X.t %0d"
,
2
)
;
initial
$
display
(
"B X.t %0d"
,
2
)
;
initial
$
display
(
"B top.X.t %0d"
,
2
)
;
initial
$
display
(
"B top.X.t %0d"
,
2
)
;
begin
:
Y
if
(
1
)
begin
:
Y
wire
[
2
:
0
]
t
;
wire
[
2
:
0
]
t
;
initial
$
display
(
"C t %0d"
,
3
)
;
initial
$
display
(
"C t %0d"
,
3
)
;
initial
$
display
(
"C top.t %0d"
,
1
)
;
initial
$
display
(
"C top.t %0d"
,
1
)
;
...
@@ -46,7 +46,7 @@ module top;
...
@@ -46,7 +46,7 @@ module top;
wire
[
11
:
0
]
arr
;
wire
[
11
:
0
]
arr
;
generate
generate
begin
:
M
if
(
1
)
begin
:
M
wire
[
19
:
0
]
arr
;
wire
[
19
:
0
]
arr
;
initial
$
display
(
"M arr[0] = %b"
,
arr
[
4
:
0
])
;
initial
$
display
(
"M arr[0] = %b"
,
arr
[
4
:
0
])
;
initial
$
display
(
"M M.arr[0] = %b"
,
M
.
arr
[
4
:
0
])
;
initial
$
display
(
"M M.arr[0] = %b"
,
M
.
arr
[
4
:
0
])
;
...
...
test/basic/interface_generate.v
View file @
10885206
...
@@ -33,7 +33,7 @@ module top;
...
@@ -33,7 +33,7 @@ module top;
generate
generate
begin
:
intf
if
(
1
)
begin
:
intf
wire
[
N
-
1
:
0
]
req
;
wire
[
N
-
1
:
0
]
req
;
end
end
genvar
j
;
genvar
j
;
...
...
test/basic/interface_infer.v
View file @
10885206
...
@@ -2,7 +2,7 @@ module top;
...
@@ -2,7 +2,7 @@ module top;
genvar
g
;
genvar
g
;
localparam
SOME_VAL
=
3
;
localparam
SOME_VAL
=
3
;
generate
generate
begin
:
i
if
(
1
)
begin
:
i
wire
x
=
0
;
wire
x
=
0
;
initial
$
display
(
"Interface %d %d"
,
x
,
SOME_VAL
)
;
initial
$
display
(
"Interface %d %d"
,
x
,
SOME_VAL
)
;
for
(
g
=
10
;
g
<
15
;
g
=
g
+
1
)
begin
for
(
g
=
10
;
g
<
15
;
g
=
g
+
1
)
begin
...
@@ -11,7 +11,7 @@ module top;
...
@@ -11,7 +11,7 @@ module top;
end
end
endgenerate
endgenerate
generate
generate
begin
:
m
if
(
1
)
begin
:
m
initial
$
display
(
"Module %d"
,
i
.
x
)
;
initial
$
display
(
"Module %d"
,
i
.
x
)
;
for
(
g
=
0
;
g
<
5
;
g
=
g
+
1
)
begin
for
(
g
=
0
;
g
<
5
;
g
=
g
+
1
)
begin
initial
$
display
(
g
)
;
initial
$
display
(
g
)
;
...
...
test/basic/interface_nested.v
View file @
10885206
module
top
;
module
top
;
wire
x
=
1
;
wire
x
=
1
;
generate
generate
begin
:
f
if
(
1
)
begin
:
f
wire
x
;
wire
x
;
begin
:
a
if
(
1
)
begin
:
a
wire
x
;
wire
x
;
initial
begin
initial
begin
$
display
(
"bar got %b"
,
x
)
;
$
display
(
"bar got %b"
,
x
)
;
end
end
end
end
assign
a
.
x
=
x
;
assign
a
.
x
=
x
;
begin
:
b
if
(
1
)
begin
:
b
wire
x
;
wire
x
;
initial
begin
initial
begin
$
display
(
"bar got %b"
,
x
)
;
$
display
(
"bar got %b"
,
x
)
;
...
...
test/basic/interface_param.v
View file @
10885206
...
@@ -13,10 +13,10 @@ endmodule
...
@@ -13,10 +13,10 @@ endmodule
module
top
;
module
top
;
generate
generate
begin
:
x
if
(
1
)
begin
:
x
wire
[
31
:
0
]
data
=
0
;
wire
[
31
:
0
]
data
=
0
;
end
end
begin
:
y
if
(
1
)
begin
:
y
wire
[
9
:
0
]
data
=
0
;
wire
[
9
:
0
]
data
=
0
;
end
end
endgenerate
endgenerate
...
...
test/basic/interface_shadow.v
View file @
10885206
module
top
;
module
top
;
generate
generate
begin
:
x
if
(
1
)
begin
:
x
integer
x
;
integer
x
;
function
z
;
function
z
;
input
x
;
input
x
;
...
@@ -10,7 +10,7 @@ module top;
...
@@ -10,7 +10,7 @@ module top;
endgenerate
endgenerate
initial
x
.
x
=
1
;
initial
x
.
x
=
1
;
generate
generate
begin
:
y
if
(
1
)
begin
:
y
function
z
;
function
z
;
input
x
;
input
x
;
z
=
x
;
z
=
x
;
...
...
test/basic/interface_struct.v
View file @
10885206
module
top
;
module
top
;
generate
generate
begin
:
i
if
(
1
)
begin
:
i
wire
[
3
:
0
]
x
;
wire
[
3
:
0
]
x
;
reg
[
1
:
0
]
w
;
reg
[
1
:
0
]
w
;
end
end
...
...
test/basic/logic_tf.v
View file @
10885206
...
@@ -19,12 +19,12 @@ module top;
...
@@ -19,12 +19,12 @@ module top;
end
end
generate
generate
begin
:
A
if
(
1
)
begin
:
A
wire
x
;
wire
x
;
begin
:
B
if
(
1
)
begin
:
B
reg
x
;
reg
x
;
end
end
begin
:
C
if
(
1
)
begin
:
C
wire
x
;
wire
x
;
end
end
assign
x
=
B
.
x
^
C
.
x
;
assign
x
=
B
.
x
^
C
.
x
;
...
...
test/basic/stmt_task.sv
View file @
10885206
...
@@ -3,7 +3,7 @@ module top;
...
@@ -3,7 +3,7 @@ module top;
$
display
(
"tick() called"
)
;
$
display
(
"tick() called"
)
;
endtask
endtask
generate
generate
begin
:
foo
if
(
1
)
begin
:
foo
task
tick
;
task
tick
;
$
display
(
"foo.tick() called"
)
;
$
display
(
"foo.tick() called"
)
;
endtask
endtask
...
...
test/basic/struct_scope.v
View file @
10885206
...
@@ -4,7 +4,7 @@ module top;
...
@@ -4,7 +4,7 @@ module top;
wire
[
17
:
0
]
c
;
wire
[
17
:
0
]
c
;
generate
generate
begin
:
foo
if
(
1
)
begin
:
foo
wire
[
2
:
0
]
a
;
wire
[
2
:
0
]
a
;
wire
[
14
:
0
]
b
;
wire
[
14
:
0
]
b
;
wire
[
17
:
0
]
c
;
wire
[
17
:
0
]
c
;
...
...
test/lib/functions.sh
View file @
10885206
...
@@ -21,7 +21,6 @@ simulate() {
...
@@ -21,7 +21,6 @@ simulate() {
iv_output
=
`
iverilog
\
iv_output
=
`
iverilog
\
-Wall
\
-Wall
\
-Wno-select-range
\
-Wno-select-range
\
-Wno-anachronisms
\
-Wno-portbind
\
-Wno-portbind
\
-o
$sim_prog
\
-o
$sim_prog
\
-g2005
\
-g2005
\
...
...
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