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
11bb0537
Commit
11bb0537
authored
Aug 16, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify duplicate genvar conversion
parent
99df3264
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
35 deletions
+8
-35
src/Convert/DuplicateGenvar.hs
+8
-35
No files found.
src/Convert/DuplicateGenvar.hs
View file @
11bb0537
...
@@ -6,47 +6,20 @@
...
@@ -6,47 +6,20 @@
module
Convert.DuplicateGenvar
(
convert
)
where
module
Convert.DuplicateGenvar
(
convert
)
where
import
Control.Monad.State.Strict
import
Convert.Scoper
import
qualified
Data.Set
as
Set
import
Convert.Traverse
import
Convert.Traverse
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
type
IdentSet
=
Set
.
Set
Identifier
convert
::
[
AST
]
->
[
AST
]
convert
::
[
AST
]
->
[
AST
]
convert
=
map
$
traverseDescriptions
traverseDescription
convert
=
map
$
traverseDescriptions
traverseDescription
traverseDescription
::
Description
->
Description
traverseDescription
::
Description
->
Description
traverseDescription
(
part
@
Part
{})
=
traverseDescription
=
partScoper
return
traverseModuleItemM
return
return
Part
attrs
extern
kw
lifetime
name
ports
items'
where
Part
attrs
extern
kw
lifetime
name
ports
items
=
part
-- intentionally only looks at top level module items
items'
=
evalState
(
mapM
traverseModuleItemM
items
)
Set
.
empty
traverseDescription
other
=
other
traverseModuleItemM
::
ModuleItem
->
S
tate
IdentSet
ModuleItem
traverseModuleItemM
::
ModuleItem
->
S
coper
()
ModuleItem
traverseModuleItemM
(
Genvar
x
)
=
do
traverseModuleItemM
(
Genvar
x
)
=
do
alreadyExists
<-
gets
$
Set
.
member
x
details
<-
lookupElemM
x
if
alreadyExists
if
details
==
Nothing
then
return
$
Generate
[]
then
insertElem
x
()
>>
return
(
Genvar
x
)
else
do
else
return
$
Generate
[]
modify
$
Set
.
insert
x
traverseModuleItemM
item
=
return
item
return
$
Genvar
x
traverseModuleItemM
(
Generate
items
)
=
do
s
<-
get
items'
<-
traverseItems
items
s'
<-
get
items''
<-
traverseItems
items'
let
genvarDecls
=
map
(
GenModuleItem
.
Genvar
)
$
Set
.
toList
$
Set
.
difference
s'
s
return
$
Generate
(
genvarDecls
++
items''
)
where
traverseItems
=
mapM
$
traverseNestedGenItemsM
traverseGenItemM
traverseModuleItemM
other
=
return
other
traverseGenItemM
::
GenItem
->
State
IdentSet
GenItem
traverseGenItemM
(
GenModuleItem
item
)
=
do
item'
<-
traverseModuleItemM
item
return
$
GenModuleItem
item'
traverseGenItemM
other
=
return
other
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