@@ -37,6 +37,7 @@ module redmule_scheduler
3737
3838 input logic wq_valid_i ,
3939 input logic zeros_valid_i ,
40+ input logic next_wrow_valid_i ,
4041
4142 input logic engine_flush_i ,
4243
@@ -159,7 +160,7 @@ module redmule_scheduler
159160 end
160161 end
161162
162- assign x_done_en = x_rows_iter_en && x_rows_iter_q == reg_file_i.hwpe_params[X_ITERS ][31 : 16 ]- 1 ;
163+ assign x_done_en = flgs_streamer_i.x_stream_source_flags.ready_start && x_rows_iter_q == reg_file_i.hwpe_params[X_ITERS ][31 : 16 ] - 1 && x_w_iters_q == reg_file_i.hwpe_params[ W_ITERS ][ 15 : 0 ] - 1 && x_cols_iter_q == reg_file_i.hwpe_params[ X_ITERS ][ 15 : 0 ]- 1 ;
163164
164165 assign cntrl_x_buffer_o.height = x_cols_iter_q == reg_file_i.hwpe_params[X_ITERS ][15 : 0 ]- 1 && reg_file_i.hwpe_params[LEFTOVERS ][23 : 16 ] != '0 ? reg_file_i.hwpe_params[LEFTOVERS ][23 : 16 ] : D ;
165166 assign cntrl_x_buffer_o.slots = x_cols_iter_q == reg_file_i.hwpe_params[X_ITERS ][15 : 0 ]- 1 && reg_file_i.hwpe_params[LEFTOVERS ][23 : 16 ] != '0 ? reg_file_i.hwpe_params[X_SLOTS ] : D ;
@@ -170,6 +171,7 @@ module redmule_scheduler
170171 ******************************/
171172 logic [$clog2 (H - 1 )- 1 : 0 ] x_shift_cnt_d, x_shift_cnt_q;
172173 logic x_shift_cnt_en;
174+ logic [$clog2 (H - 1 )- 1 : 0 ] x_shift_offs_q;
173175
174176 always_ff @ (posedge clk_i or negedge rst_ni) begin : x_shift_counter
175177 if (~ rst_ni) begin
@@ -182,6 +184,14 @@ module redmule_scheduler
182184 end
183185 end
184186
187+ always_ff @ (posedge clk_i or negedge rst_ni) begin : x_shift_offset
188+ if (~ rst_ni) begin
189+ x_shift_offs_q <= '0 ;
190+ end else if (flgs_x_buffer_i.full && flgs_x_buffer_i.empty) begin
191+ x_shift_offs_q <= x_shift_cnt_q + x_shift_offs_q;
192+ end
193+ end
194+
185195 assign x_shift_cnt_en = (current_state == LOAD_W ) && ~ stall_engine;
186196 assign x_shift_cnt_d = x_shift_cnt_q == H - 1 ? '0 : x_shift_cnt_q + 1 ;
187197
@@ -616,15 +626,16 @@ module redmule_scheduler
616626
617627 // Check if the x buffer is full
618628 // Only enable this check when a new set of x columns is to be loaded
629+ // This check is performed one cycle in earlier (i.e. during the WAIT state) as the X buffer takes one cycle after the full signal is asserted to actually update the outputs
619630 assign check_x_full = flgs_x_buffer_i.full;
620- assign check_x_full_en = x_refill && x_shift_cnt_q == H - 1 && ~ x_done;
631+ assign check_x_full_en = x_refill && x_shift_cnt_q == ( H - 1 - x_shift_offs_q) && ~ x_done;
621632
622633 // Check if the new Y rows are loaded and ready to be pushed
623634 // Only enable this check when the results of an iteration are available
624635 assign check_y_loaded = flgs_z_buffer_i.loaded;
625636 assign check_y_loaded_en = z_wait_counter_q == PIPE_REGS && ~ w_done;
626637
627- assign check_quant_valid = (zeros_valid_i || flgs_w_buffer_i.gid_repeated) && wq_valid_i;
638+ assign check_quant_valid = (zeros_valid_i || flgs_w_buffer_i.gid_repeated) && wq_valid_i && (next_wrow_valid_i || current_state != LOAD_W || x_done_en) ;
628639 assign check_quant_valid_en = ~ w_done && reg_file_i.hwpe_params[DEQUANT_MODE ][0 ];
629640
630641 /* *****************************
@@ -635,17 +646,17 @@ module redmule_scheduler
635646 ~ check_x_full && check_x_full_en
636647 ) : current_state == LOAD_W && (
637648 ~ check_w_valid && check_w_valid_en ||
638- ~ check_x_full && check_x_full_en ||
639649 ~ check_y_loaded && check_y_loaded_en ||
640650 ~ check_quant_valid && check_quant_valid_en
641- ) || z_wait_counter_q == PIPE_REGS && flgs_z_buffer_i.z_priority;
651+ ) || z_wait_counter_q == PIPE_REGS && flgs_z_buffer_i.z_priority
652+ || current_state == WAIT && ~ check_x_full && check_x_full_en;
642653`else
643654 assign stall_engine = current_state == LOAD_W && (
644655 ~ check_w_valid && check_w_valid_en ||
645- ~ check_x_full && check_x_full_en ||
646656 ~ check_y_loaded && check_y_loaded_en ||
647657 ~ check_quant_valid && check_quant_valid_en
648- ) || z_wait_counter_q == PIPE_REGS && flgs_z_buffer_i.z_priority;
658+ ) || z_wait_counter_q == PIPE_REGS && flgs_z_buffer_i.z_priority
659+ || current_state == WAIT && ~ check_x_full && check_x_full_en;
649660`endif
650661
651662 always_ff @ (posedge clk_i or negedge rst_ni) begin : first_load_register
@@ -684,10 +695,12 @@ module redmule_scheduler
684695 if (~ rst_ni) begin
685696 x_refill <= '0 ;
686697 end else begin
687- if (clear_i || cntrl_scheduler_i.rst || cntrl_x_buffer_o.rst_w_index ) begin
698+ if (clear_i || cntrl_scheduler_i.rst) begin
688699 x_refill <= '0 ;
689700 end else if (flgs_x_buffer_i.empty) begin
690701 x_refill <= '1 ;
702+ end else if (cntrl_x_buffer_o.rst_w_index) begin
703+ x_refill <= '0 ;
691704 end
692705 end
693706 end
0 commit comments