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 @@
...
@@ -11,47 +11,29 @@
module
Convert.NamedBlock
(
convert
)
where
module
Convert.NamedBlock
(
convert
)
where
import
Control.Monad.State.Strict
import
Control.Monad.State.Strict
import
qualified
Data.Set
as
Set
import
Convert.Traverse
import
Convert.Traverse
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
type
Idents
=
Set
.
Set
Identifier
convert
::
[
AST
]
->
[
AST
]
convert
::
[
AST
]
->
[
AST
]
convert
asts
=
convert
=
map
$
traverseDescriptions
convertDescription
-- 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
co
llectStmtM
::
Stmt
->
State
Idents
Stmt
co
nvertDescription
::
Description
->
Description
co
llectStmtM
(
Block
kw
x
decls
stmts
)
=
do
co
nvertDescription
description
=
modify
$
Set
.
insert
x
evalState
(
traverseModuleItemsM
traverseModuleItem
description
)
1
return
$
Block
kw
x
decls
stmts
where
collectStmtM
other
=
return
other
traverseModuleItem
=
traverseStmtsM
$
traverseNestedStmtsM
traverseStmtM
traverseStmtM
::
Stmt
->
State
I
dents
Stmt
traverseStmtM
::
Stmt
->
State
I
nt
Stmt
traverseStmtM
(
Block
kw
""
[]
stmts
)
=
traverseStmtM
(
Block
kw
""
[]
stmts
)
=
return
$
Block
kw
""
[]
stmts
return
$
Block
kw
""
[]
stmts
traverseStmtM
(
Block
kw
""
decls
stmts
)
=
do
traverseStmtM
(
Block
kw
""
decls
stmts
)
=
do
names
<-
get
x
<-
uniqueBlockName
let
x
=
uniqueBlockName
names
modify
$
Set
.
insert
x
return
$
Block
kw
x
decls
stmts
return
$
Block
kw
x
decls
stmts
traverseStmtM
other
=
return
other
traverseStmtM
other
=
return
other
uniqueBlockName
::
Idents
->
Identifier
uniqueBlockName
::
State
Int
String
uniqueBlockName
names
=
uniqueBlockName
=
do
step
(
"sv2v_autoblock_"
++
(
show
$
Set
.
size
names
))
0
cnt
<-
get
where
put
$
cnt
+
1
step
::
Identifier
->
Int
->
Identifier
return
$
"sv2v_autoblock_"
++
show
cnt
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
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