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
a293002a
Commit
a293002a
authored
May 29, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve package and class idents within class parameters
parent
0a65abd6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
4 deletions
+49
-4
src/Convert/Package.hs
+11
-4
test/basic/class_param_nest.sv
+24
-0
test/basic/class_param_nest.v
+14
-0
No files found.
src/Convert/Package.hs
View file @
a293002a
...
...
@@ -304,7 +304,8 @@ processItems topName packageName moduleItems = do
traverseTypeM
::
Type
->
Scope
Type
traverseTypeM
(
CSAlias
p
b
x
rs
)
=
do
scopeKeys
<-
bindingsScopeKeys
b
x'
<-
lift
$
resolveCSIdent
p
b
scopeKeys
x
b'
<-
mapM
traverseParamBindingM
b
x'
<-
lift
$
resolveCSIdent
p
b'
scopeKeys
x
return
$
Alias
x'
rs
traverseTypeM
(
PSAlias
p
x
rs
)
=
do
x'
<-
resolvePSIdent'
p
x
...
...
@@ -321,7 +322,8 @@ processItems topName packageName moduleItems = do
traverseExprM
::
Expr
->
Scope
Expr
traverseExprM
(
CSIdent
p
b
x
)
=
do
scopeKeys
<-
bindingsScopeKeys
b
x'
<-
lift
$
resolveCSIdent
p
b
scopeKeys
x
b'
<-
mapM
traverseParamBindingM
b
x'
<-
lift
$
resolveCSIdent
p
b'
scopeKeys
x
return
$
Ident
x'
traverseExprM
(
PSIdent
p
x
)
=
do
x'
<-
resolvePSIdent'
p
x
...
...
@@ -347,6 +349,12 @@ processItems topName packageName moduleItems = do
traverseStmtExprsM
traverseExprM
>=>
traverseStmtLHSsM
traverseLHSM
traverseParamBindingM
::
ParamBinding
->
Scope
ParamBinding
traverseParamBindingM
(
x
,
Left
t
)
=
traverseTypeM
t
>>=
return
.
(
x
,
)
.
Left
traverseParamBindingM
(
x
,
Right
e
)
=
traverseExprM
e
>>=
return
.
(
x
,
)
.
Right
-- wrapper allowing explicit reference to local package items
resolvePSIdent'
::
Identifier
->
Identifier
->
Scope
Identifier
resolvePSIdent'
p
x
=
do
...
...
@@ -481,7 +489,6 @@ resolveCSIdent className paramBindings scopeKeys itemName = do
Decl
$
Param
Parameter
t
x
$
case
lookup
x'
bindings
of
Just
(
Right
e'
)
->
e'
Just
(
Left
(
Alias
y
[]
))
->
Ident
y
Just
(
Left
t'
)
->
error
$
"cannot override parameter "
++
show
x'
++
" in class "
++
show
className
...
...
@@ -497,7 +504,7 @@ resolveCSIdent className paramBindings scopeKeys itemName = do
Decl
$
ParamType
Parameter
x
$
case
lookup
x'
bindings
of
Just
(
Left
t'
)
->
t'
Just
(
Right
(
Ident
t'
))
->
Alias
t'
[]
Just
(
Right
(
Ident
y
))
->
Alias
y
[]
Just
(
Right
e'
)
->
error
$
"cannot override type parameter "
++
show
x'
++
" in class "
++
show
className
...
...
test/basic/class_param_nest.sv
0 → 100644
View file @
a293002a
class
C
#(
parameter
X
=
1
)
;
localparam
Y
=
X
*
2
;
endclass
package
P
;
localparam
W
=
5
;
endpackage
`define
DUMP
(
expr
)
$
display
(`"
expr
=
%
0d
`",
expr
)
;
`define
DUMP_BOTH
(
prefix
)
`
DUMP
(
prefix
::
X
)
`
DUMP
(
prefix
::
Y
)
module
top
;
localparam
Z
=
3
;
initial
begin
`DUMP
(
Z
)
`DUMP
(
P
::
W
)
`DUMP_BOTH
(
C
#())
`DUMP_BOTH
(
C
#(
Z
))
`DUMP_BOTH
(
C
#(
P
::
W
))
`DUMP_BOTH
(
C
#(
C
#(
Z
)
::
Y
))
end
endmodule
test/basic/class_param_nest.v
0 → 100644
View file @
a293002a
`define
DUMP
(
expr
,
value
)
$
display
(
`
"expr = %0d`"
,
value
)
;
`define
DUMP_BOTH
(
prefix
,
value
)
`
DUMP
(
prefix
::
X
,
value
)
`
DUMP
(
prefix
::
Y
,
(
value
)
*
2
)
module
top
;
localparam
Z
=
3
;
initial
begin
`DUMP
(
Z
,
Z
)
`DUMP
(
P
::
W
,
5
)
`DUMP_BOTH
(
C
#()
,
1
)
`DUMP_BOTH
(
C
#(
Z
)
,
Z
)
`DUMP_BOTH
(
C
#(
P
::
W
)
,
5
)
`DUMP_BOTH
(
C
#(
C
#(
Z
)
::
Y
)
,
Z
*
2
)
end
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