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
90de4aa1
Commit
90de4aa1
authored
Jul 19, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix inadvertent duplicate casts
parent
03b6ece9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
7 deletions
+46
-7
src/Convert/SizeCast.hs
+21
-7
test/basic/duplicate_cast.sv
+14
-0
test/basic/duplicate_cast.v
+11
-0
No files found.
src/Convert/SizeCast.hs
View file @
90de4aa1
...
...
@@ -8,6 +8,7 @@
module
Convert.SizeCast
(
convert
)
where
import
Control.Monad.Writer
import
Data.List
(
isPrefixOf
)
import
Convert.ExprUtils
import
Convert.Scoper
...
...
@@ -18,17 +19,30 @@ convert :: [AST] -> [AST]
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
=
partScoper
convertDescription
=
traverseModuleItems
dropDuplicateCaster
.
partScoper
traverseDeclM
traverseModuleItemM
traverseGenItemM
traverseStmtM
traverseDeclM
::
Decl
->
Scoper
Type
Decl
traverseDeclM
decl
=
do
case
decl
of
Variable
_
t
x
_
_
->
insertElem
x
t
Param
_
t
x
_
->
insertElem
x
t
ParamType
_
_
_
->
return
()
CommentDecl
_
->
return
()
traverseDeclExprsM
traverseExprM
decl
decl'
<-
case
decl
of
Variable
_
t
x
_
_
->
do
details
<-
lookupElemM
x
if
isPrefixOf
"sv2v_cast_"
x
&&
details
/=
Nothing
then
return
$
Variable
Local
DuplicateTag
x
[]
Nil
else
insertElem
x
t
>>
return
decl
Param
_
t
x
_
->
insertElem
x
t
>>
return
decl
ParamType
_
_
_
->
return
decl
CommentDecl
_
->
return
decl
traverseDeclExprsM
traverseExprM
decl'
pattern
DuplicateTag
::
Type
pattern
DuplicateTag
=
Alias
":duplicate_cast_to_be_removed:"
[]
dropDuplicateCaster
::
ModuleItem
->
ModuleItem
dropDuplicateCaster
(
MIPackageItem
(
Function
_
DuplicateTag
_
_
_
))
=
Generate
[]
dropDuplicateCaster
other
=
other
traverseModuleItemM
::
ModuleItem
->
Scoper
Type
ModuleItem
traverseModuleItemM
(
Genvar
x
)
=
...
...
test/basic/duplicate_cast.sv
0 → 100644
View file @
90de4aa1
package
PKG
;
localparam
P
=
1'b1
;
typedef
struct
packed
{
logic
f
;
}
foo_t
;
endpackage
module
top
;
PKG
::
foo_t
b
;
logic
[
1
:
0
]
a
;
assign
b
=
'
{
default
:
PKG
::
P
};
assign
a
=
'
{
default
:
PKG
::
P
};
initial
#
1
$
display
(
"%b %b"
,
a
,
b
)
;
endmodule
test/basic/duplicate_cast.v
0 → 100644
View file @
90de4aa1
module
top
;
wire
b
;
wire
[
1
:
0
]
a
;
function
automatic
val
;
input
inp
;
val
=
inp
;
endfunction
assign
b
=
val
(
1
)
;
assign
a
=
{
2
{
val
(
1
)
}};
initial
#
1
$
display
(
"%b %b"
,
a
,
b
)
;
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