{#- Error Counting Logic Template -#}
    // Error Counting Logic
    always_ff @(posedge clk or negedge reset_n) begin
        if (!reset_n) begin
            correctable_error_count <= 8'h0;
            uncorrectable_error_count <= 8'h0;
        end else if (error_state == ERR_DETECTED) begin
            if (parity_error || ecc_error) begin
                correctable_error_count <= correctable_error_count + 1;
            end else if (timeout_error || crc_error) begin
                uncorrectable_error_count <= uncorrectable_error_count + 1;
            end
        end
    end