06-03-2014 09:31 AM - edited 06-03-2014 09:32 AM
Keeping the constant as an I32 is using less memory. With the coercion, you are actually adding an extra byte to the memeory (the initial I8). Though, the compiler will turn that all into an I32 constant anyways. But it just looks bad having the conversion straight off of a constant.
Keeping track of the array index is simple. Just use a shift register. The only remotely difficult part is taking care of the rollover, which is simply a comparison with a select.
06-03-2014 10:34 AM
@crossrulz wrote:
Keeping the constant as an I32 is using less memory. With the coercion, you are actually adding an extra byte to the memeory (the initial I8). Though, the compiler will turn that all into an I32 constant anyways. But it just looks bad having the conversion straight off of a constant.
I would be surprised if the FPGA compiler will retain the array index as I32 and carry it aournd as 32bits in the fabric. Since we have fixed sized array of 20 elements, it would only need 5 bits for the index. Just wondering...
06-03-2014 10:43 AM
@altenbach wrote:
@crossrulz wrote:
Keeping the constant as an I32 is using less memory. With the coercion, you are actually adding an extra byte to the memeory (the initial I8). Though, the compiler will turn that all into an I32 constant anyways. But it just looks bad having the conversion straight off of a constant.
I would be surprised if the FPGA compiler will retain the array index as I32 and carry it aournd as 32bits in the fabric. Since we have fixed sized array of 20 elements, it would only need 5 bits for the index. Just wondering...
You are likely correct. But, as I stated already, the compiler will constant fold it anyways. FPGA is a different beast, but some of these priciples remain the same.