diff --git a/libraries/base/dp/src/vhdl/dp_block_reshape_sync.vhd b/libraries/base/dp/src/vhdl/dp_block_reshape_sync.vhd index 5565aea4c2b96f31f706b2611455da7a41dbead9..f5d0538af1909dd2533edc5f3aaf6340c1cc7cee 100644 --- a/libraries/base/dp/src/vhdl/dp_block_reshape_sync.vhd +++ b/libraries/base/dp/src/vhdl/dp_block_reshape_sync.vhd @@ -45,11 +45,18 @@ -- is that a next dp_block_reshape_sync instance that reshapes back to the -- original snk_in block size recovers them. -- --- The src_index_arr[2:0] with sync index, sop index and valid index are also --- output. The sync index uses g_input_nof_data_per_sync and g_nof_counters --- = 3, instead of only 2. If the src_index_arr is left OPEN (unused), then --- this extra dp_counter level will get optimized away by synthesis and then --- the value of g_input_nof_data_per_sync is don't care. +-- Sync index: +-- The src_index_arr[2:0] with sync index, sop index and valid index are +-- also output. The sync index defaults to 0 and only counts if +-- c_nof_output_sync_per_input_sync > 1, which depends on +-- g_input_nof_data_per_sync. +-- If g_input_nof_data_per_sync <= c_reshape_nof_data_per_sync, then the +-- sync index defaults to 0 and then the value of g_input_nof_data_per_sync +-- is don't care. Therefore use g_input_nof_data_per_sync = 0 or 1 to +-- effectively disable the use of sync_index. +-- The sync index counts using dp_counter level 2, so with c_nof_counters +-- = 3. If the sync index does not need to count, then c_nof_counters = 2, +-- because dp_counter cannot support range(0,1,1) = [0]. -- -- Remarks: -- . The dp_block_reshape_sync supports pipelining and flow control, because it @@ -65,7 +72,7 @@ USE work.dp_stream_pkg.ALL; ENTITY dp_block_reshape_sync IS GENERIC ( - g_input_nof_data_per_sync : NATURAL := 96; -- nof data per input sync interval, used only for sync_index + g_input_nof_data_per_sync : NATURAL := 0; -- nof data per input sync interval, used only for sync_index g_reshape_nof_data_per_blk : NATURAL := 8; -- nof data per output block g_reshape_nof_blk_per_sync : NATURAL := 12; -- nof blocks per output sync interval g_reshape_bsn : BOOLEAN := FALSE; -- when TRUE reshape BSN else when FALSE pass on BSN @@ -89,16 +96,20 @@ END dp_block_reshape_sync; ARCHITECTURE str OF dp_block_reshape_sync IS CONSTANT c_reshape_nof_data_per_sync : NATURAL := g_reshape_nof_data_per_blk * g_reshape_nof_blk_per_sync; + + -- If g_input_nof_data_per_sync <= c_reshape_nof_data_per_sync then c_nof_output_sync_per_input_sync = 1, else the + -- assumption is that g_input_nof_data_per_sync is an integer multiple of c_reshape_nof_data_per_sync. CONSTANT c_nof_output_sync_per_input_sync : NATURAL := sel_a_b(g_input_nof_data_per_sync > c_reshape_nof_data_per_sync, g_input_nof_data_per_sync / c_reshape_nof_data_per_sync, 1); - CONSTANT c_nof_counters : NATURAL := 3; -- counter [0] is use for block reshape, - -- counter [1] is used for sync reshape, - -- counter [2] is only used for sync_index + -- counter [0] is use for block reshape, + -- counter [1] is used for sync reshape, + -- counter [2] is only used for sync_index if c_nof_output_sync_per_input_sync > 1 + CONSTANT c_nof_counters : NATURAL := sel_a_b(c_nof_output_sync_per_input_sync > 1, 3, 2); CONSTANT c_range_start : t_nat_natural_arr(c_nof_counters-1 DOWNTO 0) := (OTHERS=>0); - CONSTANT c_range_stop : t_nat_natural_arr(c_nof_counters-1 DOWNTO 0) := (c_nof_output_sync_per_input_sync, - g_reshape_nof_blk_per_sync, - g_reshape_nof_data_per_blk); + CONSTANT c_range_stop : t_nat_natural_arr(c_nof_counters-1 DOWNTO 0) := sel_a_b(c_nof_output_sync_per_input_sync > 1, + (c_nof_output_sync_per_input_sync, g_reshape_nof_blk_per_sync, g_reshape_nof_data_per_blk), + (g_reshape_nof_blk_per_sync, g_reshape_nof_data_per_blk)); CONSTANT c_range_step : t_nat_natural_arr(c_nof_counters-1 DOWNTO 0) := (OTHERS=>1); SIGNAL cnt_sosi_arr : t_dp_sosi_arr(c_nof_counters-1 DOWNTO 0); @@ -144,12 +155,17 @@ BEGIN count_src_out_arr => cnt_sosi_arr ); - + gen_sync_index : IF c_nof_output_sync_per_input_sync > 1 GENERATE sync_index <= TO_UINT(cnt_sosi_arr(2).data); END GENERATE; sop_index <= TO_UINT(cnt_sosi_arr(1).data); valid_index <= TO_UINT(cnt_sosi_arr(0).data); + + src_index_arr(2) <= sync_index; -- default 0, counting if c_nof_output_sync_per_input_sync > 1 + src_index_arr(1) <= sop_index; + src_index_arr(0) <= valid_index; + output_sync <= cnt_sosi_arr(1).sop; output_sop <= cnt_sosi_arr(0).sop; output_eop <= cnt_sosi_arr(0).eop;