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
86195d9e
Commit
86195d9e
authored
Apr 02, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interface conversion obeys function/task identifier shadowing
parent
f13275bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
14 deletions
+32
-14
src/Convert/Interface.hs
+32
-14
src/Convert/Traverse.hs
+0
-0
No files found.
src/Convert/Interface.hs
View file @
86195d9e
...
...
@@ -9,6 +9,7 @@ module Convert.Interface (convert) where
import
Data.Maybe
(
isJust
,
mapMaybe
)
import
Control.Monad.Writer
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Set
as
Set
import
Convert.Traverse
import
Language.SystemVerilog.AST
...
...
@@ -47,8 +48,8 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it
Part
extern
Module
lifetime
name
ports'
items'
where
items'
=
map
(
traverseNestedModuleItems
$
traverseExprs
(
traverseNestedExprs
convertExpr
))
$
map
(
traverseNestedModuleItems
$
traverseLHSs
(
traverseNestedLHSs
convertLHS
))
$
map
(
traverseNestedModuleItems
$
traverseExprs
'
ExcludeTFs
(
traverseNestedExprs
$
convertExpr
instances
modports
))
$
map
(
traverseNestedModuleItems
$
traverseLHSs
'
ExcludeTFs
(
traverseNestedLHSs
$
convertLHS
instances
modports
))
$
map
(
traverseNestedModuleItems
mapInterface
)
$
items
ports'
=
concatMap
convertPort
ports
...
...
@@ -89,8 +90,25 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it
inlineInterface
interface
(
ident
,
expandedPorts
)
Nothing
->
Instance
part
params
ident
Nothing
expandedPorts
where
expandedPorts
=
concatMap
(
expandPortBinding
part
)
instancePorts
mapInterface
(
orig
@
(
MIPackageItem
(
Function
_
_
_
decls
_
)))
=
convertTF
decls
orig
mapInterface
(
orig
@
(
MIPackageItem
(
Task
_
_
decls
_
)))
=
convertTF
decls
orig
mapInterface
other
=
other
convertTF
::
[
Decl
]
->
ModuleItem
->
ModuleItem
convertTF
decls
orig
=
traverseExprs
(
traverseNestedExprs
$
convertExpr
its
mps
)
$
traverseLHSs
(
traverseNestedLHSs
$
convertLHS
its
mps
)
$
orig
where
locals
=
Set
.
fromList
$
mapMaybe
declVarIdent
decls
its
=
Map
.
withoutKeys
instances
locals
mps
=
Map
.
withoutKeys
modports
locals
declVarIdent
::
Decl
->
Maybe
Identifier
declVarIdent
(
Variable
_
_
x
_
_
)
=
Just
x
declVarIdent
_
=
Nothing
expandPortBinding
::
Identifier
->
PortBinding
->
[
PortBinding
]
expandPortBinding
_
(
origBinding
@
(
portName
,
Just
(
Dot
(
Ident
instanceName
)
modportName
)))
=
case
Map
.
lookup
instanceName
instances
of
...
...
@@ -136,22 +154,22 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it
collectModport
(
Modport
ident
l
)
=
tell
$
Map
.
singleton
ident
l
collectModport
_
=
return
()
convertExpr
::
Expr
->
Expr
convertExpr
(
orig
@
(
Dot
(
Ident
x
)
y
))
=
if
Map
.
member
x
m
odports
||
Map
.
member
x
instance
s
convertExpr
::
Instances
->
Modports
->
Expr
->
Expr
convertExpr
its
mps
(
orig
@
(
Dot
(
Ident
x
)
y
))
=
if
Map
.
member
x
m
ps
||
Map
.
member
x
it
s
then
Ident
(
x
++
"_"
++
y
)
else
orig
convertExpr
other
=
other
convertLHS
::
LHS
->
LHS
convertLHS
(
orig
@
(
LHSDot
(
LHSIdent
x
)
y
))
=
if
Map
.
member
x
m
odports
||
Map
.
member
x
instance
s
convertExpr
_
_
other
=
other
convertLHS
::
Instances
->
Modports
->
LHS
->
LHS
convertLHS
its
mps
(
orig
@
(
LHSDot
(
LHSIdent
x
)
y
))
=
if
Map
.
member
x
m
ps
||
Map
.
member
x
it
s
then
LHSIdent
(
x
++
"_"
++
y
)
else
orig
convertLHS
(
LHSBit
l
e
)
=
LHSBit
l
(
traverseNestedExprs
convertExpr
e
)
convertLHS
(
LHSRange
l
(
e1
,
e2
))
=
LHSRange
l
(
traverseNestedExprs
convertExpr
e1
,
traverseNestedExprs
convertExpr
e2
)
convertLHS
other
=
other
convertLHS
its
mps
(
LHSBit
l
e
)
=
LHSBit
l
(
traverseNestedExprs
(
convertExpr
its
mps
)
e
)
convertLHS
its
mps
(
LHSRange
l
(
e1
,
e2
))
=
LHSRange
l
(
traverseNestedExprs
(
convertExpr
its
mps
)
e1
,
traverseNestedExprs
(
convertExpr
its
mps
)
e2
)
convertLHS
_
_
other
=
other
convertPort
::
Identifier
->
[
Identifier
]
convertPort
ident
=
case
Map
.
lookup
ident
modports
of
...
...
src/Convert/Traverse.hs
View file @
86195d9e
This diff is collapsed.
Click to expand it.
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