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
11dbf1a4
Commit
11dbf1a4
authored
Jul 09, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dead code in ubased unsized conversion
parent
18358063
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
45 deletions
+18
-45
src/Convert/UnbasedUnsized.hs
+18
-45
No files found.
src/Convert/UnbasedUnsized.hs
View file @
11dbf1a4
...
...
@@ -18,20 +18,19 @@
module
Convert.UnbasedUnsized
(
convert
)
where
import
Control.Monad.Writer.Strict
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
mapMaybe
)
import
qualified
Data.Map.Strict
as
Map
import
Convert.ExprUtils
import
Convert.Traverse
import
Language.SystemVerilog.AST
type
Part
=
([
Identifier
],
[
ModuleItem
])
type
Part
=
[
ModuleItem
]
type
Parts
=
Map
.
Map
Identifier
Part
data
ExprContext
=
SelfDetermined
|
ContextDetermined
Expr
deriving
(
Eq
,
Show
)
convert
::
[
AST
]
->
[
AST
]
convert
files
=
...
...
@@ -41,8 +40,8 @@ convert files =
convertDescription
=
traverseModuleItems
$
convertModuleItem
parts
collectPartsM
::
Description
->
Writer
Parts
()
collectPartsM
(
Part
_
_
_
_
name
ports
items
)
=
tell
$
Map
.
singleton
name
(
ports
,
items
)
collectPartsM
(
Part
_
_
_
_
name
_
items
)
=
tell
$
Map
.
singleton
name
items
collectPartsM
_
=
return
()
convertModuleItem
::
Parts
->
ModuleItem
->
ModuleItem
...
...
@@ -52,8 +51,8 @@ convertModuleItem parts (Instance moduleName params instanceName [] bindings) =
Instance
moduleName
params
instanceName
[]
bindings'
else
Instance
moduleName
params
instanceName
[]
bindings
where
bindings'
=
zipWith
convertBinding
bindings
[
0
..
]
(
portNames
,
moduleItems
)
=
bindings'
=
map
convertBinding
bindings
moduleItems
=
case
Map
.
lookup
moduleName
parts
of
Nothing
->
error
$
"could not find module: "
++
moduleName
Just
partInfo
->
partInfo
...
...
@@ -61,40 +60,30 @@ convertModuleItem parts (Instance moduleName params instanceName [] bindings) =
isTypeParam
(
MIPackageItem
(
Decl
ParamType
{}))
=
True
isTypeParam
_
=
False
tag
=
Ident
"~~uub~~"
convertBinding
::
PortBinding
->
Int
->
PortBinding
convertBinding
(
portName
,
expr
)
idx
=
convertBinding
::
PortBinding
->
PortBinding
convertBinding
(
portName
,
expr
)
=
(
portName
,
)
$
traverseNestedExprs
(
replaceBindingExpr
portName
idx
)
$
traverseNestedExprs
(
replaceBindingExpr
portName
)
$
convertExpr
(
ContextDetermined
tag
)
expr
replaceBindingExpr
::
Identifier
->
Int
->
Expr
->
Expr
replaceBindingExpr
portName
idx
(
orig
@
(
Repeat
_
[
ConvertedUU
a
b
]))
=
replaceBindingExpr
::
Identifier
->
Expr
->
Expr
replaceBindingExpr
portName
(
orig
@
(
Repeat
_
[
ConvertedUU
a
b
]))
=
if
orig
==
sizedLiteralFor
tag
bit
then
Repeat
portSize
[
ConvertedUU
a
b
]
else
orig
where
bit
=
bitForBased
a
b
portName'
=
if
null
portName
then
lookupBindingName
portNames
idx
else
portName
portSize
=
determinePortSize
portName'
params
moduleItems
replaceBindingExpr
_
_
other
=
other
portSize
=
determinePortSize
portName
params
moduleItems
replaceBindingExpr
_
other
=
other
convertModuleItem
_
other
=
convertModuleItem'
other
determinePortSize
::
Identifier
->
[
ParamBinding
]
->
[
ModuleItem
]
->
Expr
determinePortSize
portName
instanceParams
moduleItems
=
step
(
reverse
initialMapping
)
moduleItems
where
moduleParams
=
parameterNames
moduleItems
initialMapping
=
catMaybes
$
zipWith
createParamReplacement
instanceParams
[
0
..
]
createParamReplacement
::
ParamBinding
->
Int
->
Maybe
(
Identifier
,
Expr
)
createParamReplacement
(
""
,
b
)
idx
=
createParamReplacement
(
paramName
,
b
)
idx
where
paramName
=
lookupBindingName
moduleParams
idx
createParamReplacement
(
_
,
Left
_
)
_
=
Nothing
createParamReplacement
(
paramName
,
Right
expr
)
_
=
initialMapping
=
mapMaybe
createParamReplacement
instanceParams
createParamReplacement
::
ParamBinding
->
Maybe
(
Identifier
,
Expr
)
createParamReplacement
(
_
,
Left
_
)
=
Nothing
createParamReplacement
(
paramName
,
Right
expr
)
=
Just
(
paramName
,
tagExpr
expr
)
step
::
[(
Identifier
,
Expr
)]
->
[
ModuleItem
]
->
Expr
...
...
@@ -137,22 +126,6 @@ tagExpr :: Expr -> Expr
tagExpr
(
Ident
x
)
=
Ident
(
':'
:
x
)
tagExpr
expr
=
traverseSinglyNestedExprs
tagExpr
expr
-- given a list of module items, produces the parameter names in order
parameterNames
::
[
ModuleItem
]
->
[
Identifier
]
parameterNames
=
execWriter
.
mapM
(
collectNestedModuleItemsM
$
collectDeclsM
collectDeclM
)
where
collectDeclM
::
Decl
->
Writer
[
Identifier
]
()
collectDeclM
(
Param
Parameter
_
x
_
)
=
tell
[
x
]
collectDeclM
(
ParamType
Parameter
x
_
)
=
tell
[
x
]
collectDeclM
_
=
return
()
lookupBindingName
::
[
Identifier
]
->
Int
->
Identifier
lookupBindingName
names
idx
=
if
idx
<
length
names
then
names
!!
idx
else
error
$
"out of bounds binding "
++
show
(
names
,
idx
)
convertModuleItem'
::
ModuleItem
->
ModuleItem
convertModuleItem'
=
traverseExprs
(
convertExpr
SelfDetermined
)
.
...
...
@@ -251,7 +224,7 @@ convertExpr (ContextDetermined expr) (UU bit) =
convertExpr
_
other
=
other
pattern
UU
::
Bit
->
Expr
pattern
UU
bit
=
Number
(
UnbasedUnsized
bit
)
pattern
UU
bit
<-
Number
(
UnbasedUnsized
bit
)
convertType
::
Type
->
Type
convertType
(
TypeOf
e
)
=
TypeOf
$
convertExpr
SelfDetermined
e
...
...
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