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
54ea7d55
Commit
54ea7d55
authored
Jul 16, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify automatic procedural block naming
parent
57ef23ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
31 deletions
+13
-31
src/Convert/NamedBlock.hs
+13
-31
No files found.
src/Convert/NamedBlock.hs
View file @
54ea7d55
...
...
@@ -11,47 +11,29 @@
module
Convert.NamedBlock
(
convert
)
where
import
Control.Monad.State.Strict
import
qualified
Data.Set
as
Set
import
Convert.Traverse
import
Language.SystemVerilog.AST
type
Idents
=
Set
.
Set
Identifier
convert
::
[
AST
]
->
[
AST
]
convert
asts
=
-- we collect all the existing blocks in the first pass to make sure we
-- don't generate conflicting names on repeated passes of this conversion
evalState
(
runner
collectStmtM
asts
>>=
runner
traverseStmtM
)
Set
.
empty
where
runner
=
mapM
.
traverseDescriptionsM
.
traverseModuleItemsM
.
traverseStmtsM
.
traverseNestedStmtsM
convert
=
map
$
traverseDescriptions
convertDescription
co
llectStmtM
::
Stmt
->
State
Idents
Stmt
co
llectStmtM
(
Block
kw
x
decls
stmts
)
=
do
modify
$
Set
.
insert
x
return
$
Block
kw
x
decls
stmts
collectStmtM
other
=
return
other
co
nvertDescription
::
Description
->
Description
co
nvertDescription
description
=
evalState
(
traverseModuleItemsM
traverseModuleItem
description
)
1
where
traverseModuleItem
=
traverseStmtsM
$
traverseNestedStmtsM
traverseStmtM
traverseStmtM
::
Stmt
->
State
I
dents
Stmt
traverseStmtM
::
Stmt
->
State
I
nt
Stmt
traverseStmtM
(
Block
kw
""
[]
stmts
)
=
return
$
Block
kw
""
[]
stmts
traverseStmtM
(
Block
kw
""
decls
stmts
)
=
do
names
<-
get
let
x
=
uniqueBlockName
names
modify
$
Set
.
insert
x
x
<-
uniqueBlockName
return
$
Block
kw
x
decls
stmts
traverseStmtM
other
=
return
other
uniqueBlockName
::
Idents
->
Identifier
uniqueBlockName
names
=
step
(
"sv2v_autoblock_"
++
(
show
$
Set
.
size
names
))
0
where
step
::
Identifier
->
Int
->
Identifier
step
base
n
=
if
Set
.
member
name
names
then
step
base
(
n
+
1
)
else
name
where
name
=
if
n
==
0
then
base
else
base
++
"_"
++
show
n
uniqueBlockName
::
State
Int
String
uniqueBlockName
=
do
cnt
<-
get
put
$
cnt
+
1
return
$
"sv2v_autoblock_"
++
show
cnt
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