mirror of https://github.com/zachjs/sv2v.git
fix partial packing of multidimensional unpacked arrays
This commit is contained in:
parent
5fd21ebfb0
commit
43883efa5c
|
|
@ -60,9 +60,9 @@ rewriteDeclM (decl @ (Variable d t x a e)) = do
|
||||||
case usedAsPacked of
|
case usedAsPacked of
|
||||||
Just depth -> do
|
Just depth -> do
|
||||||
let (tf, rs) = typeRanges t
|
let (tf, rs) = typeRanges t
|
||||||
let (shifted, rest) = splitAt (length a - depth) a
|
let (unpacked, packed) = splitAt depth a
|
||||||
let t' = tf $ shifted ++ rs
|
let t' = tf $ packed ++ rs
|
||||||
return $ Variable d t' x rest e
|
return $ Variable d t' x unpacked e
|
||||||
Nothing -> return decl
|
Nothing -> return decl
|
||||||
rewriteDeclM decl @ Net{} = traverseNetAsVarM rewriteDeclM decl
|
rewriteDeclM decl @ Net{} = traverseNetAsVarM rewriteDeclM decl
|
||||||
rewriteDeclM other = return other
|
rewriteDeclM other = return other
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,22 @@
|
||||||
module example(
|
module example(
|
||||||
input wire [7:0] inp,
|
input wire inp [7:0],
|
||||||
output wire [7:0] out
|
output wire out [7:0]
|
||||||
);
|
);
|
||||||
assign out = ~inp;
|
for (genvar i = 0; i < 8; ++i)
|
||||||
|
assign out[i] = ~inp[i];
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module top;
|
module top;
|
||||||
reg arr1 [7:0][1:0];
|
reg arr1 [1:0][7:0];
|
||||||
reg arr2 [7:0][1:0][1:0];
|
reg arr2 [1:0][1:0][7:0];
|
||||||
wire [7:0] out1, out2;
|
wire out1 [7:0];
|
||||||
|
wire out2 [7:0];
|
||||||
example e1(arr1[0], out1);
|
example e1(arr1[0], out1);
|
||||||
example e2(arr2[0][0], out2);
|
example e2(arr2[0][0], out2);
|
||||||
initial begin
|
initial begin
|
||||||
#1 arr1[0] = 8'hAD;
|
for (integer i = 0; i < 8; ++i) begin
|
||||||
#1 arr2[0][0] = 8'h42;
|
#1 arr1[0][i] = (8'hAD >> i) & 1'b1;
|
||||||
|
#1 arr2[0][0][i] = (8'h42 >> i) & 1'b1;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,11 @@ module top;
|
||||||
wire [7:0] out1, out2;
|
wire [7:0] out1, out2;
|
||||||
example e1(arr1[0], out1);
|
example e1(arr1[0], out1);
|
||||||
example e2(arr2[0][0], out2);
|
example e2(arr2[0][0], out2);
|
||||||
initial begin
|
initial begin : blk
|
||||||
#1 arr1[0] = 8'hAD;
|
integer i;
|
||||||
#1 arr2[0][0] = 8'h42;
|
for (i = 0; i < 8; i = i + 1) begin
|
||||||
|
#1 arr1[0][i] = (8'hAD >> i) & 1'b1;
|
||||||
|
#1 arr2[0][0][i] = (8'h42 >> i) & 1'b1;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue