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
6788ecbf
Commit
6788ecbf
authored
Sep 18, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix interface traversal of exprs in types, and support module-scoped modport refs
parent
e42fbfa2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
12 deletions
+69
-12
CHANGELOG.md
+2
-0
src/Convert/Interface.hs
+31
-12
test/core/interface_typeof.sv
+20
-0
test/core/interface_typeof.v
+16
-0
No files found.
CHANGELOG.md
View file @
6788ecbf
...
@@ -28,6 +28,8 @@
...
@@ -28,6 +28,8 @@
separate from the corresponding net or variable declaration
separate from the corresponding net or variable declaration
*
Fix preprocessing of line comments which are neither preceded nor followed by
*
Fix preprocessing of line comments which are neither preceded nor followed by
whitespace except for the newline which terminates the comment
whitespace except for the newline which terminates the comment
*
Fix conversion of references to modports nested within types in expressions
*
Fix conversion of module-scoped references to modports
## v0.0.8
## v0.0.8
...
...
src/Convert/Interface.hs
View file @
6788ecbf
...
@@ -425,10 +425,13 @@ inlineInstance global ranges modportBindings items partName
...
@@ -425,10 +425,13 @@ inlineInstance global ranges modportBindings items partName
embedScopes
tagLHS
>=>
embedScopes
tagLHS
>=>
embedScopes
replaceLHS
embedScopes
replaceLHS
tagLHS
::
Scopes
()
->
LHS
->
LHS
tagLHS
::
Scopes
()
->
LHS
->
LHS
tagLHS
scopes
lhs
=
tagLHS
scopes
lhs
if
lookupElem
scopes
lhs
/=
Nothing
|
lookupElem
scopes
lhs
/=
Nothing
=
then
LHSDot
(
renamePartLHS
lhs
)
"@"
LHSDot
(
renamePartLHS
lhs
)
"@"
else
traverseSinglyNestedLHSs
(
tagLHS
scopes
)
lhs
|
Just
portName
<-
partScopedModportRef
$
lhsToExpr
lhs
=
LHSIdent
portName
|
otherwise
=
traverseSinglyNestedLHSs
(
tagLHS
scopes
)
lhs
renamePartLHS
::
LHS
->
LHS
renamePartLHS
::
LHS
->
LHS
renamePartLHS
(
LHSDot
(
LHSIdent
x
)
y
)
=
renamePartLHS
(
LHSDot
(
LHSIdent
x
)
y
)
=
if
x
==
partName
if
x
==
partName
...
@@ -455,16 +458,19 @@ inlineInstance global ranges modportBindings items partName
...
@@ -455,16 +458,19 @@ inlineInstance global ranges modportBindings items partName
embedScopes
tagExpr
>=>
embedScopes
tagExpr
>=>
embedScopes
replaceExpr
embedScopes
replaceExpr
tagExpr
::
Scopes
()
->
Expr
->
Expr
tagExpr
::
Scopes
()
->
Expr
->
Expr
tagExpr
scopes
expr
=
tagExpr
scopes
expr
if
lookupElem
scopes
expr
/=
Nothing
|
lookupElem
scopes
expr
/=
Nothing
=
then
Dot
(
renamePartExpr
expr
)
"@"
Dot
(
renamePartExpr
expr
)
"@"
else
traverseSinglyNestedExprs
(
tagExpr
scopes
)
expr
|
Just
portName
<-
partScopedModportRef
expr
=
Ident
portName
|
otherwise
=
visitExprsStep
(
tagExpr
scopes
)
expr
renamePartExpr
::
Expr
->
Expr
renamePartExpr
::
Expr
->
Expr
renamePartExpr
(
Dot
(
Ident
x
)
y
)
=
renamePartExpr
(
Dot
(
Ident
x
)
y
)
=
if
x
==
partName
if
x
==
partName
then
Dot
scopedInstanceExpr
y
then
Dot
scopedInstanceExpr
y
else
Dot
(
Ident
x
)
y
else
Dot
(
Ident
x
)
y
renamePartExpr
expr
=
traverseSinglyNestedExprs
renamePartExpr
expr
renamePartExpr
expr
=
visitExprsStep
renamePartExpr
expr
replaceExpr
::
Scopes
()
->
Expr
->
Expr
replaceExpr
::
Scopes
()
->
Expr
->
Expr
replaceExpr
_
(
Dot
expr
"@"
)
=
expr
replaceExpr
_
(
Dot
expr
"@"
)
=
expr
replaceExpr
local
(
Ident
x
)
=
replaceExpr
local
(
Ident
x
)
=
...
@@ -487,7 +493,7 @@ inlineInstance global ranges modportBindings items partName
...
@@ -487,7 +493,7 @@ inlineInstance global ranges modportBindings items partName
case
lookup
expr
exprReplacements
of
case
lookup
expr
exprReplacements
of
Just
expr'
->
expr'
Just
expr'
->
expr'
Nothing
->
checkExprResolution
local
expr
$
Nothing
->
checkExprResolution
local
expr
$
traverseSinglyNestedExprs
(
replaceExprAny
local
)
expr
visitExprsStep
(
replaceExprAny
local
)
expr
replaceExpr'
local
(
Ident
x
)
=
replaceExpr'
local
(
Ident
x
)
=
checkExprResolution
local
(
Ident
x
)
(
Ident
x
)
checkExprResolution
local
(
Ident
x
)
(
Ident
x
)
replaceExpr'
local
expr
=
replaceExprAny
local
expr
replaceExpr'
local
expr
=
replaceExprAny
local
expr
...
@@ -496,11 +502,24 @@ inlineInstance global ranges modportBindings items partName
...
@@ -496,11 +502,24 @@ inlineInstance global ranges modportBindings items partName
case
lookup
expr
exprReplacements
of
case
lookup
expr
exprReplacements
of
Just
expr'
->
expr'
Just
expr'
->
expr'
Nothing
->
checkExprResolution
local
expr
$
Nothing
->
checkExprResolution
local
expr
$
traverseSinglyNestedExprs
(
replaceExpr'
local
)
expr
visitExprsStep
(
replaceExpr'
local
)
expr
replaceArrTag
::
Expr
->
Expr
->
Expr
replaceArrTag
::
Expr
->
Expr
->
Expr
replaceArrTag
replacement
Tag
=
replacement
replaceArrTag
replacement
Tag
=
replacement
replaceArrTag
replacement
expr
=
replaceArrTag
replacement
expr
=
traverseSinglyNestedExprs
(
replaceArrTag
replacement
)
expr
visitExprsStep
(
replaceArrTag
replacement
)
expr
partScopedModportRef
::
Expr
->
Maybe
Identifier
partScopedModportRef
(
Dot
(
Ident
x
)
y
)
=
if
x
==
partName
&&
lookup
y
modportBindings
/=
Nothing
then
Just
y
else
Nothing
partScopedModportRef
_
=
Nothing
visitExprsStep
::
(
Expr
->
Expr
)
->
Expr
->
Expr
visitExprsStep
exprMapper
=
traverseSinglyNestedExprs
exprMapper
.
traverseExprTypes
(
traverseNestedTypes
typeMapper
)
where
typeMapper
=
traverseTypeExprs
exprMapper
checkExprResolution
::
Scopes
()
->
Expr
->
a
->
a
checkExprResolution
::
Scopes
()
->
Expr
->
a
->
a
checkExprResolution
local
expr
=
checkExprResolution
local
expr
=
...
...
test/core/interface_typeof.sv
0 → 100644
View file @
6788ecbf
interface
intf
;
logic
[
2
:
0
]
data
;
modport
m
(
output
.
data
(
data
[
0
]))
;
endinterface
module
mod
(
p
)
;
parameter
X
=
0
;
intf
p
;
initial
begin
mod
.
p
.
data
=
1
;
$
display
(
"mod %0d A %b %0d"
,
X
,
p
.
data
,
$
bits
(
p
.
data
))
;
$
display
(
"mod %0d B %b %0d"
,
X
,
mod
.
p
.
data
,
$
bits
(
mod
.
p
.
data
))
;
$
display
(
"mod %0d C %b %0d"
,
X
,
p
.
data
,
$
bits
(
logic
[$
bits
(
p
.
data
)
:
1
]))
;
$
display
(
"mod %0d D %b %0d"
,
X
,
mod
.
p
.
data
,
$
bits
(
logic
[$
bits
(
mod
.
p
.
data
)
:
1
]))
;
end
endmodule
module
top
;
intf
i
()
;
mod
#(
1
)
m1
(
i
)
;
mod
#(
2
)
m2
(
i
.
m
)
;
endmodule
test/core/interface_typeof.v
0 → 100644
View file @
6788ecbf
module
mod
()
;
parameter
X
=
0
;
parameter
W
=
0
;
reg
[
W
-
1
:
0
]
data
;
initial
begin
data
=
1
;
$
display
(
"mod %0d A %b %0d"
,
X
,
data
,
$
bits
(
data
))
;
$
display
(
"mod %0d B %b %0d"
,
X
,
mod
.
data
,
$
bits
(
mod
.
data
))
;
$
display
(
"mod %0d C %b %0d"
,
X
,
data
,
$
bits
(
data
))
;
$
display
(
"mod %0d D %b %0d"
,
X
,
mod
.
data
,
$
bits
(
mod
.
data
))
;
end
endmodule
module
top
;
mod
#(
1
,
3
)
m1
()
;
mod
#(
2
,
1
)
m2
()
;
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