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
5ad48494
Commit
5ad48494
authored
Mar 22, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix slicing direction for multi-packed arrays
parent
35e75c06
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
23 deletions
+41
-23
src/Convert/MultiplePacked.hs
+22
-10
test/basic/multipack_port.sv
+8
-5
test/basic/multipack_port.v
+11
-8
No files found.
src/Convert/MultiplePacked.hs
View file @
5ad48494
...
...
@@ -166,8 +166,9 @@ traverseExpr typeMap =
fieldType
=
fieldMap
Map
.!
x
levels
_
=
Nothing
-- given an expression, returns the two innermost packed dimensions and a
-- tagged version of the expression, if possible
-- given an expression, returns the two most significant (innermost,
-- leftmost) packed dimensions and a tagged version of the expression,
-- if possible
dims
::
Expr
->
Maybe
(
Range
,
Range
,
Expr
)
dims
expr
=
case
levels
expr
of
...
...
@@ -266,18 +267,29 @@ traverseExpr typeMap =
range'
=
(
base
,
len
)
rewriteExpr
(
orig
@
(
Range
expr
mode
range
))
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
Range
expr'
mode
range'
then
Range
expr'
mode
'
range'
else
orig
where
maybeDims
=
dims
expr
Just
(
_
,
dimOuter
,
expr'
)
=
maybeDims
Just
(
dimInner
,
dimOuter
,
expr'
)
=
maybeDims
sizeOuter
=
rangeSize
dimOuter
base
=
BinOp
Add
(
BinOp
Mul
sizeOuter
(
fst
range
))
start
len
=
BinOp
Mul
sizeOuter
(
snd
range
)
range'
=
(
base
,
len
)
start
=
offsetOuter
=
uncurry
(
endianCondExpr
dimOuter
)
$
swap
dimOuter
(
baseOrig
,
lenOrig
)
=
range
lenOrigMinusOne
=
BinOp
Sub
lenOrig
(
Number
"1"
)
baseSwapped
=
orientIdx
dimInner
$
case
mode
of
IndexedPlus
->
endianCondExpr
dimOuter
(
snd
dimOuter
)
(
fst
dimOuter
)
IndexedMinus
->
endianCondExpr
dimOuter
(
fst
dimOuter
)
(
snd
dimOuter
)
IndexedPlus
->
endianCondExpr
dimInner
baseOrig
(
BinOp
Add
baseOrig
lenOrigMinusOne
)
IndexedMinus
->
endianCondExpr
dimInner
(
BinOp
Sub
baseOrig
lenOrigMinusOne
)
baseOrig
NonIndexed
->
error
"invariant violated"
base
=
BinOp
Add
offsetOuter
(
BinOp
Mul
sizeOuter
baseSwapped
)
mode'
=
IndexedPlus
len
=
BinOp
Mul
sizeOuter
lenOrig
range'
=
(
base
,
len
)
rewriteExpr
other
=
other
test/basic/multipack_port.sv
View file @
5ad48494
module
Producer
(
clock
,
data
)
;
parameter
INIT
=
0
;
parameter
CHUNKS
=
5
;
input
logic
clock
;
output
logic
[
10
:
0
]
data
[
5
]
;
initial
data
[
0
]
[
0
]
=
INIT
;
output
logic
[
10
:
0
]
data
[
CHUNKS
]
;
initial
data
[
0
]
=
INIT
;
always
@
(
clock
)
begin
integer
i
,
j
;
for
(
i
=
4
;
i
>=
0
;
i
--
)
begin
for
(
i
=
CHUNKS
-
1
;
i
>=
0
;
i
--
)
begin
for
(
j
=
9
;
j
>=
0
;
j
--
)
begin
data
[
i
][
j
+
1
]
=
data
[
i
][
j
]
;
end
...
...
@@ -28,8 +29,10 @@ module top;
Producer
#(
.
INIT
(
0
))
p1
(
clock
,
foo
)
;
logic
[
10
:
0
]
bar
[
10
]
;
Producer
#(
.
INIT
(
0
))
p2
(
clock
,
bar
[
0
:
4
])
;
Producer
#(
.
INIT
(
1
))
p3
(
clock
,
bar
[
5
:
9
])
;
Producer
#(
.
INIT
(
0
)
,
.
CHUNKS
(
3
))
p2
(
clock
,
bar
[
0
:
2
])
;
Producer
#(
.
INIT
(
1
)
,
.
CHUNKS
(
1
))
p3
(
clock
,
bar
[
3
:
3
])
;
Producer
#(
.
INIT
(
2
)
,
.
CHUNKS
(
1
))
p4
(
clock
,
bar
[
4
+:
1
])
;
Producer
#(
.
INIT
(
3
))
p5
(
clock
,
bar
[
5
:
9
])
;
initial
$
monitor
(
"%d %b%b%b%b%b %b%b%b%b%b%b%b%b%b%b"
,
$
time
,
...
...
test/basic/multipack_port.v
View file @
5ad48494
module
Producer
(
clock
,
data
)
;
parameter
INIT
=
0
;
parameter
CHUNKS
=
5
;
input
clock
;
output
reg
[
54
:
0
]
data
;
initial
data
[
11
*
4
]
=
INIT
;
output
reg
[
11
*
CHUNKS
-
1
:
0
]
data
;
initial
data
[
11
*
(
CHUNKS
-
1
)
+:
11
]
=
INIT
;
always
@
(
clock
)
begin
:
block_name
integer
i
,
j
;
for
(
i
=
4
;
i
>=
0
;
i
--
)
begin
for
(
i
=
(
CHUNKS
-
1
)
;
i
>=
0
;
i
--
)
begin
for
(
j
=
9
;
j
>=
0
;
j
--
)
begin
data
[
11
*
(
4
-
i
)
+
j
+
1
]
=
data
[
11
*
(
4
-
i
)
+
j
]
;
data
[
11
*
(
(
CHUNKS
-
1
)
-
i
)
+
j
+
1
]
=
data
[
11
*
((
CHUNKS
-
1
)
-
i
)
+
j
]
;
end
if
(
i
!=
0
)
data
[
11
*
(
4
-
i
)
+
0
]
=
data
[
11
*
(
4
-
(
i
-
1
))
+
10
]
;
data
[
11
*
(
(
CHUNKS
-
1
)
-
i
)
+
0
]
=
data
[
11
*
((
CHUNKS
-
1
)
-
(
i
-
1
))
+
10
]
;
end
data
[
11
*
4
]
=
~
data
[
11
*
4
]
;
data
[
11
*
(
CHUNKS
-
1
)]
=
~
data
[
11
*
(
CHUNKS
-
1
)
]
;
end
endmodule
...
...
@@ -28,8 +29,10 @@ module top;
Producer
#(
.
INIT
(
0
))
p1
(
clock
,
foo
)
;
wire
[
109
:
0
]
bar
;
Producer
#(
.
INIT
(
0
))
p2
(
clock
,
bar
[
54
:
0
])
;
Producer
#(
.
INIT
(
1
))
p3
(
clock
,
bar
[
109
:
55
])
;
Producer
#(
.
INIT
(
0
)
,
.
CHUNKS
(
3
))
p2
(
clock
,
bar
[
109
-:
33
])
;
Producer
#(
.
INIT
(
1
)
,
.
CHUNKS
(
1
))
p3
(
clock
,
bar
[
76
-:
11
])
;
Producer
#(
.
INIT
(
2
)
,
.
CHUNKS
(
1
))
p4
(
clock
,
bar
[
55
+:
11
])
;
Producer
#(
.
INIT
(
3
))
p5
(
clock
,
bar
[
54
-:
55
])
;
initial
$
monitor
(
"%d %b %b"
,
$
time
,
foo
,
bar
)
;
...
...
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