Visible to Intel only — GUID: wvg1573418461512
Ixiasoft
Visible to Intel only — GUID: wvg1573418461512
Ixiasoft
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);
}