4-bit comparator X75958


Statement
 

pdf   zip   verilog

4-bit comparator

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

Specification

module cmp4(a, b, eq, gt, lt);
    input [3: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 four instances of this circuit.

Input

  • a and b are the two 4-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