pragma HLS expression_balance

Description

Sometimes a C-based specification is written with a sequence of operations resulting in a long chain of operations in RTL. With a small clock period, this can increase the latency in the design. By default, Vivado HLS rearranges the operations using associative and commutative properties. This rearrangement creates a balanced tree that can shorten the chain, potentially reducing latency in the design at the cost of extra hardware.

TheEXPRESSION_BALANCEpragma allows this expression balancing to be disabled, or to be expressly enabled, within a specified scope.

Syntax

Place the pragma in the C source within the boundaries of the required location.

#pragma HLS expression_balance off

Where:

  • off: Turns off expression balancing at this location.
    Tip:Leaving this option out of the pragma enables expression balancing, which is the default mode.

Example 1

This example explicitly enables expression balancing in functionmy_Func:

void my_func(char inval, char incr) { #pragma HLS expression_balance

Example 2

Disables expression balancing within functionmy_Func:

void my_func(char inval, char incr) { #pragma HLS expression_balance off

See Also

  • Vivado Design Suite User Guide: High-Level Synthesis(UG902)