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
db21869e
Commit
db21869e
authored
Jul 12, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix premature conversion of casts containing dimension queries
parent
d46e1f24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
src/Convert/SizeCast.hs
+14
-3
test/basic/package_function_cast.sv
+20
-0
test/basic/package_function_cast.v
+18
-0
No files found.
src/Convert/SizeCast.hs
View file @
db21869e
...
...
@@ -84,8 +84,6 @@ traverseExprM =
sizesMatch
=
numberToInteger
s
==
Just
(
numberBitLength
n
)
fallback
=
convertCastM
(
Number
s
)
(
Number
n
)
num
=
return
.
Number
convertExprM
(
orig
@
(
Cast
(
Right
DimsFn
{})
_
))
=
return
orig
convertExprM
(
Cast
(
Right
(
Ident
x
))
e
)
=
do
typeMap
<-
get
-- can't convert this cast yet because x could be a typename
...
...
@@ -93,7 +91,9 @@ traverseExprM =
then
return
$
Cast
(
Right
$
Ident
x
)
e
else
convertCastM
(
Ident
x
)
e
convertExprM
(
Cast
(
Right
s
)
e
)
=
convertCastM
s
e
if
isSimpleExpr
s
then
convertCastM
s
e
else
return
$
Cast
(
Right
s
)
e
convertExprM
(
Cast
(
Left
(
IntegerVector
_
Signed
rs
))
e
)
=
convertCastWithSigningM
(
dimensionsSize
rs
)
e
Signed
convertExprM
(
Cast
(
Left
(
IntegerVector
_
_
rs
))
e
)
=
...
...
@@ -121,6 +121,17 @@ traverseExprM =
let
args
=
Args
[
e
]
[]
return
$
Call
(
Ident
f
)
args
isSimpleExpr
::
Expr
->
Bool
isSimpleExpr
=
null
.
execWriter
.
collectNestedExprsM
collectUnresolvedExprM
where
collectUnresolvedExprM
::
Expr
->
Writer
[
Expr
]
()
collectUnresolvedExprM
(
expr
@
PSIdent
{})
=
tell
[
expr
]
collectUnresolvedExprM
(
expr
@
CSIdent
{})
=
tell
[
expr
]
collectUnresolvedExprM
(
expr
@
DimsFn
{})
=
tell
[
expr
]
collectUnresolvedExprM
(
expr
@
DimFn
{})
=
tell
[
expr
]
collectUnresolvedExprM
_
=
return
()
castFn
::
Expr
->
Signing
->
Description
castFn
e
sg
=
PackageItem
$
...
...
test/basic/package_function_cast.sv
0 → 100644
View file @
db21869e
package
P
;
function
automatic
logic
[
7
:
0
]
f
(
input
logic
[
2
:
0
]
p
)
;
logic
[
7
:
0
]
r
;
r
=
'0
;
r
[
p
+:
2
]
=
'1
;
return
r
;
endfunction
endpackage
module
top
;
logic
[
2
:
0
]
p
;
logic
[
7
:
0
]
q
;
assign
q
=
P
::
f
(
p
)
;
initial
begin
$
monitor
(
"%0d, p=%b q=%b"
,
$
time
,
p
,
q
)
;
#
1
p
=
0
;
while
(
p
!=
7
)
#
1
p
=
p
+
1
;
end
endmodule
test/basic/package_function_cast.v
0 → 100644
View file @
db21869e
module
top
;
function
automatic
[
7
:
0
]
f
;
input
[
2
:
0
]
p
;
begin
f
=
7'b0
;
f
[
p
+:
2
]
=
2'b11
;
end
endfunction
reg
[
2
:
0
]
p
;
wire
[
7
:
0
]
q
;
assign
q
=
f
(
p
)
;
initial
begin
$
monitor
(
"%0d, p=%b q=%b"
,
$
time
,
p
,
q
)
;
#
1
p
=
0
;
while
(
p
!=
7
)
#
1
p
=
p
+
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