circt icon indicating copy to clipboard operation
circt copied to clipboard

[Moore] Add MergeExtractRef pass.

Open terapines-osc-circt opened this issue 1 year ago • 1 comments

This pass is used to merge moore.extract_ref together in the big-endian order without existing in if/for statements and nested moore.extract_ref. For example:

bit [31:0] arr;
assign arr[23:16] = 8'd5;
always_comb begin
arr[15:8] = 8'd10;
end

After running this pass

bit [31:0] arr;
...
always_comb begin
...
arr[15:8] = 8'd10;
%concat = {arr[31:24], 8'd5, 8'd10, arr[7:0]} // concat
arr = %concat
end

However, cannot handle the complex situations of missing some middle bits, such as:

bit [3:0] arr;
arr[3:2] = 2'b0;
arr[0] = 1'b0;

arr[1] don't be assigned a value, this situation belongs to missing some middle bits.

And if the same slice is assigned a value repeatedly, will emit an error and interrupt.

terapines-osc-circt avatar Jul 16 '24 03:07 terapines-osc-circt

Maybe this pass should be removed, but I think some thought of this pass can be applied when after executing

@fabianschuiki mentioned combine non-blocking assignments to the same variable (https://github.com/llvm/circt/pull/7075)

Then analyze and map to a moore.register op.

terapines-osc-circt avatar Jul 16 '24 05:07 terapines-osc-circt