cucapra / dahlia

Time-sensitive affine types for predictable hardware generation
https://capra.cs.cornell.edu/dahlia
MIT License
130 stars 8 forks source link

Function calls stored in temporaries. #333

Open cgyurgyik opened 3 years ago

cgyurgyik commented 3 years ago

See discussion and related issues below: Yup, that makes sense. This is the problem mentioned in #264. Take a look at this group:

    group let0 {
      exp0.exponent = A_read0_0.out;
      exp0.go = !exp0.done ? 1'd1;

      div_pipe0.left = exp0.out; // ASSUMES exp0.out is done immediately
      div_pipe0.right = const1.out;
      div_pipe0.go = !div_pipe0.done ? 1'd1;

      bin_read0_0.in = div_pipe0.out;
      bin_read0_0.write_en = div_pipe0.done;

      let0[done] = bin_read0_0.done;
    }

The short term fix is to have the backend rewrite:

let x = exp(Res[0]) / 1;

into:

let _tmp = expr(Res[0]);
---
let x = _tmp / 1;

Open an issue in the Dahlia repo saying that function calls need to be stored in temporaries.

For you, the temporary fix is to manually rewrite the code to do this.

Originally posted by @rachitnigam in https://github.com/cucapra/futil/issues/284#issuecomment-737376805