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] max01, max23, min01, min23;
    
    assign max01 = (a>b) ? a : b;
    assign min01 = (a<b) ? a : b;
    assign max23 = (c>d) ? c : d;
    assign min23 = (c<d) ? c : d;

    assign max = (max01>max23) ? max01 : max23;
    assign min = (min01<min23) ? min01 : min23;
endmodule

 

Was this helpful?
Upvote
Downvote