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
ab867465
Commit
ab867465
authored
Jul 21, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix handling of explicitly typed struct patterns in other contexts
parent
dde734be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
10 deletions
+49
-10
src/Convert/Struct.hs
+10
-8
test/core/struct_pattern_cast.sv
+21
-1
test/core/struct_pattern_cast.v
+18
-1
No files found.
src/Convert/Struct.hs
View file @
ab867465
...
...
@@ -152,9 +152,7 @@ traverseStmtM' =
traverseStmtAsgnsM
traverseAsgnM
traverseExprM
::
Expr
->
Scoper
Type
Expr
traverseExprM
=
(
embedScopes
convertSubExpr
>=>
return
.
snd
)
.
(
traverseNestedExprs
$
traverseExprTypes
convertType
)
traverseExprM
=
embedScopes
convertSubExpr
>=>
return
.
snd
traverseLHSM
::
LHS
->
Scoper
Type
LHS
traverseLHSM
=
convertLHS
>=>
return
.
snd
...
...
@@ -292,10 +290,12 @@ convertExpr (struct @ (Struct _ fields [])) (Pattern itemsOrig) =
Just
value
=
numberToInteger
n
Right
(
Number
n
)
=
item
convertExpr
_
(
Cast
(
Left
t
)
expr
@
Pattern
{})
=
Cast
(
Left
t
)
$
convertExpr
t
expr
convertExpr
_
(
Cast
(
Left
t
)
expr
)
=
Cast
(
Left
t'
)
$
convertExpr
t
expr
where
t'
=
convertType
t
convertExpr
(
Implicit
_
[]
)
expr
=
expr
convertExpr
(
Implicit
_
[]
)
expr
=
traverseSinglyNestedExprs
(
convertExpr
UnknownType
)
expr
convertExpr
(
Implicit
sg
rs
)
expr
=
convertExpr
(
IntegerVector
TBit
sg
rs
)
expr
...
...
@@ -343,7 +343,8 @@ convertExpr t (Concat exprs) =
t'
=
dropInnerTypeRange
t
exprs'
=
map
(
convertExpr
t'
)
exprs
convertExpr
_
other
=
other
convertExpr
_
expr
=
traverseSinglyNestedExprs
(
convertExpr
UnknownType
)
expr
fallbackType
::
Scopes
Type
->
Expr
->
(
Type
,
Expr
)
fallbackType
scopes
e
=
...
...
@@ -484,7 +485,8 @@ convertSubExpr scopes e =
traverseSinglyNestedExprs
exprMapper
e
where
exprMapper
=
snd
.
convertSubExpr
scopes
typeMapper
=
traverseNestedTypes
$
traverseTypeExprs
exprMapper
typeMapper
=
convertType
.
traverseNestedTypes
(
traverseTypeExprs
exprMapper
)
-- get the fields and type function of a struct or union
getFields
::
Type
->
Maybe
[
Field
]
...
...
test/core/struct_pattern_cast.sv
View file @
ab867465
...
...
@@ -8,5 +8,25 @@ module top;
shortint
y
;
S
z
;
}
T
;
initial
$
display
(
"%b"
,
T
'
{
x
:
1
,
y
:
2
,
z
:
'
{
x
:
3
,
y
:
4
}
}
)
;
var
T
a
;
initial
a
=
T
'
{
x
:
5
,
y
:
6
,
z
:
'
{
x
:
7
,
y
:
8
}
};
var
T
b
;
T
c
;
assign
c
=
T
'
{
x
:
9
,
y
:
10
,
z
:
'
{
x
:
11
,
y
:
12
}
};
initial
begin
b
=
T
'
{
x
:
13
,
y
:
14
,
z
:
'
{
x
:
15
,
y
:
16
}
};
#
1
;
$
display
(
"a %b"
,
a
)
;
$
display
(
"b %b"
,
b
)
;
$
display
(
"c %b"
,
c
)
;
$
display
(
"x %b"
,
T
'
{
x
:
1
,
y
:
2
,
z
:
'
{
x
:
3
,
y
:
4
}
}
)
;
$
display
(
"$bits(S) = %0d"
,
$
bits
(
S
))
;
$
display
(
"$bits(T) = %0d"
,
$
bits
(
T
))
;
$
display
(
"$bits(a) = %0d"
,
$
bits
(
a
))
;
$
display
(
"$bits(a.x) = %0d"
,
$
bits
(
a
.
x
))
;
$
display
(
"$bits(a.y) = %0d"
,
$
bits
(
a
.
y
))
;
$
display
(
"$bits(a.z) = %0d"
,
$
bits
(
a
.
z
))
;
$
display
(
"$bits(a.z.x) = %0d"
,
$
bits
(
a
.
z
.
x
))
;
$
display
(
"$bits(a.z.y) = %0d"
,
$
bits
(
a
.
z
.
y
))
;
end
endmodule
test/core/struct_pattern_cast.v
View file @
ab867465
module
top
;
initial
$
display
(
"%b"
,
{
8'd1
,
16'd2
,
32'd3
,
8'd4
}
)
;
reg
[
63
:
0
]
a
=
{
8'd5
,
16'd6
,
32'd7
,
8'd8
};
reg
[
63
:
0
]
b
=
{
8'd13
,
16'd14
,
32'd15
,
8'd16
};
wire
[
63
:
0
]
c
=
{
8'd9
,
16'd10
,
32'd11
,
8'd12
};
initial
begin
#
1
;
$
display
(
"a %b"
,
a
)
;
$
display
(
"b %b"
,
b
)
;
$
display
(
"c %b"
,
c
)
;
$
display
(
"x %b"
,
{
8'd1
,
16'd2
,
32'd3
,
8'd4
}
)
;
$
display
(
"$bits(S) = %0d"
,
40
)
;
$
display
(
"$bits(T) = %0d"
,
64
)
;
$
display
(
"$bits(a) = %0d"
,
64
)
;
$
display
(
"$bits(a.x) = %0d"
,
8
)
;
$
display
(
"$bits(a.y) = %0d"
,
16
)
;
$
display
(
"$bits(a.z) = %0d"
,
40
)
;
$
display
(
"$bits(a.z.x) = %0d"
,
32
)
;
$
display
(
"$bits(a.z.y) = %0d"
,
8
)
;
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