n-bit comparator X37457


Statement
 

pdf   zip

Design a circuit that compares two nn-bit numbers represented in binary code and indicates whether the first is greater than, equal to or smaller than the second.

The number of bits of the numbers must be a parameter of the module with a default value as shown in the specification.

Specification

module cmp(a, b, eq, gt, lt);
    parameter N=16;
    input [N-1:0] a, b;
    output eq, gt, lt;

Hint

Design a 1-bit comparator that receives the result of the comparison of the least-significant bits. Use nn instances of this circuit.

Input

  • a and b are the two nn-bit input numbers.

Output

  • eq indicates that a=b.

  • gt indicates that a>>b.

  • lt indicates that a<<b.

Information
Author
Jordi Cortadella
Language
English
Official solutions
Verilog
User solutions
Verilog