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
5f0ccee0
Commit
5f0ccee0
authored
Feb 17, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversion for unsized integer arrays
parent
20dc92f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
src/Convert/Struct.hs
+13
-0
test/basic/integer_array.sv
+12
-0
test/basic/integer_array.v
+10
-0
No files found.
src/Convert/Struct.hs
View file @
5f0ccee0
...
@@ -271,6 +271,19 @@ convertAsgn structs types (lhs, expr) =
...
@@ -271,6 +271,19 @@ convertAsgn structs types (lhs, expr) =
convertExpr
(
IntegerVector
t
sg
(
r
:
rs
))
(
Pattern
[(
":default"
,
e
)])
=
convertExpr
(
IntegerVector
t
sg
(
r
:
rs
))
(
Pattern
[(
":default"
,
e
)])
=
Repeat
(
rangeSize
r
)
[
e'
]
Repeat
(
rangeSize
r
)
[
e'
]
where
e'
=
convertExpr
(
IntegerVector
t
sg
rs
)
e
where
e'
=
convertExpr
(
IntegerVector
t
sg
rs
)
e
-- TODO: This is a conversion for concat array literals with elements
-- that are unsized numbers. This probably belongs somewhere else.
convertExpr
(
t
@
IntegerVector
{})
(
Concat
exprs
)
=
if
all
isUnsizedNumber
exprs
then
Concat
exprs'
else
Concat
exprs
where
size
=
DimsFn
FnBits
(
Left
$
dropInnerTypeRange
t
)
caster
=
Cast
(
Right
size
)
exprs'
=
map
caster
exprs
isUnsizedNumber
::
Expr
->
Bool
isUnsizedNumber
(
Number
n
)
=
not
$
elem
'
\'
'
n
isUnsizedNumber
_
=
False
convertExpr
(
Struct
packing
fields
(
_
:
rs
))
(
Concat
exprs
)
=
convertExpr
(
Struct
packing
fields
(
_
:
rs
))
(
Concat
exprs
)
=
Concat
$
map
(
convertExpr
(
Struct
packing
fields
rs
))
exprs
Concat
$
map
(
convertExpr
(
Struct
packing
fields
rs
))
exprs
convertExpr
(
Struct
packing
fields
(
_
:
rs
))
(
Bit
e
_
)
=
convertExpr
(
Struct
packing
fields
(
_
:
rs
))
(
Bit
e
_
)
=
...
...
test/basic/integer_array.sv
0 → 100644
View file @
5f0ccee0
module
top
;
localparam
integer
B
[
4
]
=
{
1
,
2
,
3
,
4
};
localparam
byte
C
[
4
]
=
{
1
,
2
,
3
,
4
};
localparam
bit
D
[
4
]
=
{
1
,
2
,
3
,
4
};
initial
begin
`define
PRINT
(
X
)
\
$
display
("%
b
%
2d
%
2d
",
{
X
[
0
],
X
[
1
],
X
[
2
],
X
[
3
]},
$
bits
(
X
),
$
bits
(
X
[
0
]))
;
`PRINT
(
B
)
;
`PRINT
(
C
)
;
`PRINT
(
D
)
;
end
endmodule
test/basic/integer_array.v
0 → 100644
View file @
5f0ccee0
module
top
;
localparam
[
0
:
127
]
B
=
{
32'h1
,
32'h2
,
32'h3
,
32'h4
};
localparam
[
0
:
31
]
C
=
{
8'h1
,
8'h2
,
8'h3
,
8'h4
};
localparam
[
0
:
3
]
D
=
{
1'h1
,
1'h0
,
1'h1
,
1'h0
};
initial
begin
$
display
(
"%b %2d %2d"
,
B
,
$
bits
(
B
)
,
32
)
;
$
display
(
"%b %2d %2d"
,
C
,
$
bits
(
C
)
,
8
)
;
$
display
(
"%b %2d %2d"
,
D
,
$
bits
(
D
)
,
1
)
;
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