mirror of
https://github.com/zachjs/sv2v.git
synced 2026-08-31 09:44:27 +02:00
simplify $bits on simple part selects
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
module top;
|
||||
parameter A = 3;
|
||||
parameter B = 4;
|
||||
logic [A*B-1:0] arr;
|
||||
initial begin
|
||||
arr = 0;
|
||||
for (integer i = 0; i < A; ++i) begin
|
||||
// yes this is silly but it captures an interesting edge case
|
||||
arr[i * B +: B] = $bits(arr[i * B +: B])'(i);
|
||||
end
|
||||
$display("%b", arr);
|
||||
end
|
||||
endmodule
|
||||
@@ -0,0 +1,14 @@
|
||||
module top;
|
||||
parameter A = 3;
|
||||
parameter B = 4;
|
||||
reg [A*B-1:0] arr;
|
||||
initial begin : foo
|
||||
integer i;
|
||||
arr = 0;
|
||||
for (i = 0; i < A; ++i) begin
|
||||
arr[i * B +: B] = i;
|
||||
end
|
||||
$display("%b", arr);
|
||||
end
|
||||
endmodule
|
||||
|
||||
Reference in New Issue
Block a user