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
b28a3cac
Commit
b28a3cac
authored
Jan 24, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
represent typedefs as localparam types
parent
378ede9e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
23 deletions
+5
-23
src/Convert/Package.hs
+2
-9
src/Convert/Traverse.hs
+0
-5
src/Convert/Typedef.hs
+0
-4
src/Language/SystemVerilog/AST/Description.hs
+1
-3
src/Language/SystemVerilog/Parser/Parse.y
+2
-2
No files found.
src/Convert/Package.hs
View file @
b28a3cac
...
@@ -267,12 +267,6 @@ processItems topName packageName moduleItems = do
...
@@ -267,12 +267,6 @@ processItems topName packageName moduleItems = do
++
intercalate
", "
rootPkgs
++
intercalate
", "
rootPkgs
traversePackageItemM
::
PackageItem
->
Scope
PackageItem
traversePackageItemM
::
PackageItem
->
Scope
PackageItem
-- TODO: fold this in with type parameters
traversePackageItemM
(
Typedef
t
x
)
=
do
t'
<-
traverseTypeM
t
x'
<-
prefixIdent
x
t''
<-
traverseNestedTypesM
(
traverseTypeExprsM
traverseExprM
)
t'
return
$
Typedef
t''
x'
traversePackageItemM
(
orig
@
(
Import
pkg
ident
))
=
do
traversePackageItemM
(
orig
@
(
Import
pkg
ident
))
=
do
if
null
ident
if
null
ident
then
wildcardImports
pkg
then
wildcardImports
pkg
...
@@ -516,6 +510,8 @@ traverseDeclIdentsM identMapper =
...
@@ -516,6 +510,8 @@ traverseDeclIdentsM identMapper =
-- returns any names defined by a package item
-- returns any names defined by a package item
piNames
::
PackageItem
->
[
Identifier
]
piNames
::
PackageItem
->
[
Identifier
]
piNames
(
Decl
(
ParamType
_
ident
(
Enum
_
enumItems
_
)))
=
ident
:
map
fst
enumItems
piNames
(
Function
_
_
ident
_
_
)
=
[
ident
]
piNames
(
Function
_
_
ident
_
_
)
=
[
ident
]
piNames
(
Task
_
ident
_
_
)
=
[
ident
]
piNames
(
Task
_
ident
_
_
)
=
[
ident
]
piNames
(
Decl
(
Variable
_
_
ident
_
_
))
=
[
ident
]
piNames
(
Decl
(
Variable
_
_
ident
_
_
))
=
[
ident
]
...
@@ -525,6 +521,3 @@ piNames (Decl (CommentDecl _)) = []
...
@@ -525,6 +521,3 @@ piNames (Decl (CommentDecl _)) = []
piNames
(
Import
x
y
)
=
[
show
$
Import
x
y
]
piNames
(
Import
x
y
)
=
[
show
$
Import
x
y
]
piNames
(
Export
x
y
)
=
[
show
$
Export
x
y
]
piNames
(
Export
x
y
)
=
[
show
$
Export
x
y
]
piNames
(
Directive
_
)
=
[]
piNames
(
Directive
_
)
=
[]
piNames
(
Typedef
(
Enum
_
enumItems
_
)
ident
)
=
ident
:
map
fst
enumItems
piNames
(
Typedef
_
ident
)
=
[
ident
]
src/Convert/Traverse.hs
View file @
b28a3cac
...
@@ -555,9 +555,6 @@ traverseNodesM exprMapper declMapper typeMapper lhsMapper stmtMapper =
...
@@ -555,9 +555,6 @@ traverseNodesM exprMapper declMapper typeMapper lhsMapper stmtMapper =
moduleItemMapper
(
MIAttr
attr
mi
)
=
moduleItemMapper
(
MIAttr
attr
mi
)
=
-- note: we exclude expressions in attributes from conversion
-- note: we exclude expressions in attributes from conversion
return
$
MIAttr
attr
mi
return
$
MIAttr
attr
mi
moduleItemMapper
(
MIPackageItem
(
Typedef
t
x
))
=
do
t'
<-
typeMapper
t
return
$
MIPackageItem
$
Typedef
t'
x
moduleItemMapper
(
MIPackageItem
(
Decl
decl
))
=
moduleItemMapper
(
MIPackageItem
(
Decl
decl
))
=
declMapper
decl
>>=
return
.
MIPackageItem
.
Decl
declMapper
decl
>>=
return
.
MIPackageItem
.
Decl
moduleItemMapper
(
Defparam
lhs
expr
)
=
do
moduleItemMapper
(
Defparam
lhs
expr
)
=
do
...
@@ -951,8 +948,6 @@ traverseTypesM' strategy mapper =
...
@@ -951,8 +948,6 @@ traverseTypesM' strategy mapper =
where
where
exprMapper
=
traverseExprTypesM
mapper
exprMapper
=
traverseExprTypesM
mapper
declMapper
=
traverseDeclTypesM
mapper
declMapper
=
traverseDeclTypesM
mapper
miMapper
(
MIPackageItem
(
Typedef
t
x
))
=
mapper
t
>>=
\
t'
->
return
$
MIPackageItem
$
Typedef
t'
x
miMapper
(
MIPackageItem
(
Function
l
t
x
d
s
))
=
miMapper
(
MIPackageItem
(
Function
l
t
x
d
s
))
=
mapper
t
>>=
\
t'
->
return
$
MIPackageItem
$
Function
l
t'
x
d
s
mapper
t
>>=
\
t'
->
return
$
MIPackageItem
$
Function
l
t'
x
d
s
miMapper
(
MIPackageItem
(
other
@
(
Task
_
_
_
_
)))
=
miMapper
(
MIPackageItem
(
other
@
(
Task
_
_
_
_
)))
=
...
...
src/Convert/Typedef.hs
View file @
b28a3cac
...
@@ -45,10 +45,6 @@ traverseExprM (DimFn f v e) = do
...
@@ -45,10 +45,6 @@ traverseExprM (DimFn f v e) = do
traverseExprM
other
=
return
other
traverseExprM
other
=
return
other
traverseModuleItemM
::
ModuleItem
->
Scoper
Type
ModuleItem
traverseModuleItemM
::
ModuleItem
->
Scoper
Type
ModuleItem
traverseModuleItemM
(
MIPackageItem
(
Typedef
t
x
))
=
do
t'
<-
traverseNestedTypesM
traverseTypeM
t
insertElem
x
t'
return
$
Generate
[]
traverseModuleItemM
(
Instance
m
params
x
rs
p
)
=
do
traverseModuleItemM
(
Instance
m
params
x
rs
p
)
=
do
let
mapParam
(
i
,
v
)
=
traverseTypeOrExprM
v
>>=
\
v'
->
return
(
i
,
v'
)
let
mapParam
(
i
,
v
)
=
traverseTypeOrExprM
v
>>=
\
v'
->
return
(
i
,
v'
)
params'
<-
mapM
mapParam
params
params'
<-
mapM
mapParam
params
...
...
src/Language/SystemVerilog/AST/Description.hs
View file @
b28a3cac
...
@@ -52,8 +52,7 @@ instance Show Description where
...
@@ -52,8 +52,7 @@ instance Show Description where
show
(
PackageItem
i
)
=
show
i
show
(
PackageItem
i
)
=
show
i
data
PackageItem
data
PackageItem
=
Typedef
Type
Identifier
=
Function
Lifetime
Type
Identifier
[
Decl
]
[
Stmt
]
|
Function
Lifetime
Type
Identifier
[
Decl
]
[
Stmt
]
|
Task
Lifetime
Identifier
[
Decl
]
[
Stmt
]
|
Task
Lifetime
Identifier
[
Decl
]
[
Stmt
]
|
Import
Identifier
Identifier
|
Import
Identifier
Identifier
|
Export
Identifier
Identifier
|
Export
Identifier
Identifier
...
@@ -62,7 +61,6 @@ data PackageItem
...
@@ -62,7 +61,6 @@ data PackageItem
deriving
Eq
deriving
Eq
instance
Show
PackageItem
where
instance
Show
PackageItem
where
show
(
Typedef
t
x
)
=
printf
"typedef %s %s;"
(
show
t
)
x
show
(
Function
ml
t
x
i
b
)
=
show
(
Function
ml
t
x
i
b
)
=
printf
"function %s%s%s;
\n
%s
\n
endfunction"
(
showPad
ml
)
(
showPad
t
)
x
printf
"function %s%s%s;
\n
%s
\n
endfunction"
(
showPad
ml
)
(
showPad
t
)
x
(
showBlock
i
b
)
(
showBlock
i
b
)
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
b28a3cac
...
@@ -837,8 +837,8 @@ PackageItem :: { [PackageItem] }
...
@@ -837,8 +837,8 @@ PackageItem :: { [PackageItem] }
|
ParameterDecl
(
";"
)
{
map
(
Decl
.
makeLocalparam
)
$
1
}
|
ParameterDecl
(
";"
)
{
map
(
Decl
.
makeLocalparam
)
$
1
}
|
NonDeclPackageItem
{
$
1
}
|
NonDeclPackageItem
{
$
1
}
NonDeclPackageItem
::
{
[
PackageItem
]
}
NonDeclPackageItem
::
{
[
PackageItem
]
}
:
"typedef"
Type
Identifier
";"
{
[
Typedef
$
2
$
3
]
}
:
"typedef"
Type
Identifier
";"
{
[
Decl
$
ParamType
Localparam
$
3
$
2
]
}
|
"typedef"
Type
Identifier
DimensionsNonEmpty
";"
{
[
Typedef
(
UnpackedType
$
2
$
4
)
$
3
]
}
|
"typedef"
Type
Identifier
DimensionsNonEmpty
";"
{
[
Decl
$
ParamType
Localparam
$
3
(
UnpackedType
$
2
$
4
)
]
}
|
"function"
Lifetime
FuncRetAndName
TFItems
DeclsAndStmts
"endfunction"
opt
(
Tag
)
{
[
Function
$
2
(
fst
$
3
)
(
snd
$
3
)
(
map
defaultFuncInput
$
(
map
makeInput
$
4
)
++
fst
$
5
)
(
snd
$
5
)]
}
|
"function"
Lifetime
FuncRetAndName
TFItems
DeclsAndStmts
"endfunction"
opt
(
Tag
)
{
[
Function
$
2
(
fst
$
3
)
(
snd
$
3
)
(
map
defaultFuncInput
$
(
map
makeInput
$
4
)
++
fst
$
5
)
(
snd
$
5
)]
}
|
"function"
Lifetime
"void"
Identifier
TFItems
DeclsAndStmts
"endfunction"
opt
(
Tag
)
{
[
Task
$
2
$
4
(
map
defaultFuncInput
$
$
5
++
fst
$
6
)
(
snd
$
6
)]
}
|
"function"
Lifetime
"void"
Identifier
TFItems
DeclsAndStmts
"endfunction"
opt
(
Tag
)
{
[
Task
$
2
$
4
(
map
defaultFuncInput
$
$
5
++
fst
$
6
)
(
snd
$
6
)]
}
|
"task"
Lifetime
Identifier
TFItems
DeclsAndStmts
"endtask"
opt
(
Tag
)
{
[
Task
$
2
$
3
(
map
defaultFuncInput
$
$
4
++
fst
$
5
)
(
snd
$
5
)]
}
|
"task"
Lifetime
Identifier
TFItems
DeclsAndStmts
"endtask"
opt
(
Tag
)
{
[
Task
$
2
$
3
(
map
defaultFuncInput
$
$
4
++
fst
$
5
)
(
snd
$
5
)]
}
...
...
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