diff --git a/deepsocflow/rtl/proc_engine.sv b/deepsocflow/rtl/proc_engine.sv index 830a2de..03c5b21 100644 --- a/deepsocflow/rtl/proc_engine.sv +++ b/deepsocflow/rtl/proc_engine.sv @@ -67,9 +67,8 @@ module proc_engine #( logic [COLS-1:0] en_outshift, sel_outshift, outshift_flag; logic shift_out_ready_last_col_prev; - logic [BITS_COLS-1:0] count_outshift; - logic cnt_en; - + logic [BITS_COLS-1:0] cnt_outshift, cnt_acc; + logic cnt_outshift_valid, cnt_acc_valid; logic [COLS-1:0] s_axis_tvalid; genvar k2, c_1; @@ -322,9 +321,63 @@ endgenerate assign m_last_pkt = shift_last_pkt [COLS-1]; // -------------- OUTPUT SHIFTER ---------------- + //logic [BITS_COLS-1:0] highest_acc, lowest_outshift; + //logic cnt_acc_valid_next, cnt_outshift_valid_next; + // integer a, b; + // always_comb begin // priority encoder - used to find highest acc. + // highest_acc = 0; + // cnt_acc_valid_next = 0; + // for (a = 0; a < COLS-1; a++) begin + // if(acc_m_valid_next[a] == 1) begin + // highest_acc = a; + // cnt_acc_valid_next = 1; + // break; + // end + // end + // end + + // always_comb begin //TODO priority encoder - used to find lowest outshift. + // lowest_outshift = 0; + // cnt_outshift_valid_next = 0; + // for (b = 0; b < COLS-1; b++) begin + // if(~shift_out_ready[b]) begin + // lowest_outshift = b; + // cnt_outshift_valid_next = 1; + // break; + // end + // end + // end + + always@(posedge clk `OR_NEGEDGE(resetn))begin + if(!resetn) begin + {cnt_acc_valid, cnt_outshift_valid, cnt_acc, cnt_outshift} <= 0; + end + else begin + if(en[0] && acc_m_valid_next[0]) cnt_acc_valid <= 1; + else if (shift_out_ready[COLS-1] && acc_m_valid[COLS-1]) cnt_acc_valid <= 0; // reset condition + + if (cnt_acc_valid && en[0]) begin + if (cnt_acc==COLS-1) cnt_acc <= 0; + else cnt_acc <= cnt_acc + 1; + end + + // cnt_acc_valid <= cnt_acc_valid_next; + // cnt_acc <= highest_acc; - //assign en_mac = &(~acc_m_valid | shift_out_ready); - //assign en[0] = ~acc_m_valid[0] | shift_out_ready[0]; + // cnt_outshift_valid <= cnt_outshift_valid_next; + // cnt_outshift <= lowest_outshift; + if(~sel_outshift[0]) cnt_outshift_valid <= 1; + + if (m_ready & outshift_flag[COLS-1]) begin + if (cnt_outshift==COLS-1) cnt_outshift <= 0; + else cnt_outshift <= cnt_outshift + 1; + end + end + end + + wire freeze; + assign freeze = ((cnt_outshift <= cnt_acc) && cnt_acc_valid && cnt_outshift_valid); + for(c=0; c