module CmpModule
  (
   input wire [2:1]  alufn,
   input wire [31:0] a,
   input wire [31:0] b,

   output reg [31:0] cmp
   );
   wire [31:0] 	     s;
   wire 	     z;
   wire 	     v;
   wire 	     n;

   AddSub add_sub_inst_0
     ( 
       .alufn0(1'b1), .a(a), .b(b), .s(s), .z(z), .v(v), .n(n)
       );

   // Calculate LSB using combination of z, v, n and alufn[2:1]
   always @(alufn, z, v, n) begin
       if (alufn[2:1] == 2'b01) begin  // A == B
           cmp = {{31{1'b0}}, {z}};
       end else if (alufn[2:1] == 2'b10) begin // A < B
          cmp = {{31{1'b0}}, {n^v}};
       end else if (alufn[2:1] == 2'b11) begin // A <= B
          cmp = {{31{1'b0}}, {z | (n ^ v)}};
       end else begin
      	  cmp = 32'h00000000;
       end
   end

endmodule