Handling negative numbers
Closed this issue · 2 comments
sa2257 commented
I'm getting errors when using negative numbers.
let a = -1;
gives me
[Parsing error] [15.22] failure: '(' expected but '-' found
with brackets it gives me
[Parsing error] [15.23] failure: Base Failure
when used like this
let a = (0-1);
it generates cpp, but with one bit
ap_int<1> MISMATCH_SCORE = (0 - 1);
sampsyo commented
Curiously, parenthesizing the negative yields a less scrutable error message:
[Parsing error] [1.10] failure: Base Failure
let a = (-1);
^
Anyway, as for your current workaround, how about giving those explicit types?
let MISMATCH_SCORE: bit<2> = (0-1);
let GAP_SCORE: bit<2> = (0-1);
sa2257 commented
Curiously, parenthesizing the negative yields a less scrutable error message:
[Parsing error] [1.10] failure: Base Failure let a = (-1); ^
Anyway, as for your current workaround, how about giving those explicit types?
let MISMATCH_SCORE: bit<2> = (0-1); let GAP_SCORE: bit<2> = (0-1);
Oh yes! 🤦♂️ That's way better than manually changing the cpp. https://github.com/cucapra/fuse-benchmarks/commit/2f0e2bd50f238237af82da3c87287cccf651ac04