The problem is, we are reading 256 in hdata354[2] using uint8 pointer. My guess is, 256 read through uint8 pointer should return 0, but it returns 256 since this bug was not hit before. We could just cast to uint16 pointer as follows, and that would fix this particular case:
The fix here is different, since we're actually trying to read 65,536 in hdata338[1] as uint16. Firstly, 65,536 is beyond the range of uint16. Secondly, the bitArrWrite function only wrote uint16, so casting correctly to uint32 in codegen may not be sufficient.
There is some illegal code in LUT generation. @mainland's suggestion does fix https://github.com/dimitriv/Ziria/issues/123, but the problem is a bit more general.
For example, there is:
The problem is, we are reading 256 in hdata354[2] using uint8 pointer. My guess is, 256 read through uint8 pointer should return 0, but it returns 256 since this bug was not hit before. We could just cast to uint16 pointer as follows, and that would fix this particular case:
But there's also:
The fix here is different, since we're actually trying to read 65,536 in hdata338[1] as uint16. Firstly, 65,536 is beyond the range of uint16. Secondly, the bitArrWrite function only wrote uint16, so casting correctly to uint32 in codegen may not be sufficient.