C/RTL co-simulation automatically verifies aspects of the DATAFLOW and DEPENDENCE directives.
If the DATAFLOW directive is used to pipeline tasks, it
inserts channels between the tasks to facilitate the flow of
data between them. It is typical for the channels to be
implemented with FIFOs and the FIFO depth specified using the
STREAM directive, or the
config_dataflow command. If a FIFO depth
is too small, the RTL simulation can stall. For example, if a
FIFO is specified with a depth of 2 but the producer task writes
three values before any data values are read by the consumer
task, the FIFO blocks the producer. In some conditions this can
cause the entire design to stall as described in Cosim Deadlock Viewer.
In this case, C/RTL co-simulation issues a message as shown below, indicating the channel in the DATAFLOW region is causing the RTL simulation to stall.
////////////////////////////////////////////////////////////////////////////// // ERROR!!! DEADLOCK DETECTED at 1292000 ns! SIMULATION WILL BE STOPPED! // ////////////////////////////////////////////////////////////////////////////// ///////////////////////// // Dependence cycle 1: // (1): Process: hls_fft_1kxburst.fft_rank_rad2_nr_man_9_U0 // Channel: hls_fft_1kxburst.stage_chan_in1_0_V_s_U, FULL // Channel: hls_fft_1kxburst.stage_chan_in1_1_V_s_U, FULL // Channel: hls_fft_1kxburst.stage_chan_in1_0_V_1_U, FULL // Channel: hls_fft_1kxburst.stage_chan_in1_1_V_1_U, FULL // (2): Process: hls_fft_1kxburst.fft_rank_rad2_nr_man_6_U0 // Channel: hls_fft_1kxburst.stage_chan_in1_2_V_s_U, EMPTY // Channel: hls_fft_1kxburst.stage_chan_in1_2_V_1_U, EMPTY ///////////////////////////////// // Total 1 cycles detected! /////////////////////////////////////////////////////////////
If co-simulation is attempted from the Vitis HLS IDE and the simulation results in a deadlock, the Vitis HLS IDE will automatically launch the Dataflow Viewer and show the processes involved in the deadlock (displayed in red). It will also show which channels are full (in red) versus empty (in white). In this case, review the implementation of the channels between the tasks and ensure any FIFOs are large enough to hold the data being generated.
In a similar manner, the RTL test bench is also configured to automatically check the validity of false dependencies specified using the DEPENDENCE directive. A warning message during co-simulation indicates the dependency is not false, and the corresponding directive must be removed to achieve a functionally valid design.
-disable_deadlock_detectionoption of the
cosim_designcommand disables these checks.