module clifford_alu #(
    parameter WIDTH = 32
)(
    input wire clk,
    input wire rst_n,
    // Inputs: Two quaternions q1 = w1 + x1*i + y1*j + z1*k
    // Represented as 4 packed scalars
    input wire [WIDTH-1:0] w1, x1, y1, z1,
    input wire [WIDTH-1:0] w2, x2, y2, z2,
    input wire [1:0] opcode, // 01: Geometric Product (Mul)
    output reg [WIDTH-1:0] w_out, x_out, y_out, z_out
);

    // Geometric Algebra / Quaternion Multiplication
    // (w1, v1) * (w2, v2) = (w1w2 - v1.v2, w1v2 + w2v1 + v1 x v2)

    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            w_out <= 0; x_out <= 0; y_out <= 0; z_out <= 0;
        end else begin
            if (opcode == 2'b01) begin
                // Scalar Part: w1w2 - x1x2 - y1y2 - z1z2
                w_out <= (w1*w2) - (x1*x2) - (y1*y2) - (z1*z2);

                // Vector Part i: w1x2 + x1w2 + y1z2 - z1y2
                x_out <= (w1*x2) + (x1*w2) + (y1*z2) - (z1*y2);

                // Vector Part j: w1y2 - x1z2 + y1w2 + z1x2
                y_out <= (w1*y2) - (x1*z2) + (y1*w2) + (z1*x2);

                // Vector Part k: w1z2 + x1y2 - y1x2 + z1w2
                z_out <= (w1*z2) + (x1*y2) - (y1*x2) + (z1*w2);
            end
        end
    end

endmodule
