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
b1f1b822
Commit
b1f1b822
authored
Sep 18, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix conversion of interface-based typedefs
parent
6788ecbf
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
5 deletions
+53
-5
CHANGELOG.md
+2
-0
src/Convert/Struct.hs
+1
-0
src/Convert/Traverse.hs
+10
-1
src/Convert/Typedef.hs
+3
-2
test/core/interface_based_typedef.sv
+17
-2
test/core/interface_based_typedef.v
+6
-0
test/core/interface_based_typedef_delay.sv
+7
-0
test/core/interface_based_typedef_delay.v
+7
-0
No files found.
CHANGELOG.md
View file @
b1f1b822
...
...
@@ -30,6 +30,8 @@
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
*
Fix conversion of interface-based typedefs when used with explicit modports,
unpacked arrays, or in designs with multi-dimensional instances
## v0.0.8
...
...
src/Convert/Struct.hs
View file @
b1f1b822
...
...
@@ -126,6 +126,7 @@ traverseDeclM decl = do
isRangeable
IntegerAtom
{}
=
False
isRangeable
NonInteger
{}
=
False
isRangeable
TypeOf
{}
=
False
isRangeable
TypedefRef
{}
=
False
isRangeable
_
=
True
traverseGenItemM
::
GenItem
->
Scoper
Type
GenItem
...
...
src/Convert/Traverse.hs
View file @
b1f1b822
...
...
@@ -882,7 +882,16 @@ traverseTypeExprsM exprMapper =
typeOrExprMapper
(
Right
e
)
=
exprMapper
e
>>=
return
.
Right
typeMapper
(
TypeOf
expr
)
=
exprMapper
expr
>>=
return
.
TypeOf
-- TypedefRef is excluded because it isn't really an expression
-- TypedefRef root is a reference to a port, but the "field" here is
-- really a typename; this indirection circumvents the interface
-- expression resolution check and ensures the underlying modport is
-- appropriately resolved to the corresponding interface instance
typeMapper
(
TypedefRef
expr
)
=
do
let
Dot
inn
typ
=
expr
let
wrap
=
Dot
inn
"*"
wrap'
<-
exprMapper
wrap
let
Dot
inn'
"*"
=
wrap'
return
$
TypedefRef
$
Dot
inn'
typ
typeMapper
(
CSAlias
ps
pm
xx
rs
)
=
do
vals'
<-
mapM
typeOrExprMapper
$
map
snd
pm
let
pm'
=
zip
(
map
fst
pm
)
vals'
...
...
src/Convert/Typedef.hs
View file @
b1f1b822
...
...
@@ -16,8 +16,9 @@ import Convert.Traverse
import
Language.SystemVerilog.AST
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
$
partScoper
traverseDeclM
traverseModuleItemM
traverseGenItemM
traverseStmtM
convert
=
map
$
traverseDescriptions
$
evalScoper
.
scopeModule
scoper
where
scoper
=
scopeModuleItem
traverseDeclM
traverseModuleItemM
traverseGenItemM
traverseStmtM
traverseTypeOrExprM
::
TypeOrExpr
->
Scoper
Type
TypeOrExpr
traverseTypeOrExprM
(
Left
(
TypeOf
(
Ident
x
)))
=
do
...
...
test/core/interface_based_typedef.sv
View file @
b1f1b822
...
...
@@ -2,21 +2,36 @@ interface intf_i;
typedef
int
data_t
;
endinterface
module
sub
(
intf_i
p
,
intf_i
q
[
2
])
;
interface
intf_j
;
typedef
logic
[
1
:
0
]
data_t
;
logic
dummy
;
modport
m
(
input
dummy
)
;
endinterface
module
sub
(
interface
p
,
interface
q
[
2
])
;
typedef
p
.
data_t
p_data_t
;
// interface based typedef
typedef
q
[
0
]
.
data_t
q_data_t
;
// interface based typedef
p_data_t
p_data
;
q_data_t
q_data
;
p_data_t
p_data_arr
[
2
]
;
q_data_t
q_data_arr
[
2
]
;
initial
begin
p_data
=
1
;
q_data
=
2
;
p_data_arr
[
0
]
=
2
;
q_data_arr
[
0
]
=
2
;
$
display
(
"p %0d %b"
,
$
bits
(
p_data
)
,
p_data
)
;
$
display
(
"q %0d %b"
,
$
bits
(
q_data
)
,
q_data
)
;
$
display
(
"p %0d"
,
$
bits
(
p_data_arr
))
;
$
display
(
"q %0d"
,
$
bits
(
q_data_arr
))
;
end
endmodule
module
top
;
intf_i
p
()
;
intf_i
q
[
2
]()
;
sub
s
(
p
,
q
)
;
sub
si
(
p
,
q
)
;
intf_j
r
()
;
intf_j
s
[
2
]()
;
sub
sj
(
r
.
m
,
s
)
;
endmodule
test/core/interface_based_typedef.v
View file @
b1f1b822
module
top
;
initial
$
display
(
"p %0d %b"
,
32
,
32'd1
)
;
initial
$
display
(
"q %0d %b"
,
32
,
32'd2
)
;
initial
$
display
(
"p %0d"
,
64
)
;
initial
$
display
(
"q %0d"
,
64
)
;
initial
$
display
(
"p %0d %b"
,
2
,
2'd1
)
;
initial
$
display
(
"q %0d %b"
,
2
,
2'd2
)
;
initial
$
display
(
"p %0d"
,
4
)
;
initial
$
display
(
"q %0d"
,
4
)
;
endmodule
test/core/interface_based_typedef_delay.sv
0 → 100644
View file @
b1f1b822
module
poof
;
initial
$
display
(
"poof"
)
;
endmodule
module
alt
;
poof
poof
[
2
][
2
]()
;
endmodule
`include
"interface_based_typedef.sv"
test/core/interface_based_typedef_delay.v
0 → 100644
View file @
b1f1b822
module
poof
;
initial
$
display
(
"poof"
)
;
endmodule
module
alt
;
poof
poof
[
0
:
3
]()
;
endmodule
`include
"interface_based_typedef.v"
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