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);

  assign max=(a>=b && a>=c && a>=d)?a:(b>=a && b>=c && b>=d)?b:(c>=a && c>=b && c>=d)?c:d;
  assign min=(a<=b && a<=c && a<=d)?a:(b<=a && b<=c && b<=d)?b:(c<=a && c<=b && c<=d)?c:d;

endmodule

 

Was this helpful?
Upvote
Downvote