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
fc3e79dd
Commit
fc3e79dd
authored
Apr 24, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic conversion for int, byte, shortint, and longint
parent
50d00f9d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
3 deletions
+43
-3
src/Convert.hs
+2
-0
src/Convert/IntTypes.hs
+35
-0
src/Convert/Logic.hs
+5
-3
sv2v.cabal
+1
-0
No files found.
src/Convert.hs
View file @
fc3e79dd
...
...
@@ -16,6 +16,7 @@ import qualified Convert.Bits
import
qualified
Convert.Enum
import
qualified
Convert.FuncRet
import
qualified
Convert.Interface
import
qualified
Convert.IntTypes
import
qualified
Convert.KWArgs
import
qualified
Convert.Logic
import
qualified
Convert.NamedBlock
...
...
@@ -41,6 +42,7 @@ phases excludes =
,
selectExclude
(
Job
.
Logic
,
Convert
.
Logic
.
convert
)
,
Convert
.
FuncRet
.
convert
,
Convert
.
Enum
.
convert
,
Convert
.
IntTypes
.
convert
,
Convert
.
KWArgs
.
convert
,
Convert
.
PackedArray
.
convert
,
Convert
.
StarPort
.
convert
...
...
src/Convert/IntTypes.hs
0 → 100644
View file @
fc3e79dd
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
- Conversion for `int`, `shortint`, `longint`, and `byte`
-}
module
Convert.IntTypes
(
convert
)
where
import
Convert.Traverse
import
Language.SystemVerilog.AST
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
$
traverseModuleItems
$
traverseTypes
convertType
convertType
::
Type
->
Type
convertType
(
IntegerAtom
TInt
sg
)
=
baseType
sg
Signed
32
convertType
(
IntegerAtom
TShortint
sg
)
=
baseType
sg
Signed
16
convertType
(
IntegerAtom
TLongint
sg
)
=
baseType
sg
Signed
64
convertType
(
IntegerAtom
TByte
sg
)
=
baseType
sg
Unspecified
8
convertType
other
=
other
-- makes a integer "compatible" type with the given signing, base signing and
-- size; if not unspecified, the first signing overrides the second
baseType
::
Signing
->
Signing
->
Int
->
Type
baseType
sgOverride
sgBase
size
=
IntegerVector
TReg
sg
[(
Number
hi
,
Number
"0"
)]
where
hi
=
show
(
size
-
1
)
sg
=
if
sgOverride
/=
Unspecified
then
sgOverride
else
sgBase
src/Convert/Logic.hs
View file @
fc3e79dd
...
...
@@ -7,6 +7,8 @@
- initial block. Other module-level logics become wires. All other logics
- (i.e., in a function) become regs.
-
- Parameters and localparams with integer vector types become implicit.
-
- The struct conversion and Verilog-2005's lack of permissive net vs. variable
- resolution leads to some interesting special cases for this conversion, as
- parts of a struct may be used as a variable, while other parts may be used as
...
...
@@ -110,7 +112,7 @@ convertDescription ports orig =
++
portName
++
" of "
++
instanceName
fixBinding
other
=
(
other
,
[]
)
-- rewrite variable declarations to have the correct type
convertModuleItem
(
MIPackageItem
(
Decl
(
Variable
dir
(
IntegerVector
TLogic
sg
mr
)
ident
a
me
)))
=
convertModuleItem
(
MIPackageItem
(
Decl
(
Variable
dir
(
IntegerVector
_
sg
mr
)
ident
a
me
)))
=
MIPackageItem
$
Decl
$
Variable
dir
(
t
mr
)
ident
a
me
where
t
=
if
sg
/=
Unspecified
||
Set
.
member
ident
idents
...
...
@@ -119,9 +121,9 @@ convertDescription ports orig =
convertModuleItem
other
=
other
-- all other logics (i.e. inside of functions) become regs
convertDecl
::
Decl
->
Decl
convertDecl
(
Parameter
(
IntegerVector
TLogic
sg
rs
)
x
e
)
=
convertDecl
(
Parameter
(
IntegerVector
_
sg
rs
)
x
e
)
=
Parameter
(
Implicit
sg
rs
)
x
e
convertDecl
(
Localparam
(
IntegerVector
TLogic
sg
rs
)
x
e
)
=
convertDecl
(
Localparam
(
IntegerVector
_
sg
rs
)
x
e
)
=
Localparam
(
Implicit
sg
rs
)
x
e
convertDecl
(
Variable
d
(
IntegerVector
TLogic
sg
rs
)
x
a
me
)
=
Variable
d
(
IntegerVector
TReg
sg
rs
)
x
a
me
...
...
sv2v.cabal
View file @
fc3e79dd
...
...
@@ -60,6 +60,7 @@ executable sv2v
Convert.Enum
Convert.FuncRet
Convert.Interface
Convert.IntTypes
Convert.KWArgs
Convert.Logic
Convert.NamedBlock
...
...
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