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, min
);
    wire [3:0] max0, max1;
    wire [3:0] min0, min1;

    assign max0 = (a > b) ? a : b;
    assign max1 = (c > d) ? c : d;
    
    assign min0 = (a > b) ? b : a;
    assign min1 = (c > d) ? d : c;

    assign max = (max0 > max1) ? max0 : max1;
    assign min = (min0 > min1) ? min1 : min0;
endmodule
    
    

 

Was this helpful?
Upvote
Downvote