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
82217ec0
Commit
82217ec0
authored
Dec 22, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated lifetime representation; struct packers use automatic
parent
7ea5b60d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
27 deletions
+28
-27
src/Convert/SizeCast.hs
+1
-1
src/Convert/Struct.hs
+1
-1
src/Convert/Traverse.hs
+6
-6
src/Language/SystemVerilog/AST/Description.hs
+11
-13
src/Language/SystemVerilog/Parser/Parse.y
+9
-6
No files found.
src/Convert/SizeCast.hs
View file @
82217ec0
...
@@ -73,7 +73,7 @@ traverseExprM =
...
@@ -73,7 +73,7 @@ traverseExprM =
castFn
::
Expr
->
Signing
->
Description
castFn
::
Expr
->
Signing
->
Description
castFn
e
sg
=
castFn
e
sg
=
PackageItem
$
PackageItem
$
Function
(
Just
Automatic
)
t
fnName
[
decl
]
[
Return
$
Ident
inp
]
Function
Automatic
t
fnName
[
decl
]
[
Return
$
Ident
inp
]
where
where
inp
=
"inp"
inp
=
"inp"
r
=
(
simplify
$
BinOp
Sub
e
(
Number
"1"
),
Number
"0"
)
r
=
(
simplify
$
BinOp
Sub
e
(
Number
"1"
),
Number
"0"
)
...
...
src/Convert/Struct.hs
View file @
82217ec0
...
@@ -211,7 +211,7 @@ traverseDeclM structs origDecl = do
...
@@ -211,7 +211,7 @@ traverseDeclM structs origDecl = do
packerFn
::
TypeFunc
->
ModuleItem
packerFn
::
TypeFunc
->
ModuleItem
packerFn
structTf
=
packerFn
structTf
=
MIPackageItem
$
MIPackageItem
$
Function
Nothing
(
structTf
[]
)
fnName
decls
[
retStmt
]
Function
Automatic
(
structTf
[]
)
fnName
decls
[
retStmt
]
where
where
Struct
_
fields
[]
=
structTf
[]
Struct
_
fields
[]
=
structTf
[]
toInput
(
t
,
x
)
=
Variable
Input
t
x
[]
Nothing
toInput
(
t
,
x
)
=
Variable
Input
t
x
[]
Nothing
...
...
src/Convert/Traverse.hs
View file @
82217ec0
...
@@ -153,9 +153,9 @@ traverseModuleItemsM mapper (Part attrs extern kw lifetime name ports items) = d
...
@@ -153,9 +153,9 @@ traverseModuleItemsM mapper (Part attrs extern kw lifetime name ports items) = d
traverseModuleItemsM
mapper
(
PackageItem
packageItem
)
=
do
traverseModuleItemsM
mapper
(
PackageItem
packageItem
)
=
do
let
item
=
MIPackageItem
packageItem
let
item
=
MIPackageItem
packageItem
converted
<-
converted
<-
traverseModuleItemsM
mapper
(
Part
[]
False
Module
Nothing
"DNE"
[]
[
item
])
traverseModuleItemsM
mapper
(
Part
[]
False
Module
Inherit
"DNE"
[]
[
item
])
let
item'
=
case
converted
of
let
item'
=
case
converted
of
Part
[]
False
Module
Nothing
"DNE"
[]
[
newItem
]
->
newItem
Part
[]
False
Module
Inherit
"DNE"
[]
[
newItem
]
->
newItem
_
->
error
$
"redirected PackageItem traverse failed: "
_
->
error
$
"redirected PackageItem traverse failed: "
++
show
converted
++
show
converted
return
$
case
item'
of
return
$
case
item'
of
...
@@ -164,9 +164,9 @@ traverseModuleItemsM mapper (PackageItem packageItem) = do
...
@@ -164,9 +164,9 @@ traverseModuleItemsM mapper (PackageItem packageItem) = do
traverseModuleItemsM
mapper
(
Package
lifetime
name
packageItems
)
=
do
traverseModuleItemsM
mapper
(
Package
lifetime
name
packageItems
)
=
do
let
items
=
map
MIPackageItem
packageItems
let
items
=
map
MIPackageItem
packageItems
converted
<-
converted
<-
traverseModuleItemsM
mapper
(
Part
[]
False
Module
Nothing
"DNE"
[]
items
)
traverseModuleItemsM
mapper
(
Part
[]
False
Module
Inherit
"DNE"
[]
items
)
let
items'
=
case
converted
of
let
items'
=
case
converted
of
Part
[]
False
Module
Nothing
"DNE"
[]
newItems
->
newItems
Part
[]
False
Module
Inherit
"DNE"
[]
newItems
->
newItems
_
->
error
$
"redirected Package traverse failed: "
_
->
error
$
"redirected Package traverse failed: "
++
show
converted
++
show
converted
return
$
Package
lifetime
name
$
map
(
\
(
MIPackageItem
item
)
->
item
)
items'
return
$
Package
lifetime
name
$
map
(
\
(
MIPackageItem
item
)
->
item
)
items'
...
@@ -1017,9 +1017,9 @@ collectStmtAsgnsM = collectify traverseStmtAsgnsM
...
@@ -1017,9 +1017,9 @@ collectStmtAsgnsM = collectify traverseStmtAsgnsM
traverseNestedModuleItemsM
::
Monad
m
=>
MapperM
m
ModuleItem
->
MapperM
m
ModuleItem
traverseNestedModuleItemsM
::
Monad
m
=>
MapperM
m
ModuleItem
->
MapperM
m
ModuleItem
traverseNestedModuleItemsM
mapper
item
=
do
traverseNestedModuleItemsM
mapper
item
=
do
converted
<-
converted
<-
traverseModuleItemsM
mapper
(
Part
[]
False
Module
Nothing
"DNE"
[]
[
item
])
traverseModuleItemsM
mapper
(
Part
[]
False
Module
Inherit
"DNE"
[]
[
item
])
let
items'
=
case
converted
of
let
items'
=
case
converted
of
Part
[]
False
Module
Nothing
"DNE"
[]
newItems
->
newItems
Part
[]
False
Module
Inherit
"DNE"
[]
newItems
->
newItems
_
->
error
$
"redirected NestedModuleItems traverse failed: "
_
->
error
$
"redirected NestedModuleItems traverse failed: "
++
show
converted
++
show
converted
return
$
case
items'
of
return
$
case
items'
of
...
...
src/Language/SystemVerilog/AST/Description.hs
View file @
82217ec0
...
@@ -25,9 +25,9 @@ import Language.SystemVerilog.AST.Type (Type, Identifier)
...
@@ -25,9 +25,9 @@ import Language.SystemVerilog.AST.Type (Type, Identifier)
import
{-#
SOURCE
#-
}
Language
.
SystemVerilog
.
AST
.
ModuleItem
(
ModuleItem
)
import
{-#
SOURCE
#-
}
Language
.
SystemVerilog
.
AST
.
ModuleItem
(
ModuleItem
)
data
Description
data
Description
=
Part
[
Attr
]
Bool
PartKW
(
Maybe
Lifetime
)
Identifier
[
Identifier
]
[
ModuleItem
]
=
Part
[
Attr
]
Bool
PartKW
Lifetime
Identifier
[
Identifier
]
[
ModuleItem
]
|
PackageItem
PackageItem
|
PackageItem
PackageItem
|
Package
(
Maybe
Lifetime
)
Identifier
[
PackageItem
]
|
Package
Lifetime
Identifier
[
PackageItem
]
deriving
Eq
deriving
Eq
instance
Show
Description
where
instance
Show
Description
where
...
@@ -35,12 +35,12 @@ instance Show Description where
...
@@ -35,12 +35,12 @@ instance Show Description where
show
(
Part
attrs
True
kw
lifetime
name
_
items
)
=
show
(
Part
attrs
True
kw
lifetime
name
_
items
)
=
printf
"%sextern %s %s%s %s;"
printf
"%sextern %s %s%s %s;"
(
concatMap
showPad
attrs
)
(
concatMap
showPad
attrs
)
(
show
kw
)
(
show
Lifetime
lifetime
)
name
(
indentedParenList
itemStrs
)
(
show
kw
)
(
show
Pad
lifetime
)
name
(
indentedParenList
itemStrs
)
where
itemStrs
=
map
(
init
.
show
)
items
where
itemStrs
=
map
(
init
.
show
)
items
show
(
Part
attrs
False
kw
lifetime
name
ports
items
)
=
show
(
Part
attrs
False
kw
lifetime
name
ports
items
)
=
printf
"%s%s %s%s%s;
\n
%s
\n
end%s"
printf
"%s%s %s%s%s;
\n
%s
\n
end%s"
(
concatMap
showPad
attrs
)
(
concatMap
showPad
attrs
)
(
show
kw
)
(
show
Lifetime
lifetime
)
name
portsStr
bodyStr
(
show
kw
)
(
show
kw
)
(
show
Pad
lifetime
)
name
portsStr
bodyStr
(
show
kw
)
where
where
portsStr
=
if
null
ports
portsStr
=
if
null
ports
then
""
then
""
...
@@ -48,15 +48,15 @@ instance Show Description where
...
@@ -48,15 +48,15 @@ instance Show Description where
bodyStr
=
indent
$
unlines'
$
map
show
items
bodyStr
=
indent
$
unlines'
$
map
show
items
show
(
Package
lifetime
name
items
)
=
show
(
Package
lifetime
name
items
)
=
printf
"package %s%s;
\n
%s
\n
endpackage"
printf
"package %s%s;
\n
%s
\n
endpackage"
(
show
Lifetime
lifetime
)
name
bodyStr
(
show
Pad
lifetime
)
name
bodyStr
where
where
bodyStr
=
indent
$
unlines'
$
map
show
items
bodyStr
=
indent
$
unlines'
$
map
show
items
show
(
PackageItem
i
)
=
show
i
show
(
PackageItem
i
)
=
show
i
data
PackageItem
data
PackageItem
=
Typedef
Type
Identifier
=
Typedef
Type
Identifier
|
Function
(
Maybe
Lifetime
)
Type
Identifier
[
Decl
]
[
Stmt
]
|
Function
Lifetime
Type
Identifier
[
Decl
]
[
Stmt
]
|
Task
(
Maybe
Lifetime
)
Identifier
[
Decl
]
[
Stmt
]
|
Task
Lifetime
Identifier
[
Decl
]
[
Stmt
]
|
Import
Identifier
(
Maybe
Identifier
)
|
Import
Identifier
(
Maybe
Identifier
)
|
Export
(
Maybe
(
Identifier
,
Maybe
Identifier
))
|
Export
(
Maybe
(
Identifier
,
Maybe
Identifier
))
|
Decl
Decl
|
Decl
Decl
...
@@ -68,11 +68,11 @@ instance Show PackageItem where
...
@@ -68,11 +68,11 @@ instance Show PackageItem where
show
(
Typedef
t
x
)
=
printf
"typedef %s %s;"
(
show
t
)
x
show
(
Typedef
t
x
)
=
printf
"typedef %s %s;"
(
show
t
)
x
show
(
Function
ml
t
x
i
b
)
=
show
(
Function
ml
t
x
i
b
)
=
printf
"function %s%s%s;
\n
%s
\n
%s
\n
endfunction"
printf
"function %s%s%s;
\n
%s
\n
%s
\n
endfunction"
(
show
Lifetime
ml
)
(
showPad
t
)
x
(
indent
$
show
i
)
(
show
Pad
ml
)
(
showPad
t
)
x
(
indent
$
show
i
)
(
indent
$
unlines'
$
map
show
b
)
(
indent
$
unlines'
$
map
show
b
)
show
(
Task
ml
x
i
b
)
=
show
(
Task
ml
x
i
b
)
=
printf
"task %s%s;
\n
%s
\n
%s
\n
endtask"
printf
"task %s%s;
\n
%s
\n
%s
\n
endtask"
(
show
Lifetime
ml
)
x
(
indent
$
show
i
)
(
show
Pad
ml
)
x
(
indent
$
show
i
)
(
indent
$
unlines'
$
map
show
b
)
(
indent
$
unlines'
$
map
show
b
)
show
(
Import
x
y
)
=
printf
"import %s::%s;"
x
(
fromMaybe
"*"
y
)
show
(
Import
x
y
)
=
printf
"import %s::%s;"
x
(
fromMaybe
"*"
y
)
show
(
Export
Nothing
)
=
"export *::*"
;
show
(
Export
Nothing
)
=
"export *::*"
;
...
@@ -96,12 +96,10 @@ instance Show PartKW where
...
@@ -96,12 +96,10 @@ instance Show PartKW where
data
Lifetime
data
Lifetime
=
Static
=
Static
|
Automatic
|
Automatic
|
Inherit
deriving
(
Eq
,
Ord
)
deriving
(
Eq
,
Ord
)
instance
Show
Lifetime
where
instance
Show
Lifetime
where
show
Static
=
"static"
show
Static
=
"static"
show
Automatic
=
"automatic"
show
Automatic
=
"automatic"
show
Inherit
=
""
showLifetime
::
Maybe
Lifetime
->
String
showLifetime
Nothing
=
""
showLifetime
(
Just
l
)
=
show
l
++
" "
src/Language/SystemVerilog/Parser/Parse.y
View file @
82217ec0
...
@@ -513,7 +513,7 @@ Part(begin, end) :: { Description }
...
@@ -513,7 +513,7 @@ Part(begin, end) :: { Description }
| AttributeInstances "extern" begin PartHeader { $4 $1 True $3 [] }
| AttributeInstances "extern" begin PartHeader { $4 $1 True $3 [] }
PartHeader :: { [Attr] -> Bool -> PartKW -> [ModuleItem] -> Description }
PartHeader :: { [Attr] -> Bool -> PartKW -> [ModuleItem] -> Description }
:
opt(Lifetime)
Identifier PackageImportDeclarations Params PortDecls ";" { \attrs extern kw items -> Part attrs extern kw $1 $2 (fst $5) ($3 ++ $4 ++ (snd $5) ++ items) }
:
Lifetime
Identifier PackageImportDeclarations Params PortDecls ";" { \attrs extern kw items -> Part attrs extern kw $1 $2 (fst $5) ($3 ++ $4 ++ (snd $5) ++ items) }
ModuleKW :: { PartKW }
ModuleKW :: { PartKW }
: "module" { Module }
: "module" { Module }
...
@@ -521,7 +521,7 @@ InterfaceKW :: { PartKW }
...
@@ -521,7 +521,7 @@ InterfaceKW :: { PartKW }
: "interface" { Interface }
: "interface" { Interface }
PackageDeclaration :: { Description }
PackageDeclaration :: { Description }
: "package"
opt(Lifetime)
Identifier ";" PackageItems "endpackage" opt(Tag) { Package $2 $3 $5 }
: "package"
Lifetime
Identifier ";" PackageItems "endpackage" opt(Tag) { Package $2 $3 $5 }
Tag :: { Identifier }
Tag :: { Identifier }
: ":" Identifier { $2 }
: ":" Identifier { $2 }
...
@@ -613,7 +613,7 @@ DeclOrStmtToken :: { DeclToken }
...
@@ -613,7 +613,7 @@ DeclOrStmtToken :: { DeclToken }
| "." Identifier { DTDot $2 }
| "." Identifier { DTDot $2 }
| PortBindings { DTInstance $1 }
| PortBindings { DTInstance $1 }
| Signing { DTSigning $1 }
| Signing { DTSigning $1 }
|
Lifetime
{ DTLifetime $1 }
|
ExplicitLifetime
{ DTLifetime $1 }
| Identifier "::" Identifier { DTPSIdent $1 $3 }
| Identifier "::" Identifier { DTPSIdent $1 $3 }
| "const" PartialType { DTType $2 }
| "const" PartialType { DTType $2 }
| "{" StreamOp StreamSize Concat "}" { DTStream $2 $3 (map toLHS $4) }
| "{" StreamOp StreamSize Concat "}" { DTStream $2 $3 (map toLHS $4) }
...
@@ -775,9 +775,9 @@ PackageItem :: { [PackageItem] }
...
@@ -775,9 +775,9 @@ PackageItem :: { [PackageItem] }
| NonDeclPackageItem { $1 }
| NonDeclPackageItem { $1 }
NonDeclPackageItem :: { [PackageItem] }
NonDeclPackageItem :: { [PackageItem] }
: "typedef" Type Identifier ";" { [Typedef $2 $3] }
: "typedef" Type Identifier ";" { [Typedef $2 $3] }
| "function"
opt(Lifetime)
FuncRetAndName TFItems DeclsAndStmts "endfunction" opt(Tag) { [Function $2 (fst $3) (snd $3) (map defaultFuncInput $ (map makeInput $4) ++ fst $5) (snd $5)] }
| "function"
Lifetime
FuncRetAndName TFItems DeclsAndStmts "endfunction" opt(Tag) { [Function $2 (fst $3) (snd $3) (map defaultFuncInput $ (map makeInput $4) ++ fst $5) (snd $5)] }
| "function"
opt(Lifetime)
"void" Identifier TFItems DeclsAndStmts "endfunction" opt(Tag) { [Task $2 $4 (map defaultFuncInput $ $5 ++ fst $6) (snd $6)] }
| "function"
Lifetime
"void" Identifier TFItems DeclsAndStmts "endfunction" opt(Tag) { [Task $2 $4 (map defaultFuncInput $ $5 ++ fst $6) (snd $6)] }
| "task"
opt(Lifetime)
Identifier TFItems DeclsAndStmts "endtask" opt(Tag) { [Task $2 $3 (map defaultFuncInput $ $4 ++ fst $5) (snd $5)] }
| "task"
Lifetime
Identifier TFItems DeclsAndStmts "endtask" opt(Tag) { [Task $2 $3 (map defaultFuncInput $ $4 ++ fst $5) (snd $5)] }
| "import" PackageImportItems ";" { map (uncurry Import) $2 }
| "import" PackageImportItems ";" { map (uncurry Import) $2 }
| "export" PackageImportItems ";" { map (Export . Just) $2 }
| "export" PackageImportItems ";" { map (Export . Just) $2 }
| "export" "*" "::" "*" ";" { [Export Nothing] } -- "Nothing" being no restrictions
| "export" "*" "::" "*" ";" { [Export Nothing] } -- "Nothing" being no restrictions
...
@@ -818,6 +818,9 @@ AlwaysKW :: { AlwaysKW }
...
@@ -818,6 +818,9 @@ AlwaysKW :: { AlwaysKW }
| "always_latch" { AlwaysLatch }
| "always_latch" { AlwaysLatch }
Lifetime :: { Lifetime }
Lifetime :: { Lifetime }
: {- empty -} { Inherit }
| ExplicitLifetime { $1 }
ExplicitLifetime :: { Lifetime }
: "static" { Static }
: "static" { Static }
| "automatic" { Automatic }
| "automatic" { Automatic }
...
...
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