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
4c173d86
Commit
4c173d86
authored
Jul 15, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transition simplify conversion to new scoper
parent
a38137b6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
src/Convert/Simplify.hs
+19
-18
No files found.
src/Convert/Simplify.hs
View file @
4c173d86
...
@@ -16,27 +16,25 @@
...
@@ -16,27 +16,25 @@
module
Convert.Simplify
(
convert
)
where
module
Convert.Simplify
(
convert
)
where
import
Control.Monad.State
import
Control.Monad
(
when
)
import
qualified
Data.Map.Strict
as
Map
import
Convert.ExprUtils
import
Convert.ExprUtils
import
Convert.Scoper
import
Convert.Traverse
import
Convert.Traverse
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
type
Info
=
Map
.
Map
Identifier
Expr
convert
::
[
AST
]
->
[
AST
]
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
convertDescription
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
::
Description
->
Description
convertDescription
=
convertDescription
=
scopedConversion
traverseDeclM
traverseModuleItemM
traverseStmtM
Map
.
empty
partScoper
traverseDeclM
traverseModuleItemM
traverseGenItemM
traverseStmtM
traverseDeclM
::
Decl
->
S
tate
Info
Decl
traverseDeclM
::
Decl
->
S
coper
Expr
Decl
traverseDeclM
decl
=
do
traverseDeclM
decl
=
do
case
decl
of
case
decl
of
Param
Localparam
_
x
e
->
Param
Localparam
_
x
e
->
when
(
isSimpleExpr
e
)
$
modify
$
Map
.
insert
x
e
when
(
isSimpleExpr
e
)
$
insertElem
x
e
_
->
return
()
_
->
return
()
let
mi
=
MIPackageItem
$
Decl
decl
let
mi
=
MIPackageItem
$
Decl
decl
mi'
<-
traverseModuleItemM
mi
mi'
<-
traverseModuleItemM
mi
...
@@ -52,7 +50,7 @@ isSimpleExpr (Bit e _ ) = isSimpleExpr e
...
@@ -52,7 +50,7 @@ isSimpleExpr (Bit e _ ) = isSimpleExpr e
isSimpleExpr
(
Range
e
_
_
)
=
isSimpleExpr
e
isSimpleExpr
(
Range
e
_
_
)
=
isSimpleExpr
e
isSimpleExpr
_
=
False
isSimpleExpr
_
=
False
traverseModuleItemM
::
ModuleItem
->
S
tate
Info
ModuleItem
traverseModuleItemM
::
ModuleItem
->
S
coper
Expr
ModuleItem
traverseModuleItemM
(
Instance
m
p
x
rs
l
)
=
do
traverseModuleItemM
(
Instance
m
p
x
rs
l
)
=
do
p'
<-
mapM
paramBindingMapper
p
p'
<-
mapM
paramBindingMapper
p
traverseExprsM
traverseExprM
$
Instance
m
p'
x
rs
l
traverseExprsM
traverseExprM
$
Instance
m
p'
x
rs
l
...
@@ -63,16 +61,19 @@ traverseModuleItemM (Instance m p x rs l) = do
...
@@ -63,16 +61,19 @@ traverseModuleItemM (Instance m p x rs l) = do
paramBindingMapper
(
param
,
Right
e
)
=
return
(
param
,
Right
e
)
paramBindingMapper
(
param
,
Right
e
)
=
return
(
param
,
Right
e
)
traverseModuleItemM
item
=
traverseExprsM
traverseExprM
item
traverseModuleItemM
item
=
traverseExprsM
traverseExprM
item
traverseStmtM
::
Stmt
->
State
Info
Stmt
traverseGenItemM
::
GenItem
->
Scoper
Expr
GenItem
traverseGenItemM
=
traverseGenItemExprsM
traverseExprM
traverseStmtM
::
Stmt
->
Scoper
Expr
Stmt
traverseStmtM
stmt
=
traverseStmtExprsM
traverseExprM
stmt
traverseStmtM
stmt
=
traverseStmtExprsM
traverseExprM
stmt
traverseExprM
::
Expr
->
S
tate
Info
Expr
traverseExprM
::
Expr
->
S
coper
Expr
Expr
traverseExprM
=
stately
convertExpr
traverseExprM
=
embedScopes
convertExpr
substituteExprM
::
Expr
->
S
tate
Info
Expr
substituteExprM
::
Expr
->
S
coper
Expr
Expr
substituteExprM
=
stately
substitute
substituteExprM
=
embedScopes
substitute
convertExpr
::
Info
->
Expr
->
Expr
convertExpr
::
Scopes
Expr
->
Expr
->
Expr
convertExpr
info
(
Cast
(
Right
c
)
e
)
=
convertExpr
info
(
Cast
(
Right
c
)
e
)
=
Cast
(
Right
c'
)
e'
Cast
(
Right
c'
)
e'
where
where
...
@@ -114,13 +115,13 @@ convertExpr info (Concat exprs) =
...
@@ -114,13 +115,13 @@ convertExpr info (Concat exprs) =
convertExpr
info
expr
=
convertExpr
info
expr
=
traverseSinglyNestedExprs
(
convertExpr
info
)
expr
traverseSinglyNestedExprs
(
convertExpr
info
)
expr
substitute
::
Info
->
Expr
->
Expr
substitute
::
Scopes
Expr
->
Expr
->
Expr
substitute
info
expr
=
substitute
scopes
expr
=
traverseNestedExprs
substitute'
expr
traverseNestedExprs
substitute'
expr
where
where
substitute'
::
Expr
->
Expr
substitute'
::
Expr
->
Expr
substitute'
(
Ident
x
)
=
substitute'
(
Ident
x
)
=
case
Map
.
lookup
x
info
of
case
lookupElem
scopes
x
of
Nothing
->
Ident
x
Nothing
->
Ident
x
Just
e
->
e
Just
(
_
,
_
,
e
)
->
e
substitute'
other
=
other
substitute'
other
=
other
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