{#- Error Logging Logic Template -#}
{%- if error_config.enable_error_logging or false %}
    // Error Logging Logic
    always_ff @(posedge clk or negedge reset_n) begin
        if (!reset_n) begin
            error_log_ptr <= 4'h0;
            for (int i = 0; i < 16; i++) begin
                error_log[i] <= 32'h0;
            end
        end else if (error_state == ERR_LOGGING) begin
            error_log[error_log_ptr] <= {
                8'h0,  // Reserved
                error_recovery_timer,
                retry_count,
                timeout_error, crc_error, parity_error, ecc_error
            };
            error_log_ptr <= error_log_ptr + 1;
        end
    end
{%- else %}
    // Error logging disabled
{%- endif %}