yupferris / kaze

An HDL embedded in Rust.
Apache License 2.0
194 stars 9 forks source link

Complete add/sub overloads #20

Open yupferris opened 3 years ago

yupferris commented 3 years ago

Currently, I've implemented add / sub for signals emulating std's primitive types' wrapping_add / wrapping_sub functionality, which I think is the most ergonomic in most cases.

However, there are cases where other behavior is desired - particularly if we want to extract the carry bit on overflow. std provides overflowing_add / overflowing_sub for these purposes, so I think we should:

Note that all of this can be emulated today with the current API - a user can concat low bits to lhs and rhs before add / sub, and they're free to pull apart the resulting Signal however they want.

I still want to handle mul separately; I believe its current behavior is correct/least surprising (but I'm open to feedback on this).