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
e52de9d4
Commit
e52de9d4
authored
May 31, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove legacy ordered binding handling in param type conversion
parent
69bc64ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
17 deletions
+8
-17
src/Convert/ParamType.hs
+8
-17
No files found.
src/Convert/ParamType.hs
View file @
e52de9d4
...
@@ -17,7 +17,7 @@ import Convert.Traverse
...
@@ -17,7 +17,7 @@ import Convert.Traverse
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
type
MaybeTypeMap
=
Map
.
Map
Identifier
(
Maybe
Type
)
type
MaybeTypeMap
=
Map
.
Map
Identifier
(
Maybe
Type
)
type
Info
=
Map
.
Map
Identifier
([
Identifier
],
MaybeTypeMap
)
type
Info
=
Map
.
Map
Identifier
MaybeTypeMap
type
Instance
=
Map
.
Map
Identifier
(
Type
,
IdentSet
)
type
Instance
=
Map
.
Map
Identifier
(
Type
,
IdentSet
)
type
Instances
=
Set
.
Set
(
Identifier
,
Instance
)
type
Instances
=
Set
.
Set
(
Identifier
,
Instance
)
...
@@ -75,7 +75,7 @@ convert files =
...
@@ -75,7 +75,7 @@ convert files =
collectModuleItemM
(
Instance
m
bindings
_
_
_
)
=
do
collectModuleItemM
(
Instance
m
bindings
_
_
_
)
=
do
case
Map
.
lookup
m
info
of
case
Map
.
lookup
m
info
of
Nothing
->
tell
(
Set
.
singleton
m
,
Set
.
empty
)
Nothing
->
tell
(
Set
.
singleton
m
,
Set
.
empty
)
Just
(
_
,
maybeTypeMap
)
->
Just
maybeTypeMap
->
if
any
(
flip
Map
.
member
maybeTypeMap
)
$
map
fst
bindings
if
any
(
flip
Map
.
member
maybeTypeMap
)
$
map
fst
bindings
then
tell
(
Set
.
empty
,
Set
.
singleton
m
)
then
tell
(
Set
.
empty
,
Set
.
singleton
m
)
else
tell
(
Set
.
singleton
m
,
Set
.
empty
)
else
tell
(
Set
.
singleton
m
,
Set
.
empty
)
...
@@ -97,7 +97,7 @@ convert files =
...
@@ -97,7 +97,7 @@ convert files =
then
[]
then
[]
else
[
rewriteModule
part
$
fromJust
typeMap
]
else
[
rewriteModule
part
$
fromJust
typeMap
]
where
where
maybeTypeMap
=
snd
$
info
Map
.!
name
maybeTypeMap
=
info
Map
.!
name
typeMap
=
defaultInstance
maybeTypeMap
typeMap
=
defaultInstance
maybeTypeMap
existingNames
=
map
moduleName
existing
existingNames
=
map
moduleName
existing
alreadyExists
=
(
flip
elem
existingNames
)
.
moduleName
alreadyExists
=
(
flip
elem
existingNames
)
.
moduleName
...
@@ -203,11 +203,10 @@ convert files =
...
@@ -203,11 +203,10 @@ convert files =
-- write down module parameter names and type parameters
-- write down module parameter names and type parameters
collectDescriptionM
::
Description
->
Writer
Info
()
collectDescriptionM
::
Description
->
Writer
Info
()
collectDescriptionM
(
part
@
(
Part
_
_
_
_
name
_
_
))
=
collectDescriptionM
(
part
@
(
Part
_
_
_
_
name
_
_
))
=
tell
$
Map
.
singleton
name
(
paramNames
,
maybeTypeMap
)
tell
$
Map
.
singleton
name
maybeTypeMap
where
where
params
=
execWriter
$
params
=
execWriter
$
collectModuleItemsM
(
collectDeclsM
collectDeclM
)
part
collectModuleItemsM
(
collectDeclsM
collectDeclM
)
part
paramNames
=
map
fst
params
maybeTypeMap
=
Map
.
fromList
$
maybeTypeMap
=
Map
.
fromList
$
map
(
\
(
x
,
y
)
->
(
x
,
fromJust
y
))
$
map
(
\
(
x
,
y
)
->
(
x
,
fromJust
y
))
$
filter
(
isJust
.
snd
)
params
filter
(
isJust
.
snd
)
params
...
@@ -306,7 +305,7 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
...
@@ -306,7 +305,7 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
let
defaults
=
Map
.
map
(
Left
.
fst
)
resolvedTypes
let
defaults
=
Map
.
map
(
Left
.
fst
)
resolvedTypes
let
bindingsDefaulted
=
Map
.
toList
$
Map
.
union
bindingsMap
defaults
let
bindingsDefaulted
=
Map
.
toList
$
Map
.
union
bindingsMap
defaults
if
isDefaultName
m
||
bindingsDefaulted
==
Map
.
toList
bindingsMap
if
isDefaultName
m
||
bindingsDefaulted
==
Map
.
toList
bindingsMap
then
return
$
Instance
m
bindings
Named
x
r
p
then
return
$
Instance
m
bindings
x
r
p
else
return
$
Instance
(
moduleDefaultName
m
)
bindingsDefaulted
x
r
p
else
return
$
Instance
(
moduleDefaultName
m
)
bindingsDefaulted
x
r
p
else
do
else
do
tell
$
Set
.
singleton
(
m
,
resolvedTypes
)
tell
$
Set
.
singleton
(
m
,
resolvedTypes
)
...
@@ -315,17 +314,9 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
...
@@ -315,17 +314,9 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
map
(
MIPackageItem
.
Decl
)
addedDecls
++
map
(
MIPackageItem
.
Decl
)
addedDecls
++
[
Instance
m'
(
additionalBindings
++
bindings'
)
x
r
p
]
[
Instance
m'
(
additionalBindings
++
bindings'
)
x
r
p
]
where
where
(
paramNames
,
maybeTypeMap
)
=
info
Map
.!
m
maybeTypeMap
=
info
Map
.!
m
-- attach names to unnamed parameters
bindingsNamed
=
if
all
(
==
""
)
(
map
fst
bindings
)
then
zip
paramNames
(
map
snd
bindings
)
else
if
any
(
==
""
)
(
map
fst
bindings
)
then
error
$
"instance has a mix of named and unnamed params: "
++
show
orig
else
bindings
-- determine the types corresponding to each type parameter
-- determine the types corresponding to each type parameter
bindingsMap
=
Map
.
fromList
bindings
Named
bindingsMap
=
Map
.
fromList
bindings
resolvedTypesWithDecls
=
Map
.
mapWithKey
resolveType
maybeTypeMap
resolvedTypesWithDecls
=
Map
.
mapWithKey
resolveType
maybeTypeMap
resolvedTypes
=
Map
.
map
(
\
(
a
,
(
b
,
_
))
->
(
a
,
b
))
resolvedTypesWithDecls
resolvedTypes
=
Map
.
map
(
\
(
a
,
(
b
,
_
))
->
(
a
,
b
))
resolvedTypesWithDecls
addedDecls
=
concatMap
(
snd
.
snd
.
snd
)
$
addedDecls
=
concatMap
(
snd
.
snd
.
snd
)
$
...
@@ -340,7 +331,7 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
...
@@ -340,7 +331,7 @@ convertModuleItemM info (orig @ (Instance m bindings x r p)) =
-- leave only the normal expression params behind
-- leave only the normal expression params behind
isParamType
=
flip
Map
.
member
maybeTypeMap
isParamType
=
flip
Map
.
member
maybeTypeMap
bindings'
=
filter
(
not
.
isParamType
.
fst
)
bindings
Named
bindings'
=
filter
(
not
.
isParamType
.
fst
)
bindings
-- create additional parameters needed to specify existing type params
-- create additional parameters needed to specify existing type params
additionalBindings
=
concatMap
makeAddedParams
$
additionalBindings
=
concatMap
makeAddedParams
$
...
...
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