cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
322 stars 92 forks source link

[API] Fix bit slicing operations & Introduce reverse slicing #291

Closed seanlatias closed 4 years ago

seanlatias commented 4 years ago

Issue: #289

Root cause: The IR equality pass does not handle the bit slicing cases, which leads to segfault.

Solution: Make sure all IR nodes are handled correctly in the IR equality pass.

Test: tests/issues/test_issue_289.py

Other comments: We also change the returned data type for bit slicing. It should always be uint if the bitwidth can be inferred. In this PR, we also introduce the reverse bit slicing. Following is an example:

a = 0b10010010
# a[4:0] => 0b0010
# a[0:4] => 0b0100

Similarly, we can also set bit slices in reverse.

a = 0b10010010
# a[4:0] = 0b1101 => a = 0b10011101
# a[0:4] = 0b1101 => a = 0b10010111