EPFL-LAP / dynamatic

DHLS (Dynamic High-Level Synthesis) compiler based on MLIR
Other
65 stars 19 forks source link

[HandshakeToHW] Incorrect floating-point constant op to extern module mapping #122

Closed Jiahui17 closed 3 months ago

Jiahui17 commented 3 months ago

This is partially related to a comment in #117

Benchmarks (non-exhausive):

Issue 1:

handshake_export.mlir

    %31 = constant %30 {handshake.bb = 2 : ui32, handshake.name = "constant11", value = 0.699999988 : f32} : <f32>

hw.mlir

    %constant11.outs = hw.instance "constant11" @handshake_constant_1(ctrl: %source3.outs: !handshake.control<>, clk: %clk: i1, rst: %rst: i1) -> (outs: !handshake.channel<i32>)
...
  hw.module.extern @handshake_constant_1(in %ctrl : !handshake.control<>, in %clk : i1, in %rst : i1, out outs : !handshake.channel<i32>) attributes {hw.name = "handshake.constant", hw.parameters = {DATA_WIDTH = 32 : ui32, VALUE = "00000000000000000000000000000000"}}

Issue 2:

In handshake_export.mlir:

    %53 = constant %52 {handshake.bb = 3 : ui32, handshake.name = "constant7", value = 1.000000e+00 : f32} : <f32>

In hw.mlir:

    %constant7.outs = hw.instance "constant7" @handshake_constant_3(ctrl: %source2.outs: !handshake.control<>, clk: %clk: i1, rst: %rst: i1) -> (outs: !handshake.channel<i32>)
...
  hw.module.extern @handshake_constant_3(in %ctrl : !handshake.control<>, in %clk : i1, in %rst : i1, out outs : !handshake.channel<i32>) attributes {hw.name = "handshake.constant", hw.parameters = {DATA_WIDTH = 32 : ui32, VALUE = "00000000000000000000000000000001"}}

Here a floating-point constant 1.0 is mapped to an integer 1.