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
7eed2fc5
Commit
7eed2fc5
authored
Jul 20, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix handling of multi-dimensional integer array literals (resolves #113)
parent
e6e62e88
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
src/Convert/Struct.hs
+13
-6
test/basic/integer_array.sv
+7
-0
test/basic/integer_array.v
+7
-0
No files found.
src/Convert/Struct.hs
View file @
7eed2fc5
...
...
@@ -199,20 +199,27 @@ convertExpr (IntegerVector t sg (r:rs)) (Pattern [(":default", e)]) =
-- TODO: This is a conversion for concat array literals with elements
-- that are unsized numbers. This probably belongs somewhere else.
convertExpr
(
t
@
IntegerVector
{})
(
Pattern
items
)
=
if
all
(
null
.
fst
)
item
s
then
convertExpr
t
$
Concat
$
map
snd
items
if
all
null
name
s
then
convertExpr
t
$
Concat
exprs'
else
Pattern
items
where
(
names
,
exprs
)
=
unzip
items
t'
=
dropInnerTypeRange
t
exprs'
=
map
(
convertExpr
t'
)
exprs
convertExpr
(
t
@
IntegerVector
{})
(
Concat
exprs
)
=
if
all
isUnsizedNumber
exprs
then
Concat
exprs'
else
Concat
exprs
then
Concat
$
map
(
Cast
$
Left
t'
)
exprs
else
Concat
$
map
(
convertExpr
t'
)
exprs
where
caster
=
Cast
(
Left
$
dropInnerTypeRange
t
)
exprs'
=
map
caster
exprs
t'
=
dropInnerTypeRange
t
isUnsizedNumber
::
Expr
->
Bool
isUnsizedNumber
(
Number
n
)
=
not
$
numberIsSized
n
isUnsizedNumber
(
UniOp
UniSub
e
)
=
isUnsizedNumber
e
isUnsizedNumber
_
=
False
convertExpr
(
Implicit
sg
rs
)
expr
=
if
null
rs
then
expr
else
convertExpr
(
IntegerVector
TBit
sg
rs
)
expr
convertExpr
(
Struct
packing
fields
(
_
:
rs
))
(
Concat
exprs
)
=
Concat
$
map
(
convertExpr
(
Struct
packing
fields
rs
))
exprs
convertExpr
(
Struct
packing
fields
(
_
:
rs
))
(
Bit
e
_
)
=
...
...
test/basic/integer_array.sv
View file @
7eed2fc5
...
...
@@ -21,4 +21,11 @@ module top;
`PRINT
(
H
)
;
`PRINT
(
I
)
;
end
localparam
[
1
:
0
][
0
:
1
]
P
=
'
{
'
{
default
:
'd1
},
'
{
default
:
'd2
}};
localparam
bit
[
1
:
0
][
0
:
1
]
Q
=
'
{
'
{
default
:
'd2
},
'
{
default
:
'd1
}};
initial
begin
$
display
(
"%b %b %b"
,
P
,
P
[
0
]
,
P
[
1
])
;
$
display
(
"%b %b %b"
,
Q
,
Q
[
0
]
,
Q
[
1
])
;
end
endmodule
test/basic/integer_array.v
View file @
7eed2fc5
...
...
@@ -19,4 +19,11 @@ module top;
$
display
(
"%b %2d %2d"
,
H
,
$
bits
(
H
)
,
8
)
;
$
display
(
"%b %2d %2d"
,
I
,
$
bits
(
I
)
,
1
)
;
end
localparam
[
3
:
0
]
P
=
4'b1100
;
localparam
[
3
:
0
]
Q
=
4'b0011
;
initial
begin
$
display
(
"%b %b %b"
,
P
,
P
[
1
:
0
]
,
P
[
3
:
2
])
;
$
display
(
"%b %b %b"
,
Q
,
Q
[
1
:
0
]
,
Q
[
3
:
2
])
;
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