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
121fea5a
Commit
121fea5a
authored
Jul 24, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid unnecessary casts on substituted hierarchical constants
parent
46be0edb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
src/Convert/Cast.hs
+1
-1
src/Convert/HierConst.hs
+4
-1
test/core/struct_hier_nocast.sv
+19
-0
test/core/struct_hier_nocast.v
+7
-0
No files found.
src/Convert/Cast.hs
View file @
121fea5a
...
...
@@ -99,7 +99,7 @@ traverseStmtM stmt = do
return
stmt'
traverseExprM
::
Expr
->
SC
Expr
traverseExprM
(
Cast
(
Left
(
IntegerVector
_
sg
rs
))
value
)
=
do
traverseExprM
(
Cast
(
Left
(
IntegerVector
kw
sg
rs
))
value
)
|
kw
/=
TBit
=
do
value'
<-
traverseExprM
value
size'
<-
traverseExprM
size
convertCastM
size'
value'
signed
...
...
src/Convert/HierConst.hs
View file @
121fea5a
...
...
@@ -71,7 +71,10 @@ traverseDeclM decl = do
scopeExpr
e
>>=
insertElem
x
.
Right
Param
Localparam
(
Implicit
sg
rs
)
x
e
->
scopeExpr
(
Cast
(
Left
t
)
e
)
>>=
insertElem
x
.
Right
where
t
=
IntegerVector
TLogic
sg
rs
where
t
=
IntegerVector
TBit
sg
rs
Param
Localparam
(
IntegerVector
_
sg
rs
)
x
e
->
scopeExpr
(
Cast
(
Left
t
)
e
)
>>=
insertElem
x
.
Right
where
t
=
IntegerVector
TBit
sg
rs
Param
Localparam
t
x
e
->
scopeExpr
(
Cast
(
Left
t
)
e
)
>>=
insertElem
x
.
Right
_
->
return
()
...
...
test/core/struct_hier_nocast.sv
0 → 100644
View file @
121fea5a
module
top
;
typedef
struct
packed
{
int
A
;
byte
B
;
shortint
C
;
}
T
;
localparam
T
Q
=
'
{
A
:
1
,
B
:
2
,
C
:
3
};
if
(
1
)
begin
:
blk
localparam
T
P
=
Q
;
logic
[
P
.
A
-
1
:
0
]
a
;
logic
[
P
.
B
-
1
:
0
]
b
;
logic
[
P
.
C
-
1
:
0
]
c
;
end
initial
begin
$
display
(
"%b"
,
$
bits
(
blk
.
a
))
;
$
display
(
"%b"
,
$
bits
(
blk
.
b
))
;
$
display
(
"%b"
,
$
bits
(
blk
.
c
))
;
end
endmodule
test/core/struct_hier_nocast.v
0 → 100644
View file @
121fea5a
module
top
;
initial
begin
$
display
(
"%b"
,
32'd1
)
;
$
display
(
"%b"
,
8'd2
)
;
$
display
(
"%b"
,
16'd3
)
;
end
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