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
c936b39b
Commit
c936b39b
authored
Oct 20, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use system functions for signedness casts
parent
06411d70
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
0 deletions
+48
-0
src/Convert.hs
+2
-0
src/Convert/SignCast.hs
+29
-0
sv2v.cabal
+1
-0
test/basic/sign_cast.sv
+8
-0
test/basic/sign_cast.v
+8
-0
No files found.
src/Convert.hs
View file @
c936b39b
...
@@ -31,6 +31,7 @@ import qualified Convert.NestPI
...
@@ -31,6 +31,7 @@ import qualified Convert.NestPI
import
qualified
Convert.Package
import
qualified
Convert.Package
import
qualified
Convert.ParamType
import
qualified
Convert.ParamType
import
qualified
Convert.RemoveComments
import
qualified
Convert.RemoveComments
import
qualified
Convert.SignCast
import
qualified
Convert.Simplify
import
qualified
Convert.Simplify
import
qualified
Convert.SizeCast
import
qualified
Convert.SizeCast
import
qualified
Convert.StarPort
import
qualified
Convert.StarPort
...
@@ -72,6 +73,7 @@ phases excludes =
...
@@ -72,6 +73,7 @@ phases excludes =
,
Convert
.
Unique
.
convert
,
Convert
.
Unique
.
convert
,
Convert
.
UnpackedArray
.
convert
,
Convert
.
UnpackedArray
.
convert
,
Convert
.
Unsigned
.
convert
,
Convert
.
Unsigned
.
convert
,
Convert
.
SignCast
.
convert
,
Convert
.
Package
.
convert
,
Convert
.
Package
.
convert
,
Convert
.
Enum
.
convert
,
Convert
.
Enum
.
convert
,
Convert
.
NestPI
.
convert
,
Convert
.
NestPI
.
convert
...
...
src/Convert/SignCast.hs
0 → 100644
View file @
c936b39b
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
- Conversion for `signed` and `unsigned` type casts.
-
- SystemVerilog has `signed'(foo)` and `unsigned'(foo)` as syntactic sugar for
- the `$signed` and `$unsigned` system functions present in Verilog-2005. This
- conversion elaborates these casts.
-}
module
Convert.SignCast
(
convert
)
where
import
Convert.Traverse
import
Language.SystemVerilog.AST
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
$
traverseModuleItems
$
traverseExprs
$
traverseNestedExprs
convertExpr
convertExpr
::
Expr
->
Expr
convertExpr
(
Cast
(
Left
(
Implicit
Signed
[]
))
e
)
=
Call
(
Ident
"$signed"
)
(
Args
[
Just
e
]
[]
)
convertExpr
(
Cast
(
Left
(
Implicit
Unsigned
[]
))
e
)
=
Call
(
Ident
"$unsigned"
)
(
Args
[
Just
e
]
[]
)
convertExpr
other
=
other
sv2v.cabal
View file @
c936b39b
...
@@ -77,6 +77,7 @@ executable sv2v
...
@@ -77,6 +77,7 @@ executable sv2v
Convert.Package
Convert.Package
Convert.ParamType
Convert.ParamType
Convert.RemoveComments
Convert.RemoveComments
Convert.SignCast
Convert.Simplify
Convert.Simplify
Convert.SizeCast
Convert.SizeCast
Convert.StarPort
Convert.StarPort
...
...
test/basic/sign_cast.sv
0 → 100644
View file @
c936b39b
module
top
;
initial
begin
$
display
(
signed
'
(
4294967295
))
;
$
display
(
unsigned
'
(
4294967295
))
;
$
display
(
signed
'
(
-
1
))
;
$
display
(
unsigned
'
(
-
1
))
;
end
endmodule
test/basic/sign_cast.v
0 → 100644
View file @
c936b39b
module
top
;
initial
begin
$
display
($
signed
(
4294967295
))
;
$
display
($
unsigned
(
4294967295
))
;
$
display
($
signed
(
-
1
))
;
$
display
($
unsigned
(
-
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