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
24071d74
Commit
24071d74
authored
Jun 24, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paramtype conversion resolves dimension queries before substitution
parent
2d134a86
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
7 deletions
+57
-7
src/Convert/ParamType.hs
+21
-7
test/basic/paramtype_bits.sv
+16
-0
test/basic/paramtype_bits.v
+20
-0
No files found.
src/Convert/ParamType.hs
View file @
24071d74
...
...
@@ -219,13 +219,27 @@ exprToType _ = Nothing
-- TODO: If a type parameter contains an expression, that expression should be
-- substituted into the new module, or created as a new parameter.
isSimpleType
::
Type
->
Bool
isSimpleType
(
IntegerVector
_
_
_
)
=
True
isSimpleType
(
IntegerAtom
_
_
)
=
True
isSimpleType
(
NonInteger
_
)
=
True
isSimpleType
(
Net
_
_
_
)
=
True
isSimpleType
(
Struct
_
fields
_
)
=
all
(
isSimpleType
.
fst
)
fields
isSimpleType
(
Union
_
fields
_
)
=
all
(
isSimpleType
.
fst
)
fields
isSimpleType
_
=
False
isSimpleType
typ
=
(
not
$
typeHasQueries
typ
)
&&
case
typ
of
IntegerVector
{}
->
True
IntegerAtom
{}
->
True
NonInteger
{}
->
True
Net
{}
->
True
Struct
_
fields
_
->
all
(
isSimpleType
.
fst
)
fields
Union
_
fields
_
->
all
(
isSimpleType
.
fst
)
fields
_
->
False
-- returns whether a type contains any dimension queries
typeHasQueries
::
Type
->
Bool
typeHasQueries
=
not
.
null
.
execWriter
.
collectTypeExprsM
(
collectNestedExprsM
collectUnresolvedExprM
)
where
collectUnresolvedExprM
::
Expr
->
Writer
[
Expr
]
()
collectUnresolvedExprM
(
expr
@
DimsFn
{})
=
tell
[
expr
]
collectUnresolvedExprM
(
expr
@
DimFn
{})
=
tell
[
expr
]
collectUnresolvedExprM
_
=
return
()
-- attempt to rewrite instantiations with type parameters
convertModuleItemM
::
Info
->
ModuleItem
->
Writer
Instances
ModuleItem
...
...
test/basic/paramtype_bits.sv
0 → 100644
View file @
24071d74
module
Module
(
out
)
;
parameter
type
T
=
logic
;
output
T
out
;
assign
out
=
'1
;
endmodule
module
top
;
logic
w
;
logic
[$
bits
(
w
)
-
1
:
0
]
b
;
logic
o0
,
o1
;
logic
[
1
:
0
]
o2
;
Module
m0
(
o0
)
;
Module
#(
logic
[$
bits
(
w
)
-
1
:
0
])
m1
(
o1
)
;
Module
#(
logic
[$
bits
(
b
)
*
2
-
1
:
0
])
m2
(
o2
)
;
endmodule
test/basic/paramtype_bits.v
0 → 100644
View file @
24071d74
module
Module_Size1
(
out
)
;
output
wire
out
;
assign
out
=
1'b1
;
endmodule
module
Module_Size2
(
out
)
;
output
wire
[
1
:
0
]
out
;
assign
out
=
2'b11
;
endmodule
module
top
;
wire
w
;
wire
[
0
:
0
]
b
;
wire
o0
,
o1
;
wire
[
1
:
0
]
o2
;
Module_Size1
m0
(
o0
)
;
Module_Size1
m1
(
o1
)
;
Module_Size2
m2
(
o2
)
;
endmodule
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