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
4b5e3232
Commit
4b5e3232
authored
Jul 08, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for localparam type
parent
9aa8d5a5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
11 deletions
+33
-11
src/Convert/ParamType.hs
+4
-11
src/Convert/Typedef.hs
+4
-0
test/basic/localparamtype.sv
+16
-0
test/basic/localparamtype.v
+9
-0
No files found.
src/Convert/ParamType.hs
View file @
4b5e3232
...
@@ -147,22 +147,15 @@ convert files =
...
@@ -147,22 +147,15 @@ convert files =
where
where
Part
attrs
extern
kw
ml
m
p
items
=
part
Part
attrs
extern
kw
ml
m
p
items
=
part
m'
=
moduleInstanceName
m
typeMap
m'
=
moduleInstanceName
m
typeMap
items'
=
map
rewriteDecl
items
items'
=
map
(
traverseDecls
rewriteDecl
)
items
rewriteDecl
::
ModuleItem
->
ModuleItem
rewriteDecl
::
Decl
->
Decl
rewriteDecl
(
MIPackageItem
(
Decl
(
ParamType
Parameter
x
_
))
)
=
rewriteDecl
(
ParamType
Parameter
x
_
)
=
MIPackageItem
$
Typedef
(
typeMap'
Map
.!
x
)
x
ParamType
Localparam
x
(
Just
$
typeMap'
Map
.!
x
)
rewriteDecl
other
=
other
rewriteDecl
other
=
other
explodedTypeMap
=
Map
.
mapWithKey
prepareTypeIdents
typeMap
explodedTypeMap
=
Map
.
mapWithKey
prepareTypeIdents
typeMap
typeMap'
=
Map
.
map
fst
explodedTypeMap
typeMap'
=
Map
.
map
fst
explodedTypeMap
additionalParamItems
=
concatMap
makeAddedParams
$
additionalParamItems
=
concatMap
makeAddedParams
$
Map
.
toList
$
Map
.
map
snd
explodedTypeMap
Map
.
toList
$
Map
.
map
snd
explodedTypeMap
-- TODO FIXME: Typedef conversion must be made to handle
-- ParamTypes!
-----items' = map (traverseDecls rewriteDecl) items
-----rewriteDecl :: Decl -> Decl
-----rewriteDecl (ParamType Parameter x _) =
----- ParamType Localparam x (Just $ typeMap Map.! x)
-----rewriteDecl other = other
makeAddedParams
::
(
Identifier
,
IdentSet
)
->
[
ModuleItem
]
makeAddedParams
::
(
Identifier
,
IdentSet
)
->
[
ModuleItem
]
makeAddedParams
(
paramName
,
identSet
)
=
makeAddedParams
(
paramName
,
identSet
)
=
...
...
src/Convert/Typedef.hs
View file @
4b5e3232
...
@@ -70,6 +70,10 @@ traverseDeclM decl = do
...
@@ -70,6 +70,10 @@ traverseDeclM decl = do
case
decl'
of
case
decl'
of
Variable
{}
->
return
decl'
Variable
{}
->
return
decl'
Param
{}
->
return
decl'
Param
{}
->
return
decl'
ParamType
Localparam
x
(
Just
t
)
->
do
t'
<-
traverseNestedTypesM
traverseTypeM
t
insertElem
x
t'
return
$
CommentDecl
$
"removed localparam type "
++
x
ParamType
{}
->
return
decl'
ParamType
{}
->
return
decl'
CommentDecl
{}
->
return
decl'
CommentDecl
{}
->
return
decl'
...
...
test/basic/localparamtype.sv
0 → 100644
View file @
4b5e3232
module
top
;
localparam
type
T
=
logic
;
initial
begin
$
display
(
"A %0d"
,
$
bits
(
T
))
;
begin
localparam
type
T
=
logic
[
1
:
0
]
;
$
display
(
"B %0d"
,
$
bits
(
T
))
;
begin
localparam
type
T
=
T
[
1
:
0
]
;
$
display
(
"C %0d"
,
$
bits
(
T
))
;
end
$
display
(
"B %0d"
,
$
bits
(
T
))
;
end
$
display
(
"A %0d"
,
$
bits
(
T
))
;
end
endmodule
test/basic/localparamtype.v
0 → 100644
View file @
4b5e3232
module
top
;
initial
begin
$
display
(
"A %0d"
,
1
)
;
$
display
(
"B %0d"
,
2
)
;
$
display
(
"C %0d"
,
4
)
;
$
display
(
"B %0d"
,
2
)
;
$
display
(
"A %0d"
,
1
)
;
end
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