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

module maxmin4 (
    input [3:0] a, b, c, d,
    output [3:0] max, min
);
    wire [3:0] max1, max2, min1, min2;
    assign max1 = (a <= b) ? b : a;
    assign max2 = (c <= d) ? d : c;
    assign max = (max1 <= max2)? max2 : max1;
    assign min1 = (a <= b) ? a : b;
    assign min2 = (c <= d) ? c : d;
    assign min = (min1 <= min2) ? min1 : min2; 
endmodule

 

Was this helpful?
Upvote
Downvote