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
a9f502a6
Commit
a9f502a6
authored
Aug 26, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
traverse covers typedefs in packages and exprs in types
parent
08682671
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
17 deletions
+49
-17
src/Convert/Traverse.hs
+31
-17
test/basic/pacakge_typedef.sv
+14
-0
test/basic/pacakge_typedef.v
+4
-0
No files found.
src/Convert/Traverse.hs
View file @
a9f502a6
...
...
@@ -459,9 +459,9 @@ traverseNestedExprsM mapper = exprMapper
return
$
Pattern
$
zip
names
exprs
exprMapperHelpers
::
Monad
m
=>
MapperM
m
Expr
->
(
MapperM
m
Range
,
MapperM
m
(
Maybe
Expr
),
MapperM
m
Decl
,
MapperM
m
LHS
)
(
MapperM
m
Range
,
MapperM
m
(
Maybe
Expr
),
MapperM
m
Decl
,
MapperM
m
LHS
,
MapperM
m
Type
)
exprMapperHelpers
exprMapper
=
(
rangeMapper
,
maybeExprMapper
,
declMapper
,
traverseNestedLHSsM
lhsMapper
)
(
rangeMapper
,
maybeExprMapper
,
declMapper
,
traverseNestedLHSsM
lhsMapper
,
typeMapper
)
where
rangeMapper
(
a
,
b
)
=
do
...
...
@@ -473,14 +473,22 @@ exprMapperHelpers exprMapper =
maybeExprMapper
(
Just
e
)
=
exprMapper
e
>>=
return
.
Just
declMapper
(
Parameter
t
x
e
)
=
exprMapper
e
>>=
return
.
Parameter
t
x
declMapper
(
Localparam
t
x
e
)
=
exprMapper
e
>>=
return
.
Localparam
t
x
declMapper
(
Variable
d
t
x
a
me
)
=
do
typeMapper'
t
=
do
let
(
tf
,
rs
)
=
typeRanges
t
rs'
<-
mapM
rangeMapper
rs
let
t'
=
tf
rs'
return
$
tf
rs'
typeMapper
=
traverseNestedTypesM
typeMapper'
declMapper
(
Parameter
t
x
e
)
=
do
t'
<-
typeMapper
t
e'
<-
exprMapper
e
return
$
Parameter
t'
x
e'
declMapper
(
Localparam
t
x
e
)
=
do
t'
<-
typeMapper
t
e'
<-
exprMapper
e
return
$
Localparam
t'
x
e'
declMapper
(
Variable
d
t
x
a
me
)
=
do
t'
<-
typeMapper
t
a'
<-
mapM
rangeMapper
a
me'
<-
maybeExprMapper
me
return
$
Variable
d
t'
x
a'
me'
...
...
@@ -495,7 +503,7 @@ traverseExprsM' :: Monad m => TFStrategy -> MapperM m Expr -> MapperM m ModuleIt
traverseExprsM'
strat
exprMapper
=
moduleItemMapper
where
(
rangeMapper
,
maybeExprMapper
,
declMapper
,
lhsMapper
)
(
rangeMapper
,
maybeExprMapper
,
declMapper
,
lhsMapper
,
typeMapper
)
=
exprMapperHelpers
exprMapper
stmtMapper
=
traverseNestedStmtsM
(
traverseStmtExprsM
exprMapper
)
...
...
@@ -506,6 +514,9 @@ traverseExprsM' strat exprMapper = moduleItemMapper
moduleItemMapper
(
MIAttr
attr
mi
)
=
-- note: we exclude expressions in attributes from conversion
return
$
MIAttr
attr
mi
moduleItemMapper
(
MIPackageItem
(
Typedef
t
x
))
=
do
t'
<-
typeMapper
t
return
$
MIPackageItem
$
Typedef
t'
x
moduleItemMapper
(
MIPackageItem
(
Decl
decl
))
=
declMapper
decl
>>=
return
.
MIPackageItem
.
Decl
moduleItemMapper
(
Defparam
lhs
expr
)
=
do
...
...
@@ -560,8 +571,6 @@ traverseExprsM' strat exprMapper = moduleItemMapper
moduleItemMapper
(
Generate
items
)
=
do
items'
<-
mapM
(
traverseNestedGenItemsM
genItemMapper
)
items
return
$
Generate
items'
moduleItemMapper
(
MIPackageItem
(
Typedef
t
x
))
=
return
$
MIPackageItem
$
Typedef
t
x
moduleItemMapper
(
MIPackageItem
(
Comment
c
))
=
return
$
MIPackageItem
$
Comment
c
moduleItemMapper
(
MIPackageItem
(
Import
x
y
))
=
...
...
@@ -609,7 +618,7 @@ traverseStmtExprsM :: Monad m => MapperM m Expr -> MapperM m Stmt
traverseStmtExprsM
exprMapper
=
flatStmtMapper
where
(
_
,
maybeExprMapper
,
declMapper
,
lhsMapper
)
(
_
,
maybeExprMapper
,
declMapper
,
lhsMapper
,
_
)
=
exprMapperHelpers
exprMapper
caseMapper
(
exprs
,
stmt
)
=
do
...
...
@@ -762,11 +771,8 @@ traverseDecls = traverseDecls' IncludeTFs
collectDeclsM
::
Monad
m
=>
CollectorM
m
Decl
->
CollectorM
m
ModuleItem
collectDeclsM
=
collectDeclsM'
IncludeTFs
traverseTypesM
::
Monad
m
=>
MapperM
m
Type
->
MapperM
m
ModuleItem
traverseTypesM
mapper
item
=
miMapper
item
>>=
traverseDeclsM
declMapper
>>=
traverseExprsM
(
traverseNestedExprsM
exprMapper
)
traverseNestedTypesM
::
Monad
m
=>
MapperM
m
Type
->
MapperM
m
Type
traverseNestedTypesM
mapper
=
fullMapper
where
fullMapper
t
=
tm
t
>>=
mapper
tm
(
Alias
ps
xx
rs
)
=
return
$
Alias
ps
xx
rs
...
...
@@ -789,6 +795,14 @@ traverseTypesM mapper item =
types
<-
mapM
fullMapper
$
map
fst
fields
let
idents
=
map
snd
fields
return
$
Union
p
(
zip
types
idents
)
r
traverseTypesM
::
Monad
m
=>
MapperM
m
Type
->
MapperM
m
ModuleItem
traverseTypesM
mapper
item
=
miMapper
item
>>=
traverseDeclsM
declMapper
>>=
traverseExprsM
(
traverseNestedExprsM
exprMapper
)
where
fullMapper
=
traverseNestedTypesM
mapper
exprMapper
(
Cast
(
Left
t
)
e
)
=
fullMapper
t
>>=
\
t'
->
return
$
Cast
(
Left
t'
)
e
exprMapper
(
Bits
(
Left
t
))
=
...
...
test/basic/pacakge_typedef.sv
0 → 100644
View file @
a9f502a6
package
top_pkg
;
localparam
AW
=
16
;
endpackage
package
foo_pkg
;
typedef
struct
packed
{
logic
valid
;
logic
[
top_pkg
::
AW
-
1
:
0
]
user
;
}
boo_t
;
endpackage
module
top
;
foo_pkg
::
boo_t
foo
;
endmodule
test/basic/pacakge_typedef.v
0 → 100644
View file @
a9f502a6
module
top
;
localparam
AW
=
16
;
wire
[
16
:
0
]
foo
;
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