// Synthesizable generic design.

module alu_40181
(
    input        [3:0] a,
    input        [3:0] b,
    input        [1:0] op,
    output       [3:0] result,
    output             carry_n
);

    logic [4:0] arithmetic;
    always_comb
        if (op [0])
            arithmetic = { 1'b0, a } + { 1'b0, ~ b } + 5'd1;
        else
            arithmetic = { 1'b0, a } + { 1'b0, b };
    assign result  = op [1] ? a ^ b : arithmetic [3:0];
    assign carry_n = op [1] ? 1'b1 : ~ arithmetic [4];

endmodule
