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
d6c932d0
Commit
d6c932d0
authored
Sep 02, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversion for block decls with asignments
parent
bafe7e43
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
0 deletions
+69
-0
src/Convert.hs
+2
-0
src/Convert/BlockDecl.hs
+38
-0
sv2v.cabal
+1
-0
test/basic/for_decl.sv
+15
-0
test/basic/for_decl.v
+13
-0
No files found.
src/Convert.hs
View file @
d6c932d0
...
...
@@ -13,6 +13,7 @@ import qualified Convert.AlwaysKW
import
qualified
Convert.AsgnOp
import
qualified
Convert.Assertion
import
qualified
Convert.Bits
import
qualified
Convert.BlockDecl
import
qualified
Convert.EmptyArgs
import
qualified
Convert.Enum
import
qualified
Convert.ForDecl
...
...
@@ -43,6 +44,7 @@ phases excludes =
,
Convert
.
NamedBlock
.
convert
,
Convert
.
Assertion
.
convert
,
Convert
.
Bits
.
convert
,
Convert
.
BlockDecl
.
convert
,
selectExclude
(
Job
.
Logic
,
Convert
.
Logic
.
convert
)
,
Convert
.
ForDecl
.
convert
,
Convert
.
FuncRet
.
convert
...
...
src/Convert/BlockDecl.hs
0 → 100644
View file @
d6c932d0
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
- Verilog-2005 forbids block declarations with default values. We convert
- these assignments to separate statements. If we handle static lifetimes in
- the future, this conversion may have to change.
-}
module
Convert.BlockDecl
(
convert
)
where
import
Data.Maybe
(
mapMaybe
)
import
Convert.Traverse
import
Language.SystemVerilog.AST
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
$
traverseModuleItems
$
traverseStmts
$
convertStmt
convertStmt
::
Stmt
->
Stmt
convertStmt
(
Block
name
decls
stmts
)
=
Block
name
decls'
stmts'
where
splitDecls
=
map
splitDecl
decls
decls'
=
map
fst
splitDecls
asgns
=
map
asgnStmt
$
mapMaybe
snd
splitDecls
stmts'
=
asgns
++
stmts
convertStmt
other
=
other
splitDecl
::
Decl
->
(
Decl
,
Maybe
(
LHS
,
Expr
))
splitDecl
(
Variable
d
t
ident
a
(
Just
e
))
=
(
Variable
d
t
ident
a
Nothing
,
Just
(
LHSIdent
ident
,
e
))
splitDecl
other
=
(
other
,
Nothing
)
asgnStmt
::
(
LHS
,
Expr
)
->
Stmt
asgnStmt
=
uncurry
$
AsgnBlk
AsgnOpEq
sv2v.cabal
View file @
d6c932d0
...
...
@@ -57,6 +57,7 @@ executable sv2v
Convert.AsgnOp
Convert.Assertion
Convert.Bits
Convert.BlockDecl
Convert.EmptyArgs
Convert.Enum
Convert.ForDecl
...
...
test/basic/for_decl.sv
View file @
d6c932d0
...
...
@@ -34,4 +34,19 @@ module top;
end
end
initial
begin
integer
i
=
0
;
for
(
;
i
<
32
;
i
++
)
$
display
(
"6: "
,
~
a
[
i
])
;
end
initial
begin
integer
j
=
0
,
k
;
for
(
;
j
<
4
;
j
++
)
begin
k
=
0
;
for
(
;
k
<
8
;
k
++
)
$
display
(
"7: "
,
~
a
[
j
*
8
+
k
]
+
11
)
;
end
end
endmodule
test/basic/for_decl.v
View file @
d6c932d0
...
...
@@ -42,4 +42,17 @@ module top;
$
display
(
"5: "
,
~
a
[
j
*
8
+
k
]
+
11
)
;
end
initial
begin
:
foo_6
integer
i
;
for
(
i
=
0
;
i
<
32
;
i
=
i
+
1
)
$
display
(
"6: "
,
~
a
[
i
])
;
end
initial
begin
:
foo_7
integer
j
,
k
;
for
(
j
=
0
;
j
<
4
;
j
++
)
for
(
k
=
0
;
k
<
8
;
k
++
)
$
display
(
"7: "
,
~
a
[
j
*
8
+
k
]
+
11
)
;
end
endmodule
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