Commit 2d7982f8 by Zachary Snow

simplify $bits on simple part selects

parent eb93ba67
......@@ -136,4 +136,11 @@ convertBits (Right e) =
Nothing -> Number "32"
Just 0 -> Number "32"
Just idx -> Number $ take idx n
Range expr mode range ->
BinOp Mul size $ convertBits $ Right $ Bit expr (Number "0")
where
size = case mode of
NonIndexed -> rangeSize range
IndexedPlus -> snd range
IndexedMinus -> snd range
_ -> DimsFn FnBits $ Left $ TypeOf e
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment