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
2d003c6d
Commit
2d003c6d
authored
Apr 24, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversion for package-scoped tasks, functions, and typenames
parent
bc23aebc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
12 deletions
+54
-12
README.md
+3
-3
src/Convert.hs
+1
-1
src/Convert/Package.hs
+22
-8
test/basic/package.sv
+16
-0
test/basic/package.v
+12
-0
No files found.
README.md
View file @
2d003c6d
...
...
@@ -81,9 +81,9 @@ Common flags:
## Supported Features
sv2v supports most synthesizable SystemVerilog features. Current notable
exceptions include
`
package`
/
`import`
/
`export`
, interfaces _with parameter
bindings_, and complex (non-identifier)
`modport`
expressions. Assertions
are
also supported, but are
simply dropped during conversion.
exceptions include
`
export`
, interfaces _with parameter bindings_, and complex
(non-identifier)
`modport`
expressions. Assertions are also supported, but
are
simply dropped during conversion.
If you find a bug or have a feature request, please create an issue. Preference
will be given to issues which include examples or test cases.
...
...
src/Convert.hs
View file @
2d003c6d
...
...
@@ -46,12 +46,12 @@ phases excludes =
,
Convert
.
StarPort
.
convert
,
Convert
.
StmtBlock
.
convert
,
Convert
.
Struct
.
convert
,
Convert
.
Return
.
convert
,
Convert
.
Typedef
.
convert
,
Convert
.
UnbasedUnsized
.
convert
,
Convert
.
Unique
.
convert
,
Convert
.
Package
.
convert
,
Convert
.
NestPI
.
convert
,
Convert
.
Return
.
convert
,
selectExclude
(
Job
.
Interface
,
Convert
.
Interface
.
convert
)
,
selectExclude
(
Job
.
Always
,
Convert
.
AlwaysKW
.
convert
)
]
...
...
src/Convert/Package.hs
View file @
2d003c6d
...
...
@@ -2,10 +2,6 @@
- Author: Zachary Snow <zach@zachjs.com>
-
- Conversion for packages and imports
-
- TODO FIXME: This package conversion does not yet handle package-scoped
- identifiers for task/function names or type names, as the AST and parser
- doesn't support them yet. This won't be too difficult.
-}
module
Convert.Package
(
convert
)
where
...
...
@@ -64,8 +60,11 @@ prefixPackageItem packageName idents item =
other
->
other
convertExpr
(
Ident
x
)
=
Ident
$
prefix
x
convertExpr
other
=
other
convertLHS
(
LHSIdent
x
)
=
LHSIdent
$
prefix
x
convertLHS
other
=
other
converter
=
(
traverseExprs
$
traverseNestedExprs
convertExpr
)
(
traverseExprs
$
traverseNestedExprs
convertExpr
)
.
(
traverseLHSs
$
traverseNestedLHSs
convertLHS
)
MIPackageItem
item''
=
converter
$
MIPackageItem
item'
collectDescriptionM
::
Description
->
Writer
Packages
()
...
...
@@ -102,11 +101,26 @@ traverseModuleItem packages (MIPackageItem (Import x y)) =
items
=
map
snd
$
filter
(
filterer
.
fst
)
$
Map
.
toList
packageItems
traverseModuleItem
_
item
=
(
traverseExprs
$
traverseNestedExprs
traverseExpr
)
$
(
traverseStmts
traverseStmt
)
$
(
traverseTypes
traverseType
)
$
item
where
traverseExpr
::
Expr
->
Expr
traverseExpr
(
PSIdent
x
y
)
=
Ident
$
x
++
"_"
++
y
traverseExpr
(
Call
(
Just
ps
)
f
args
)
=
Call
Nothing
(
ps
++
"_"
++
f
)
args
traverseExpr
other
=
other
traverseStmt
::
Stmt
->
Stmt
traverseStmt
(
Subroutine
(
Just
ps
)
f
args
)
=
Subroutine
Nothing
(
ps
++
"_"
++
f
)
args
traverseStmt
other
=
other
traverseExpr
::
Expr
->
Expr
traverseExpr
(
PSIdent
x
y
)
=
Ident
$
x
++
"_"
++
y
traverseExpr
other
=
other
traverseType
::
Type
->
Type
traverseType
(
Alias
(
Just
ps
)
xx
rs
)
=
Alias
Nothing
(
ps
++
"_"
++
xx
)
rs
traverseType
other
=
other
-- returns the "name" of a package item, if it has one
piName
::
PackageItem
->
Maybe
Identifier
...
...
test/basic/package.sv
View file @
2d003c6d
...
...
@@ -6,6 +6,18 @@ package B;
localparam
FOO
=
-
37
;
localparam
BAR
=
-
97
;
endpackage
package
C
;
typedef
logic
[
3
:
0
]
pack_t
;
endpackage
package
D
;
function
C
::
pack_t
pack
;
input
logic
x
;
pack
=
{
$
bits
(
C
::
pack_t
)
{
x
}};
endfunction
endpackage
package
E
;
import
D
::*;
endpackage
module
top
;
import
A
::
FOO
;
import
B
::
BAR
;
...
...
@@ -16,5 +28,9 @@ module top;
$
display
(
B
::
BAR
)
;
$
display
(
FOO
)
;
$
display
(
BAR
)
;
$
display
(
"%d"
,
D
::
pack
(
0
))
;
$
display
(
"%d"
,
D
::
pack
(
1
))
;
$
display
(
"%d"
,
E
::
pack
(
0
))
;
$
display
(
"%d"
,
E
::
pack
(
1
))
;
end
endmodule
test/basic/package.v
View file @
2d003c6d
...
...
@@ -5,6 +5,14 @@ module top;
localparam
B_BAR
=
-
97
;
localparam
FOO
=
37
;
localparam
BAR
=
-
97
;
function
[
3
:
0
]
D_pack
;
input
reg
x
;
D_pack
=
{
4
{
x
}};
endfunction
function
[
3
:
0
]
E_pack
;
input
reg
x
;
E_pack
=
{
4
{
x
}};
endfunction
initial
begin
$
display
(
A_FOO
)
;
$
display
(
A_BAR
)
;
...
...
@@ -12,5 +20,9 @@ module top;
$
display
(
B_BAR
)
;
$
display
(
FOO
)
;
$
display
(
BAR
)
;
$
display
(
"%d"
,
D_pack
(
0
))
;
$
display
(
"%d"
,
D_pack
(
1
))
;
$
display
(
"%d"
,
E_pack
(
0
))
;
$
display
(
"%d"
,
E_pack
(
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