A possible reason the design does not meet timing is that it contains one or more barrel shifters in series with other combinatorial logic. Whenever a shift operator is used with a variable operand i.e. "a = b << c;" Nios® II C2H generates barrelshift logic. The barrelshift logic generated by C2H implements large numbers of combinatorial multiplexers which can significantly affect the design's timing. The following two examples show source code that may cause timing degradation due to barrel shifters.
Combinatorial Shift Input:
Below is an example of a combinatorial shift input into the barrel shifter that may cause timing degradation.
int a, b, c, d, result, shift_distance;
result = (a b c d) >> shift_distance;
The addition result is used as the operand to the shift operator, so a long timing path is created between one of the addition inputs and ‘result’. To increase the amount of pipelining, assign the addition result to a temporary variable as shown below:
int a, b, c, d, addition_result, shift_distance;
addition_result = a b c d;
result = addition_result >> shift_distance;
Combinatorial Shift Output:
Below is an example of a combinatorial shift output from the barrel shifter that may cause timing degradation.
int a, b, c, d, result, shift_distance;
result = (a >> shift_distance) b c d;
The shift result is used as an operand to an addition operator, so a long timing path is created between ‘a’ and ‘result’. To increase the amount of pipelining, assign the shift result to a variable as shown below:
int a, b, c, d, result, shift_result, shift_distance;
shift_result = a >> shift_distance;
result = shift_result b c d;