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
a0c3112b
Commit
a0c3112b
authored
May 05, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flatten tf blocks with decls
parent
9e7768b6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
src/Convert.hs
+2
-2
src/Convert/TFBlock.hs
+30
-5
sv2v.cabal
+1
-1
No files found.
src/Convert.hs
View file @
a0c3112b
...
@@ -38,9 +38,9 @@ import qualified Convert.SignCast
...
@@ -38,9 +38,9 @@ import qualified Convert.SignCast
import
qualified
Convert.Simplify
import
qualified
Convert.Simplify
import
qualified
Convert.SizeCast
import
qualified
Convert.SizeCast
import
qualified
Convert.StarPort
import
qualified
Convert.StarPort
import
qualified
Convert.StmtBlock
import
qualified
Convert.Stream
import
qualified
Convert.Stream
import
qualified
Convert.Struct
import
qualified
Convert.Struct
import
qualified
Convert.TFBlock
import
qualified
Convert.Typedef
import
qualified
Convert.Typedef
import
qualified
Convert.TypeOf
import
qualified
Convert.TypeOf
import
qualified
Convert.UnbasedUnsized
import
qualified
Convert.UnbasedUnsized
...
@@ -73,9 +73,9 @@ phases excludes =
...
@@ -73,9 +73,9 @@ phases excludes =
,
Convert
.
SizeCast
.
convert
,
Convert
.
SizeCast
.
convert
,
Convert
.
Simplify
.
convert
,
Convert
.
Simplify
.
convert
,
Convert
.
StarPort
.
convert
,
Convert
.
StarPort
.
convert
,
Convert
.
StmtBlock
.
convert
,
Convert
.
Stream
.
convert
,
Convert
.
Stream
.
convert
,
Convert
.
Struct
.
convert
,
Convert
.
Struct
.
convert
,
Convert
.
TFBlock
.
convert
,
Convert
.
Typedef
.
convert
,
Convert
.
Typedef
.
convert
,
Convert
.
UnbasedUnsized
.
convert
,
Convert
.
UnbasedUnsized
.
convert
,
Convert
.
Unique
.
convert
,
Convert
.
Unique
.
convert
...
...
src/Convert/
Stmt
Block.hs
→
src/Convert/
TF
Block.hs
View file @
a0c3112b
{- sv2v
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
- Author: Zachary Snow <zach@zachjs.com>
-
-
- Conversion for tasks and functions to use only one statement, as required in
- Conversion for tasks and functions to contain only one top-level statement,
- Verilog-2005.
- as required in Verilog-2005. This conversion also hoists data declarations to
- the task or function level for greater portability.
-}
-}
module
Convert.StmtBlock
(
convert
)
where
module
Convert.TFBlock
(
convert
)
where
import
Data.List
(
isPrefixOf
)
import
Convert.Traverse
import
Convert.Traverse
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
...
@@ -20,11 +23,33 @@ convertModuleItem other = other
...
@@ -20,11 +23,33 @@ convertModuleItem other = other
convertPackageItem
::
PackageItem
->
PackageItem
convertPackageItem
::
PackageItem
->
PackageItem
convertPackageItem
(
Function
ml
t
f
decls
stmts
)
=
convertPackageItem
(
Function
ml
t
f
decls
stmts
)
=
Function
ml
t
f
decls
[
stmtsToStmt
stmts
]
Function
ml
t
f
decls'
stmts'
where
(
decls'
,
stmts'
)
=
convertTFBlock
decls
stmts
convertPackageItem
(
Task
ml
f
decls
stmts
)
=
convertPackageItem
(
Task
ml
f
decls
stmts
)
=
Task
ml
f
decls
[
stmtsToStmt
stmts
]
Task
ml
f
decls'
stmts'
where
(
decls'
,
stmts'
)
=
convertTFBlock
decls
stmts
convertPackageItem
other
=
other
convertPackageItem
other
=
other
convertTFBlock
::
[
Decl
]
->
[
Stmt
]
->
([
Decl
],
[
Stmt
])
convertTFBlock
decls
stmts
=
(
decls'
,
[
stmtsToStmt
stmts'
])
where
(
decls'
,
stmts'
)
=
flattenOuterBlocks
$
Block
Seq
""
decls
stmts
stmtsToStmt
::
[
Stmt
]
->
Stmt
stmtsToStmt
::
[
Stmt
]
->
Stmt
stmtsToStmt
[
stmt
]
=
stmt
stmtsToStmt
[
stmt
]
=
stmt
stmtsToStmt
stmts
=
Block
Seq
""
[]
stmts
stmtsToStmt
stmts
=
Block
Seq
""
[]
stmts
flattenOuterBlocks
::
Stmt
->
([
Decl
],
[
Stmt
])
flattenOuterBlocks
(
Block
Seq
""
declsA
[
stmt
])
=
(
declsA
++
declsB
,
stmtsB
)
where
(
declsB
,
stmtsB
)
=
flattenOuterBlocks
stmt
flattenOuterBlocks
(
Block
Seq
""
declsA
(
Block
Seq
name
declsB
stmtsA
:
stmtsB
))
=
flattenOuterBlocks
$
Block
Seq
name
(
declsA
++
declsB
)
(
stmtsA
++
stmtsB
)
flattenOuterBlocks
(
Block
Seq
name
decls
stmts
)
|
notscope
name
=
(
decls
,
stmts
)
|
otherwise
=
(
[]
,
[
Block
Seq
name
decls
stmts
])
flattenOuterBlocks
stmt
=
(
[]
,
[
stmt
])
notscope
::
Identifier
->
Bool
notscope
""
=
True
notscope
name
=
"sv2v_autoblock_"
`
isPrefixOf
`
name
sv2v.cabal
View file @
a0c3112b
...
@@ -86,9 +86,9 @@ executable sv2v
...
@@ -86,9 +86,9 @@ executable sv2v
Convert.Simplify
Convert.Simplify
Convert.SizeCast
Convert.SizeCast
Convert.StarPort
Convert.StarPort
Convert.StmtBlock
Convert.Stream
Convert.Stream
Convert.Struct
Convert.Struct
Convert.TFBlock
Convert.Traverse
Convert.Traverse
Convert.Typedef
Convert.Typedef
Convert.TypeOf
Convert.TypeOf
...
...
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