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
c6dbdd09
Commit
c6dbdd09
authored
Mar 22, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preliminary language support for basic classes
parent
c0cac486
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
+30
-6
src/Convert/Package.hs
+2
-0
src/Convert/Traverse.hs
+16
-5
src/Language/SystemVerilog/AST/Description.hs
+7
-0
src/Language/SystemVerilog/Parser/Parse.y
+5
-1
No files found.
src/Convert/Package.hs
View file @
c6dbdd09
...
@@ -93,6 +93,8 @@ traverseDescriptionM (PackageItem item) = do
...
@@ -93,6 +93,8 @@ traverseDescriptionM (PackageItem item) = do
idents
->
Decl
$
CommentDecl
$
"removed "
++
show
idents
idents
->
Decl
$
CommentDecl
$
"removed "
++
show
idents
traverseDescriptionM
(
Package
_
name
_
)
=
traverseDescriptionM
(
Package
_
name
_
)
=
return
$
PackageItem
$
Decl
$
CommentDecl
$
"removed package "
++
show
name
return
$
PackageItem
$
Decl
$
CommentDecl
$
"removed package "
++
show
name
traverseDescriptionM
(
Class
_
name
_
_
)
=
return
$
PackageItem
$
Decl
$
CommentDecl
$
"removed class "
++
show
name
traverseDescriptionM
(
Part
attrs
extern
kw
liftetime
name
ports
items
)
=
do
traverseDescriptionM
(
Part
attrs
extern
kw
liftetime
name
ports
items
)
=
do
(
_
,
items'
)
<-
processItems
name
""
items
(
_
,
items'
)
<-
processItems
name
""
items
return
$
Part
attrs
extern
kw
liftetime
name
ports
items'
return
$
Part
attrs
extern
kw
liftetime
name
ports
items'
...
...
src/Convert/Traverse.hs
View file @
c6dbdd09
...
@@ -151,11 +151,22 @@ traverseModuleItemsM mapper (PackageItem packageItem) = do
...
@@ -151,11 +151,22 @@ traverseModuleItemsM mapper (PackageItem packageItem) = do
return
$
case
item'
of
return
$
case
item'
of
MIPackageItem
packageItem'
->
PackageItem
packageItem'
MIPackageItem
packageItem'
->
PackageItem
packageItem'
other
->
error
$
"encountered bad package module item: "
++
show
other
other
->
error
$
"encountered bad package module item: "
++
show
other
traverseModuleItemsM
mapper
(
Package
lifetime
name
packageItems
)
=
do
traverseModuleItemsM
mapper
(
Package
lifetime
name
items
)
=
do
let
items
=
map
MIPackageItem
packageItems
let
itemsWrapped
=
map
MIPackageItem
items
items'
<-
mapM
(
traverseNestedModuleItemsM
mapper
)
items
itemsWrapped'
<-
mapM
(
traverseNestedModuleItemsM
mapper
)
itemsWrapped
let
items''
=
concatMap
breakGenerate
items'
let
items'
=
map
(
\
(
MIPackageItem
item
)
->
item
)
$
return
$
Package
lifetime
name
$
map
(
\
(
MIPackageItem
item
)
->
item
)
items''
concatMap
breakGenerate
itemsWrapped'
return
$
Package
lifetime
name
items'
traverseModuleItemsM
mapper
(
Class
lifetime
name
decls
items
)
=
do
let
declsWrapped
=
map
(
MIPackageItem
.
Decl
)
decls
declsWrapped'
<-
mapM
(
traverseNestedModuleItemsM
mapper
)
declsWrapped
let
decls'
=
map
(
\
(
MIPackageItem
(
Decl
decl
))
->
decl
)
$
concatMap
breakGenerate
declsWrapped'
let
itemsWrapped
=
map
MIPackageItem
items
itemsWrapped'
<-
mapM
(
traverseNestedModuleItemsM
mapper
)
itemsWrapped
let
items'
=
map
(
\
(
MIPackageItem
item
)
->
item
)
$
concatMap
breakGenerate
itemsWrapped'
return
$
Class
lifetime
name
decls'
items'
traverseModuleItems
::
Mapper
ModuleItem
->
Mapper
Description
traverseModuleItems
::
Mapper
ModuleItem
->
Mapper
Description
traverseModuleItems
=
unmonad
traverseModuleItemsM
traverseModuleItems
=
unmonad
traverseModuleItemsM
...
...
src/Language/SystemVerilog/AST/Description.hs
View file @
c6dbdd09
...
@@ -26,6 +26,7 @@ data Description
...
@@ -26,6 +26,7 @@ data Description
=
Part
[
Attr
]
Bool
PartKW
Lifetime
Identifier
[
Identifier
]
[
ModuleItem
]
=
Part
[
Attr
]
Bool
PartKW
Lifetime
Identifier
[
Identifier
]
[
ModuleItem
]
|
PackageItem
PackageItem
|
PackageItem
PackageItem
|
Package
Lifetime
Identifier
[
PackageItem
]
|
Package
Lifetime
Identifier
[
PackageItem
]
|
Class
Lifetime
Identifier
[
Decl
]
[
PackageItem
]
deriving
Eq
deriving
Eq
instance
Show
Description
where
instance
Show
Description
where
...
@@ -49,6 +50,12 @@ instance Show Description where
...
@@ -49,6 +50,12 @@ instance Show Description where
(
showPad
lifetime
)
name
bodyStr
(
showPad
lifetime
)
name
bodyStr
where
where
bodyStr
=
indent
$
unlines'
$
map
show
items
bodyStr
=
indent
$
unlines'
$
map
show
items
show
(
Class
lifetime
name
decls
items
)
=
printf
"class %s%s;
\n
%s
\n
endclass"
(
showPad
lifetime
)
name
bodyStr
where
bodyStr
=
indent
$
unlines'
$
map
show
items'
items'
=
(
map
Decl
decls
)
++
items
show
(
PackageItem
i
)
=
show
i
show
(
PackageItem
i
)
=
show
i
data
PackageItem
data
PackageItem
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
c6dbdd09
...
@@ -555,6 +555,7 @@ InterfaceKW :: { PartKW }
...
@@ -555,6 +555,7 @@ InterfaceKW :: { PartKW }
PackageDeclaration
::
{
Description
}
PackageDeclaration
::
{
Description
}
:
"package"
Lifetime
Identifier
";"
PackageItems
endpackage
opt
(
Tag
)
{
Package
$
2
$
3
$
5
}
:
"package"
Lifetime
Identifier
";"
PackageItems
endpackage
opt
(
Tag
)
{
Package
$
2
$
3
$
5
}
|
"class"
Lifetime
Identifier
PIParams
";"
PackageItems
endclass
opt
(
Tag
)
{
Class
$
2
$
3
$
4
$
6
}
Tag
::
{
Identifier
}
Tag
::
{
Identifier
}
:
":"
Identifier
{
$
2
}
:
":"
Identifier
{
$
2
}
...
@@ -571,9 +572,11 @@ PackageImportDeclaration :: { [ModuleItem] }
...
@@ -571,9 +572,11 @@ PackageImportDeclaration :: { [ModuleItem] }
:
"import"
PackageImportItems
";"
{
map
(
MIPackageItem
.
uncurry
Import
)
$
2
}
:
"import"
PackageImportItems
";"
{
map
(
MIPackageItem
.
uncurry
Import
)
$
2
}
Params
::
{
[
ModuleItem
]
}
Params
::
{
[
ModuleItem
]
}
:
PIParams
{
map
(
MIPackageItem
.
Decl
)
$
1
}
PIParams
::
{
[
Decl
]
}
:
{- empty -}
{
[]
}
:
{- empty -}
{
[]
}
|
"#"
"("
")"
{
[]
}
|
"#"
"("
")"
{
[]
}
|
"#"
"("
ParamsFollow
{
map
(
MIPackageItem
.
Decl
)
$
3
}
|
"#"
"("
ParamsFollow
{
$
3
}
ParamsFollow
::
{
[
Decl
]
}
ParamsFollow
::
{
[
Decl
]
}
:
ParamAsgn
")"
{
[
$
1
]
}
:
ParamAsgn
")"
{
[
$
1
]
}
|
ParamAsgn
","
ParamsFollow
{
$
1
:
$
3
}
|
ParamAsgn
","
ParamsFollow
{
$
1
:
$
3
}
...
@@ -1380,6 +1383,7 @@ position :: { Position }
...
@@ -1380,6 +1383,7 @@ position :: { Position }
:
{- empty -}
{
%
gets
fst
}
:
{- empty -}
{
%
gets
fst
}
end
:
"end"
{}
|
error
{
%
missingToken
"end"
}
end
:
"end"
{}
|
error
{
%
missingToken
"end"
}
endclass
:
"endclass"
{}
|
error
{
%
missingToken
"endclass"
}
endfunction
:
"endfunction"
{}
|
error
{
%
missingToken
"endfunction"
}
endfunction
:
"endfunction"
{}
|
error
{
%
missingToken
"endfunction"
}
endgenerate
:
"endgenerate"
{}
|
error
{
%
missingToken
"endgenerate"
}
endgenerate
:
"endgenerate"
{}
|
error
{
%
missingToken
"endgenerate"
}
endinterface
:
"endinterface"
{}
|
error
{
%
missingToken
"endinterface"
}
endinterface
:
"endinterface"
{}
|
error
{
%
missingToken
"endinterface"
}
...
...
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