www.pudn.com > x86.rar > compare32.v, change:2007-12-05,size:1309b


module compare32(compOut, compIn1, compIn2);
input [31:0] compIn1, compIn2;
output [2:0] compOut;
reg [2:0] compOut;
reg [31:0]claIn1;
reg [31:0]claIn2;
wire [31:0]claOut;
wire [32:1]carryOut;
reg [31:0]twoCmpIn;
wire [31:0]twoCmpOut;

cla32Bit cla1(claOut,carryOut,claIn1,claIn2,1'b0);
twosComp comp(twoCmpOut,twoCmpIn);
always @ (compIn2)
begin
        twoCmpIn = compIn2;
end

always @ (compIn1 or twoCmpOut)
begin
        claIn1 = compIn1;
        claIn2 = twoCmpOut;
end

always @ (claOut or carryOut or compIn1 or compIn2)
begin

        if(!(|claOut))
        begin
                compOut = 3'd2;
        end
        else
        if(!(|compIn1 ) || !(|compIn2))
        begin

                if(!(|compIn1))
                begin
                        if(!(|compIn2))
                                compOut = 3'd2;
                        else
                                compOut = 3'd1;
                end
                else
                if(!(|compIn2 ))
                begin
                        compOut = 3'd4;
                end

        end
        else
        begin
                if(carryOut[32]===1)
                begin
                        compOut = 3'd4;
                end
                else
                        compOut = 3'd1;

        end
end

endmodule