samitbasu / rust-hdl

A framework for writing FPGA firmware using the Rust Programming Language
Other
325 stars 17 forks source link

Arithmetic shift right not compiling #8

Closed john-terrell closed 1 year ago

john-terrell commented 1 year ago

Attempting to perform an arithmetic shift right fails to compile. Is there a better way to handle this?

            self.result.next = signed_cast(self.a.val()) >> self.b.val();
samitbasu commented 1 year ago

I currently only support right and left shift if the two arguments are of the same bit width. So you should be able to do something like:

self.result.next = a >> bit_cast::<M,N>(b);

This will satisfy Rust. Can you try that?

samitbasu commented 1 year ago

Ok - I added support for A << B where A and B are different bit widths. No support for signed ops in this branch, but unsigned ops should work. The performance won't be great, but the flexibility is probably more important.