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
ecee8b33
Commit
ecee8b33
authored
Apr 15, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for interface based typedefs
parent
1ba5ab27
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
2 deletions
+38
-2
README.md
+2
-2
src/Convert/Traverse.hs
+2
-0
src/Convert/Typedef.hs
+5
-0
src/Language/SystemVerilog/AST/Type.hs
+3
-0
src/Language/SystemVerilog/Parser/Parse.y
+4
-0
test/basic/interface_based_typedef.sv
+18
-0
test/basic/interface_based_typedef.v
+4
-0
No files found.
README.md
View file @
ecee8b33
...
...
@@ -107,8 +107,8 @@ Other:
## Supported Features
sv2v supports most synthesizable SystemVerilog features. Current notable
exceptions include
`defparam`
on interface instances and
references to typedefs
within interface instanc
es. Assertions are also supported, but are simply
exceptions include
`defparam`
on interface instances and
certain synthesizable
usages of parameterized class
es. Assertions are also supported, but are simply
dropped during conversion.
If you find a bug or have a feature request, please create an issue. Preference
...
...
src/Convert/Traverse.hs
View file @
ecee8b33
...
...
@@ -821,6 +821,7 @@ traverseSinglyNestedTypesM mapper = tm
tm
(
IntegerAtom
kw
sg
)
=
return
$
IntegerAtom
kw
sg
tm
(
NonInteger
kw
)
=
return
$
NonInteger
kw
tm
(
TypeOf
expr
)
=
return
$
TypeOf
expr
tm
(
TypedefRef
expr
)
=
return
$
TypedefRef
expr
tm
(
InterfaceT
x
y
r
)
=
return
$
InterfaceT
x
y
r
tm
(
Enum
t
vals
r
)
=
do
t'
<-
mapper
t
...
...
@@ -879,6 +880,7 @@ 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
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 @
ecee8b33
...
...
@@ -95,6 +95,11 @@ traverseTypeM (Alias st rs1) = do
Just
(
_
,
_
,
UnknownType
)
->
Alias
st
rs1'
Just
(
_
,
_
,
typ
)
->
tf
$
rs1'
++
rs2
where
(
tf
,
rs2
)
=
typeRanges
typ
traverseTypeM
(
TypedefRef
expr
)
=
do
details
<-
lookupElemM
expr
return
$
case
details
of
Nothing
->
TypedefRef
expr
Just
(
_
,
_
,
typ
)
->
typ
traverseTypeM
other
=
traverseSinglyNestedTypesM
traverseTypeM
other
>>=
traverseTypeExprsM
traverseExprM
...
...
src/Language/SystemVerilog/AST/Type.hs
View file @
ecee8b33
...
...
@@ -51,6 +51,7 @@ data Type
|
Union
Packing
[
Field
]
[
Range
]
|
InterfaceT
Identifier
Identifier
[
Range
]
|
TypeOf
Expr
|
TypedefRef
Expr
|
UnpackedType
Type
[
Range
]
-- used internally
deriving
(
Eq
,
Ord
)
...
...
@@ -74,6 +75,7 @@ instance Show Type where
show
(
Union
p
items
r
)
=
printf
"union %s{
\n
%s
\n
}%s"
(
showPad
p
)
(
showFields
items
)
(
showRanges
r
)
show
(
TypeOf
expr
)
=
printf
"type(%s)"
(
show
expr
)
show
(
UnpackedType
t
rs
)
=
printf
"UnpackedType(%s, %s)"
(
show
t
)
(
showRanges
rs
)
show
(
TypedefRef
e
)
=
show
e
showFields
::
[
Field
]
->
String
showFields
items
=
itemsStr
...
...
@@ -112,6 +114,7 @@ typeRanges typ =
IntegerAtom
kw
sg
->
(
nullRange
$
IntegerAtom
kw
sg
,
[]
)
NonInteger
kw
->
(
nullRange
$
NonInteger
kw
,
[]
)
TypeOf
expr
->
(
nullRange
$
TypeOf
expr
,
[]
)
TypedefRef
expr
->
(
nullRange
$
TypedefRef
expr
,
[]
)
nullRange
::
Type
->
([
Range
]
->
Type
)
nullRange
t
[]
=
t
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
ecee8b33
...
...
@@ -848,6 +848,7 @@ PackageItem :: { [PackageItem] }
NonDeclPackageItem
::
{
[
PackageItem
]
}
:
"typedef"
Type
Identifier
";"
{
[
Decl
$
ParamType
Localparam
$
3
$
2
]
}
|
"typedef"
Type
Identifier
DimensionsNonEmpty
";"
{
[
Decl
$
ParamType
Localparam
$
3
(
UnpackedType
$
2
$
4
)]
}
|
"typedef"
TypedefRef
Identifier
";"
{
[
Decl
$
ParamType
Localparam
$
3
$
2
]
}
|
"function"
Lifetime
FuncRetAndName
TFItems
DeclsAndStmts
endfunction
opt
(
Tag
)
{
[
Function
$
2
(
fst
$
3
)
(
snd
$
3
)
(
map
makeInput
$
4
++
fst
$
5
)
(
snd
$
5
)]
}
|
"function"
Lifetime
"void"
Identifier
TFItems
DeclsAndStmts
endfunction
opt
(
Tag
)
{
[
Task
$
2
$
4
(
$
5
++
fst
$
6
)
(
snd
$
6
)]
}
|
"task"
Lifetime
Identifier
TFItems
DeclsAndStmts
endtask
opt
(
Tag
)
{
[
Task
$
2
$
3
(
$
4
++
fst
$
5
)
(
snd
$
5
)]
}
...
...
@@ -857,6 +858,9 @@ NonDeclPackageItem :: { [PackageItem] }
|
ForwardTypedef
";"
{
$
1
}
|
TimeunitsDeclaration
{
$
1
}
|
Directive
{
[
Directive
$
1
]
}
TypedefRef
::
{
Type
}
:
Identifier
"."
Identifier
{
TypedefRef
$
Dot
(
Ident
$
1
)
$
3
}
|
Identifier
"["
Expr
"]"
"."
Identifier
{
TypedefRef
$
Dot
(
Bit
(
Ident
$
1
)
$
3
)
$
6
}
ForwardTypedef
::
{
[
PackageItem
]
}
:
"typedef"
Identifier
{
[]
}
|
"typedef"
"enum"
Identifier
{
[]
}
...
...
test/basic/interface_based_typedef.sv
0 → 100644
View file @
ecee8b33
interface
intf_i
;
typedef
int
data_t
;
endinterface
module
sub
(
intf_i
p
,
intf_i
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
;
initial
$
display
(
"p %0d %b"
,
$
bits
(
p_data
)
,
p_data
)
;
initial
$
display
(
"q %0d %b"
,
$
bits
(
q_data
)
,
q_data
)
;
endmodule
module
top
;
intf_i
p
()
;
intf_i
q
[
2
]()
;
sub
s
(
p
,
q
)
;
endmodule
test/basic/interface_based_typedef.v
0 → 100644
View file @
ecee8b33
module
top
;
initial
$
display
(
"p %0d %b"
,
32
,
32'bx
)
;
initial
$
display
(
"q %0d %b"
,
32
,
32'bx
)
;
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