// compare.sv // Magnitude comparator. The same bits give different answers when they are // treated as unsigned or as two's complement signed numbers. module compare #( parameter int WIDTH = 8 ) ( input logic [WIDTH-1:0] a, input logic [WIDTH-1:0] b, output logic eq, output logic lt_u, // a < b, unsigned output logic lt_s // a < b, signed ); assign eq = (a == b); assign lt_u = (a < b); assign lt_s = ($signed(a) < $signed(b)); endmodule