Prev Problem
Next Problem

68. 4-bit Comparator

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

Code

/*Write your code here*/
module maxmin4 (
    input  [3:0] a, b, c, d,
    output [3:0] max,
    output [3:0] min
);
    wire [3:0] max_1 = (a >= b) ? a : b;
    wire [3:0] min_1 = (a  <  b) ? a : b;

    wire [3:0] max_2 = (c >= d) ? c : d;
    wire [3:0] min_2 = (c  <  d) ? c : d;

    assign max = (max_1 >= max_2) ? max_1 : max_2;
    assign min = (min_1  <  min_2) ? min_1 : min_2;
endmodule

 

Was this helpful?
Upvote
Downvote