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
c876c447
Commit
c876c447
authored
Feb 09, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix interface inlining renaming
parent
df4244d8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
21 deletions
+61
-21
src/Convert.hs
+1
-1
src/Convert/Interface.hs
+35
-16
test/basic/interface_infer.sv
+13
-2
test/basic/interface_infer.v
+12
-2
No files found.
src/Convert.hs
View file @
c876c447
...
@@ -57,7 +57,6 @@ phases excludes =
...
@@ -57,7 +57,6 @@ phases excludes =
,
Convert
.
Assertion
.
convert
,
Convert
.
Assertion
.
convert
,
Convert
.
BlockDecl
.
convert
,
Convert
.
BlockDecl
.
convert
,
selectExclude
(
Job
.
Logic
,
Convert
.
Logic
.
convert
)
,
selectExclude
(
Job
.
Logic
,
Convert
.
Logic
.
convert
)
,
Convert
.
ForDecl
.
convert
,
Convert
.
FuncRet
.
convert
,
Convert
.
FuncRet
.
convert
,
Convert
.
FuncRoutine
.
convert
,
Convert
.
FuncRoutine
.
convert
,
Convert
.
EmptyArgs
.
convert
,
Convert
.
EmptyArgs
.
convert
...
@@ -88,6 +87,7 @@ phases excludes =
...
@@ -88,6 +87,7 @@ phases excludes =
,
Convert
.
Jump
.
convert
,
Convert
.
Jump
.
convert
,
Convert
.
Foreach
.
convert
,
Convert
.
Foreach
.
convert
,
selectExclude
(
Job
.
Interface
,
Convert
.
Interface
.
convert
)
,
selectExclude
(
Job
.
Interface
,
Convert
.
Interface
.
convert
)
,
Convert
.
ForDecl
.
convert
,
selectExclude
(
Job
.
Always
,
Convert
.
AlwaysKW
.
convert
)
,
selectExclude
(
Job
.
Always
,
Convert
.
AlwaysKW
.
convert
)
,
selectExclude
(
Job
.
Succinct
,
Convert
.
RemoveComments
.
convert
)
,
selectExclude
(
Job
.
Succinct
,
Convert
.
RemoveComments
.
convert
)
]
]
...
...
src/Convert/Interface.hs
View file @
c876c447
...
@@ -199,39 +199,52 @@ convertDescription _ _ other = other
...
@@ -199,39 +199,52 @@ convertDescription _ _ other = other
-- add a prefix to all standard identifiers in a module item
-- add a prefix to all standard identifiers in a module item
prefixModuleItems
::
Identifier
->
ModuleItem
->
ModuleItem
prefixModuleItems
::
(
Identifier
->
Identifier
)
->
ModuleItem
->
ModuleItem
prefixModuleItems
prefix
=
prefixModuleItems
prefix
=
prefix
MIPackage
Item
.
prefix
Other
Item
.
traverseDecls
prefixDecl
.
traverseDecls
prefixDecl
.
traverseExprs
(
traverseNestedExprs
prefixExpr
)
.
traverseExprs
(
traverseNestedExprs
prefixExpr
)
.
traverseLHSs
(
traverseNestedLHSs
prefixLHS
)
traverseLHSs
(
traverseNestedLHSs
prefixLHS
)
where
where
prefixDecl
::
Decl
->
Decl
prefixDecl
::
Decl
->
Decl
prefixDecl
(
Variable
d
t
x
a
me
)
=
Variable
d
t
(
prefix
++
x
)
a
me
prefixDecl
(
Variable
d
t
x
a
me
)
=
Variable
d
t
(
prefix
x
)
a
me
prefixDecl
(
Param
s
t
x
e
)
=
Param
s
t
(
prefix
++
x
)
e
prefixDecl
(
Param
s
t
x
e
)
=
Param
s
t
(
prefix
x
)
e
prefixDecl
(
ParamType
s
x
mt
)
=
ParamType
s
(
prefix
++
x
)
mt
prefixDecl
(
ParamType
s
x
mt
)
=
ParamType
s
(
prefix
x
)
mt
prefixDecl
(
CommentDecl
c
)
=
CommentDecl
c
prefixDecl
(
CommentDecl
c
)
=
CommentDecl
c
prefixExpr
::
Expr
->
Expr
prefixExpr
::
Expr
->
Expr
prefixExpr
(
Ident
(
'$'
:
x
))
=
Ident
$
'$'
:
x
prefixExpr
(
Ident
x
)
=
Ident
(
prefix
x
)
prefixExpr
(
Ident
x
)
=
Ident
(
prefix
++
x
)
prefixExpr
other
=
other
prefixExpr
other
=
other
prefixLHS
::
LHS
->
LHS
prefixLHS
::
LHS
->
LHS
prefixLHS
(
LHSIdent
x
)
=
LHSIdent
(
prefix
++
x
)
prefixLHS
(
LHSIdent
x
)
=
LHSIdent
(
prefix
x
)
prefixLHS
other
=
other
prefixLHS
other
=
other
prefix
MIPackage
Item
(
MIPackageItem
item
)
=
prefix
Other
Item
(
MIPackageItem
item
)
=
MIPackageItem
$
prefixPackageItem
prefix
item
MIPackageItem
$
prefixPackageItem
prefix
item
prefixMIPackageItem
other
=
other
prefixOtherItem
(
Genvar
x
)
=
Genvar
$
prefix
x
prefixOtherItem
other
=
other
-- add a prefix to all standard identifiers in a package item
-- add a prefix to all standard identifiers in a package item
prefixPackageItem
::
Identifier
->
PackageItem
->
PackageItem
prefixPackageItem
::
(
Identifier
->
Identifier
)
->
PackageItem
->
PackageItem
prefixPackageItem
prefix
(
Function
lifetime
t
x
decls
stmts
)
=
prefixPackageItem
prefix
(
Function
lifetime
t
x
decls
stmts
)
=
Function
lifetime
t
x'
decls
stmts
Function
lifetime
t
x'
decls
stmts
where
x'
=
prefix
++
x
where
x'
=
prefix
x
prefixPackageItem
prefix
(
Task
lifetime
x
decls
stmts
)
=
prefixPackageItem
prefix
(
Task
lifetime
x
decls
stmts
)
=
Task
lifetime
x'
decls
stmts
Task
lifetime
x'
decls
stmts
where
x'
=
prefix
++
x
where
x'
=
prefix
x
prefixPackageItem
_
other
=
other
prefixPackageItem
_
other
=
other
-- collect all identifiers defined within a module item
collectIdentsM
::
ModuleItem
->
Writer
(
Set
.
Set
Identifier
)
()
collectIdentsM
(
MIPackageItem
(
Function
_
_
x
_
_
))
=
tell
$
Set
.
singleton
x
collectIdentsM
(
MIPackageItem
(
Task
_
x
_
_
))
=
tell
$
Set
.
singleton
x
collectIdentsM
(
Genvar
x
)
=
tell
$
Set
.
singleton
x
collectIdentsM
item
=
collectDeclsM
collectDecl
item
where
collectDecl
::
Decl
->
Writer
(
Set
.
Set
Identifier
)
()
collectDecl
(
Variable
_
_
x
_
_
)
=
tell
$
Set
.
singleton
x
collectDecl
(
Param
_
_
x
_
)
=
tell
$
Set
.
singleton
x
collectDecl
(
ParamType
_
x
_
)
=
tell
$
Set
.
singleton
x
collectDecl
(
CommentDecl
_
)
=
return
()
lookupType
::
[
ModuleItem
]
->
Expr
->
(
Type
,
[
Range
])
lookupType
::
[
ModuleItem
]
->
Expr
->
(
Type
,
[
Range
])
lookupType
items
(
Ident
ident
)
=
lookupType
items
(
Ident
ident
)
=
case
mapMaybe
findType
items
of
case
mapMaybe
findType
items
of
...
@@ -258,10 +271,16 @@ inlineInterface (ports, items) (instanceName, instanceParams, instancePorts) =
...
@@ -258,10 +271,16 @@ inlineInterface (ports, items) (instanceName, instanceParams, instancePorts) =
where
where
comment
=
MIPackageItem
$
Decl
$
CommentDecl
$
comment
=
MIPackageItem
$
Decl
$
CommentDecl
$
"expanded instance: "
++
instanceName
"expanded instance: "
++
instanceName
prefix
=
instanceName
++
"_"
prefix
=
instanceName
++
"_"
idents
=
execWriter
$
mapM
(
collectNestedModuleItemsM
collectIdentsM
)
items
prefixIfNecessary
::
Identifier
->
Identifier
prefixIfNecessary
x
=
if
Set
.
member
x
idents
then
prefix
++
x
else
x
itemsPrefixed
=
itemsPrefixed
=
map
(
prefixModuleItems
prefix
)
$
map
(
traverseNestedModuleItems
$
prefixModuleItems
prefixIfNecessary
)
$
map
(
traverseDecls
overrideParam
)
$
map
(
traverseDecls
overrideParam
)
$
items
items
origInstancePortNames
=
map
fst
instancePorts
origInstancePortNames
=
map
fst
instancePorts
...
...
test/basic/interface_infer.sv
View file @
c876c447
localparam
SOME_VAL
=
3
;
interface
Interface
;
interface
Interface
;
logic
x
;
logic
x
;
modport
Modport
(
modport
Modport
(
input
x
input
x
)
;
)
;
initial
$
display
(
"Interface"
,
x
)
;
initial
$
display
(
"Interface %d %d"
,
x
,
SOME_VAL
)
;
generate
for
(
genvar
g
=
10
;
g
<
15
;
++
g
)
begin
initial
$
display
(
g
)
;
end
endgenerate
endinterface
endinterface
module
Module
(
Interface
.
Modport
foo
)
;
module
Module
(
Interface
.
Modport
foo
)
;
initial
$
display
(
"Module"
,
foo
.
x
)
;
initial
$
display
(
"Module
%d
"
,
foo
.
x
)
;
endmodule
endmodule
module
top
;
module
top
;
generate
for
(
genvar
g
=
0
;
g
<
5
;
++
g
)
begin
initial
$
display
(
g
)
;
end
endgenerate
Interface
i
()
;
Interface
i
()
;
Module
m
(
i
)
;
Module
m
(
i
)
;
endmodule
endmodule
test/basic/interface_infer.v
View file @
c876c447
module
Module
(
input
wire
x
)
;
module
Module
(
input
wire
x
)
;
initial
$
display
(
"Module"
,
x
)
;
initial
$
display
(
"Module
%d
"
,
x
)
;
endmodule
endmodule
module
top
;
module
top
;
wire
i_x
;
wire
i_x
;
initial
$
display
(
"Interface"
,
i_x
)
;
localparam
SOME_VAL
=
3
;
initial
$
display
(
"Interface %d %d"
,
i_x
,
SOME_VAL
)
;
Module
m
(
.
x
(
i_x
))
;
Module
m
(
.
x
(
i_x
))
;
generate
genvar
g
;
for
(
g
=
0
;
g
<
5
;
g
=
g
+
1
)
begin
initial
$
display
(
g
)
;
end
for
(
g
=
10
;
g
<
15
;
g
=
g
+
1
)
begin
initial
$
display
(
g
)
;
end
endgenerate
endmodule
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