JulianKemmerer / PipelineC

A C-like hardware description language (HDL) adding high level synthesis(HLS)-like automatic pipelining as a language construct/compiler feature.
https://github.com/JulianKemmerer/PipelineC/wiki
GNU General Public License v3.0
605 stars 50 forks source link

Inverted constants do not resolve to correct bit width #181

Closed JulianKemmerer closed 1 year ago

JulianKemmerer commented 1 year ago
int8_t r = ~0;
return r;

~0 resolved to a to_unsigned(1, 1) '1' instead of 0xFF all ones

So does ~0b00000000 ...

JulianKemmerer commented 1 year ago

Fixed in https://github.com/JulianKemmerer/PipelineC/commit/98460c5b33dbd76326b22b79cccd31fd9f19563a

int8_t r = ~0; is still not correct pipelinec since the '0' is a single bit literal - need to manually extend bit width. These are what is now works fine instead: int8_t r = ~(int8_t)0; int8_t r = ~0x00; int8_t r = ~0b00000000;