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
Hide 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 @@
module
Convert.Simplify
(
convert
)
where
import
Control.Monad.State
import
qualified
Data.Map.Strict
as
Map
import
Control.Monad
(
when
)
import
Convert.ExprUtils
import
Convert.Scoper
import
Convert.Traverse
import
Language.SystemVerilog.AST
type
Info
=
Map
.
Map
Identifier
Expr
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
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
case
decl
of
Param
Localparam
_
x
e
->
when
(
isSimpleExpr
e
)
$
modify
$
Map
.
insert
x
e
when
(
isSimpleExpr
e
)
$
insertElem
x
e
_
->
return
()
let
mi
=
MIPackageItem
$
Decl
decl
mi'
<-
traverseModuleItemM
mi
...
...
@@ -52,7 +50,7 @@ isSimpleExpr (Bit e _ ) = isSimpleExpr e
isSimpleExpr
(
Range
e
_
_
)
=
isSimpleExpr
e
isSimpleExpr
_
=
False
traverseModuleItemM
::
ModuleItem
->
S
tate
Info
ModuleItem
traverseModuleItemM
::
ModuleItem
->
S
coper
Expr
ModuleItem
traverseModuleItemM
(
Instance
m
p
x
rs
l
)
=
do
p'
<-
mapM
paramBindingMapper
p
traverseExprsM
traverseExprM
$
Instance
m
p'
x
rs
l
...
...
@@ -63,16 +61,19 @@ traverseModuleItemM (Instance m p x rs l) = do
paramBindingMapper
(
param
,
Right
e
)
=
return
(
param
,
Right
e
)
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
traverseExprM
::
Expr
->
S
tate
Info
Expr
traverseExprM
=
stately
convertExpr
traverseExprM
::
Expr
->
S
coper
Expr
Expr
traverseExprM
=
embedScopes
convertExpr
substituteExprM
::
Expr
->
S
tate
Info
Expr
substituteExprM
=
stately
substitute
substituteExprM
::
Expr
->
S
coper
Expr
Expr
substituteExprM
=
embedScopes
substitute
convertExpr
::
Info
->
Expr
->
Expr
convertExpr
::
Scopes
Expr
->
Expr
->
Expr
convertExpr
info
(
Cast
(
Right
c
)
e
)
=
Cast
(
Right
c'
)
e'
where
...
...
@@ -114,13 +115,13 @@ convertExpr info (Concat exprs) =
convertExpr
info
expr
=
traverseSinglyNestedExprs
(
convertExpr
info
)
expr
substitute
::
Info
->
Expr
->
Expr
substitute
info
expr
=
substitute
::
Scopes
Expr
->
Expr
->
Expr
substitute
scopes
expr
=
traverseNestedExprs
substitute'
expr
where
substitute'
::
Expr
->
Expr
substitute'
(
Ident
x
)
=
case
Map
.
lookup
x
info
of
case
lookupElem
scopes
x
of
Nothing
->
Ident
x
Just
e
->
e
Just
(
_
,
_
,
e
)
->
e
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