Intel® High Level Synthesis Compiler Standard Edition: Best Practices Guide
ID
683259
Date
12/18/2019
Public
1. Intel® HLS Compiler Standard Edition Best Practices Guide
2. Best Practices for Coding and Compiling Your Component
3. Interface Best Practices
4. Loop Best Practices
5. Memory Architecture Best Practices
6. Datatype Best Practices
7. Advanced Troubleshooting
A. Intel® HLS Compiler Standard Edition Best Practices Guide Archives
B. Document Revision History for Intel® HLS Compiler Standard Edition Best Practices Guide
6.2. Avoid Negative Bit Shifts When Using the ac_int Datatype
The ac_int datatype differs from other languages, including C and Verilog, in bit shifting. By default, if the shift amount is of a signed datatype ac_int allows negative shifts.
In hardware, this negative shift results in the implementation of both a left shifter and a right shifter. The following code example shows a shift amount that is a signed datatype.
int14 shift_left(int14 a, int14 b) {
return (a << b);
}
If you know that the shift is always in one direction, to implement an efficient shift operator, declare the shift amount as an unsigned datatype as follows:
int14 efficient_left_only_shift(int14 a, uint14 b) {
return (a << b);
}