circt icon indicating copy to clipboard operation
circt copied to clipboard

[ESI] Better names for unwrapped channels

Open mortbopet opened this issue 3 years ago • 0 comments

Currently, unwrap operators will create default names for wrap/unwrap ops:

  hw.module @handshake_store_in_ui64_ui32_out_ui32_ui64(%addrIn0: !esi.channel<i64>, %dataIn: !esi.channel<i32>, %ctrl: !esi.channel<none>) -> (dataToMem: !esi.channel<i32>, addrOut0: !esi.channel<i64>) {
    %rawOutput, %valid = esi.unwrap.vr %addrIn0, %2 : i64
    %rawOutput_0, %valid_1 = esi.unwrap.vr %dataIn, %2 : i32
    %rawOutput_2, %valid_3 = esi.unwrap.vr %ctrl, %2 : none
    %chanOutput, %ready = esi.wrap.vr %rawOutput_0, %1 : i32
    %chanOutput_4, %ready_5 = esi.wrap.vr %rawOutput, %1 : i64
    %0 = comb.and %ready, %ready_5 : i1
    %1 = comb.and %valid_1, %valid, %valid_3 : i1
    %2 = comb.and %0, %1 : i1
    hw.output %chanOutput, %chanOutput_4 : !esi.channel<i32>, !esi.channel<i64>
  }

However, referenced SSA values may already have a meaningful name or a name attribute or a name attribute. These names should be used in the generated asm names:

  hw.module @handshake_store_in_ui64_ui32_out_ui32_ui64(%addrIn0: !esi.channel<i64>, %dataIn: !esi.channel<i32>, %ctrl: !esi.channel<none>) -> (dataToMem: !esi.channel<i32>, addrOut0: !esi.channel<i64>) {
    %addrIn0_raw, %addrIn0_valid = esi.unwrap.vr %addrIn0, %2 : i64
    %dataIn_raw, %dataIn_valid = esi.unwrap.vr %dataIn, %2 : i32
    %ctrl_raw, %ctrl_valid = esi.unwrap.vr %ctrl, %2 : none
    %chanOutput, %ready = esi.wrap.vr %dataIn_raw, %1 : i32
    %chanOutput_4, %ready_5 = esi.wrap.vr %addrIn0_raw, %1 : i64
    %0 = comb.and %ready, %ready_5 : i1
    %1 = comb.and %dataIn_valid, %addrIn0_valid, %ctrl_valid : i1
    %2 = comb.and %0, %1 : i1
    hw.output %chanOutput, %chanOutput_4 : !esi.channel<i32>, !esi.channel<i64>
  }

Going even further, it should also be possible to derive names for wrap ops - these are often used to generate module outputs, which have names associated with them.

mortbopet avatar Sep 23 '22 11:09 mortbopet