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
211e4b0e
Commit
211e4b0e
authored
Jul 01, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix literal casts larger than 32 bits
parent
1dfa9a9e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
src/Convert/SizeCast.hs
+2
-2
src/Language/SystemVerilog/AST/Expr.hs
+7
-1
test/basic/cast.sv
+6
-0
test/basic/cast.v
+6
-0
No files found.
src/Convert/SizeCast.hs
View file @
211e4b0e
...
...
@@ -66,8 +66,8 @@ traverseExprM =
where
str
=
(
show
size
)
++
"'d"
++
(
show
num
)
size
=
s'
num
=
if
size
=
=
32
then
n'
num
=
if
size
>
=
32
then
n'
-- already read as 32 bits
else
n'
`
mod
`
(
2
^
s'
)
_
->
convertCastM
(
Number
s
)
(
Number
n
)
convertExprM
(
orig
@
(
Cast
(
Right
DimsFn
{})
_
))
=
...
...
src/Language/SystemVerilog/AST/Expr.hs
View file @
211e4b0e
...
...
@@ -207,7 +207,13 @@ readNumber ('\'' : 'h' : rest) =
case
readHex
rest
of
[(
v
,
_
)]
->
Just
v
_
->
Nothing
readNumber
n
=
readMaybe
n
readNumber
n
=
case
readMaybe
n
of
Nothing
->
Nothing
Just
res
->
if
show
res
==
n
then
Just
res
else
Nothing
showUniOpPrec
::
Expr
->
ShowS
showUniOpPrec
(
e
@
UniOp
{})
=
(
showParen
True
.
shows
)
e
...
...
test/basic/cast.sv
View file @
211e4b0e
...
...
@@ -23,6 +23,12 @@ module top;
$
display
(
"%0d %0d"
,
y
,
($
clog2
(
WIDTH
))
'
(
y
))
;
$
display
(
"%0d %0d"
,
z
,
($
clog2
(
WIDTH
))
'
(
z
))
;
$
display
(
"%b"
,
32
'
(
4
))
;
$
display
(
"%b"
,
33
'
(
4
))
;
$
display
(
"%b"
,
33
'
(
64'hFFFF_FFFF_FFFF_FFFF
))
;
$
display
(
"%b"
,
32
'
(
4294967296
))
;
$
display
(
"%b"
,
33
'
(
4294967296
))
;
$
display
(
"%b"
,
32
'
(
4294967297
))
;
$
display
(
"%b"
,
33
'
(
4294967297
))
;
end
localparam
bit
foo
=
'0
;
...
...
test/basic/cast.v
View file @
211e4b0e
...
...
@@ -26,6 +26,12 @@ module top;
$
display
(
"%0d %0d"
,
y
,
$
signed
(
y
[
4
:
0
]))
;
$
display
(
"%0d %0d"
,
z
,
z
[
4
:
0
])
;
$
display
(
"%b"
,
32'd4
)
;
$
display
(
"%b"
,
33'd4
)
;
$
display
(
"%b"
,
33'h1_FFFF_FFFF
)
;
$
display
(
"%b"
,
32'd0
)
;
$
display
(
"%b"
,
33'd4294967296
)
;
$
display
(
"%b"
,
32'd1
)
;
$
display
(
"%b"
,
33'd4294967297
)
;
end
localparam
[
0
:
0
]
foo
=
0
;
...
...
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