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