Description
The SHARED pragma specifies that an array local variable or argument in a given scope is viewed as a single shared memory, distributing the available ports to the processes that access it.
If the array is a local variable in a dataflow region, the resulting memory implementation depends whether it is also stable or not. If a variable is also marked STABLE it does not have any synchronization except for individual memory reads and writes. Consistency (read-write and write-write order) must be ensured by the design itself.
However, if a variable is not STABLE it is synchronized like a regular Ping-Pong buffer, with depth but without a duplication of the array data. Consistency can be ensured by setting the depth small enough, which acts as the distance of synchronization between the producer and consumer.
Syntax
Place the pragma in the C source within the boundaries of the function, where the variable is defined, or the global variable is used.
#pragma HLS shared variable=<variable>
Options
Where:
-
variable=<variable>
: Specifies the name of the variable that does not change during execution of the function.
Examples
In this example, variable a
is shared among processes
under the p1
dataflow region:
#pragma HLS shared variable=a