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


// Used to compare two 8-bit values



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

cla8Bit cla1(claOut,carryOut,claIn1,claIn2,1'b0);
twosComp8 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[8]===1)
                begin
                        compOut = 3'd4;
                end
                else
                        compOut = 3'd1;

        end
end

endmodule